diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-29 16:42:52 -0600 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-29 16:44:27 -0600 |
commit | c092d555bd6d3e93a11625bfe76bb59b2e64e994 (patch) | |
tree | 0c899e74cafdb8878f92405d7b0e3df2b41078b5 /framework/src/clipboardproxy.cpp | |
parent | 51fbcca97ef9058cdb75c52ac77bdc728a296e4a (diff) | |
download | kube-c092d555bd6d3e93a11625bfe76bb59b2e64e994.tar.gz kube-c092d555bd6d3e93a11625bfe76bb59b2e64e994.zip |
SelectableLabel to support copying individual labels
Diffstat (limited to 'framework/src/clipboardproxy.cpp')
-rw-r--r-- | framework/src/clipboardproxy.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/framework/src/clipboardproxy.cpp b/framework/src/clipboardproxy.cpp new file mode 100644 index 00000000..aaa5052b --- /dev/null +++ b/framework/src/clipboardproxy.cpp | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekofp <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "clipboardproxy.h" | ||
20 | |||
21 | #include <QClipboard> | ||
22 | #include <QApplication> | ||
23 | |||
24 | ClipboardProxy::ClipboardProxy(QObject *parent) | ||
25 | : QObject(parent) | ||
26 | { | ||
27 | QClipboard *clipboard = QApplication::clipboard(); | ||
28 | QObject::connect(clipboard, &QClipboard::dataChanged, | ||
29 | this, &ClipboardProxy::dataChanged); | ||
30 | QObject::connect(clipboard, &QClipboard::selectionChanged, | ||
31 | this, &ClipboardProxy::selectionChanged); | ||
32 | } | ||
33 | |||
34 | void ClipboardProxy::setDataText(const QString &text) | ||
35 | { | ||
36 | QApplication::clipboard()->setText(text, QClipboard::Clipboard); | ||
37 | } | ||
38 | |||
39 | QString ClipboardProxy::dataText() const | ||
40 | { | ||
41 | return QGuiApplication::clipboard()->text(QClipboard::Clipboard); | ||
42 | } | ||
43 | |||
44 | void ClipboardProxy::setSelectionText(const QString &text) | ||
45 | { | ||
46 | QApplication::clipboard()->setText(text, QClipboard::Selection); | ||
47 | } | ||
48 | |||
49 | QString ClipboardProxy::selectionText() const | ||
50 | { | ||
51 | return QApplication::clipboard()->text(QClipboard::Selection); | ||
52 | } | ||