forked from lirios/fluid
/
clipboard.cpp
58 lines (48 loc) · 1.14 KB
/
clipboard.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* This file is part of Fluid.
*
* Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
* Copyright (C) 2017 Michael Spencer <sonrisesoftware@gmail.com>
*
* $BEGIN_LICENSE:MPL2$
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* $END_LICENSE$
*/
#include "clipboard.h"
#include <QGuiApplication>
/*!
\qmltype Clipboard
\inqmlmodule Fluid.Core
\ingroup fluidcore
\brief Clipboard.
*/
Clipboard::Clipboard(QObject *parent)
: QObject(parent)
, m_clipboard(QGuiApplication::clipboard())
{
connect(m_clipboard, &QClipboard::dataChanged, this, &Clipboard::textChanged);
}
/*!
\qmlproperty string Clipboard::text
This property holds the clipboard text.
*/
QString Clipboard::text() const
{
return m_clipboard->text();
}
void Clipboard::setText(const QString &text)
{
m_clipboard->setText(text);
}
/*!
\qmlmethod void Clipboard::clear()
Clear the global clipboard contents.
*/
void Clipboard::clear()
{
m_clipboard->clear();
}