diff options
Diffstat (limited to 'framework/src')
-rw-r--r-- | framework/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | framework/src/clipboardproxy.cpp | 52 | ||||
-rw-r--r-- | framework/src/clipboardproxy.h | 39 | ||||
-rw-r--r-- | framework/src/frameworkplugin.cpp | 2 |
4 files changed, 94 insertions, 0 deletions
diff --git a/framework/src/CMakeLists.txt b/framework/src/CMakeLists.txt index 034feba9..85ad8344 100644 --- a/framework/src/CMakeLists.txt +++ b/framework/src/CMakeLists.txt | |||
@@ -40,6 +40,7 @@ set(SRCS | |||
40 | fabric.cpp | 40 | fabric.cpp |
41 | sinkfabric.cpp | 41 | sinkfabric.cpp |
42 | kubeimage.cpp | 42 | kubeimage.cpp |
43 | clipboardproxy.cpp | ||
43 | ) | 44 | ) |
44 | 45 | ||
45 | add_library(frameworkplugin SHARED ${SRCS}) | 46 | add_library(frameworkplugin SHARED ${SRCS}) |
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 | } | ||
diff --git a/framework/src/clipboardproxy.h b/framework/src/clipboardproxy.h new file mode 100644 index 00000000..9a965004 --- /dev/null +++ b/framework/src/clipboardproxy.h | |||
@@ -0,0 +1,39 @@ | |||
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 | #pragma once | ||
20 | |||
21 | #include <QObject> | ||
22 | class ClipboardProxy : public QObject | ||
23 | { | ||
24 | Q_OBJECT | ||
25 | Q_PROPERTY(QString text READ dataText WRITE setDataText NOTIFY dataChanged) | ||
26 | Q_PROPERTY(QString selectionText READ selectionText WRITE setSelectionText NOTIFY selectionChanged) | ||
27 | public: | ||
28 | explicit ClipboardProxy(QObject *parent = 0); | ||
29 | |||
30 | void setDataText(const QString &text); | ||
31 | QString dataText() const; | ||
32 | |||
33 | void setSelectionText(const QString &text); | ||
34 | QString selectionText() const; | ||
35 | |||
36 | signals: | ||
37 | void dataChanged(); | ||
38 | void selectionChanged(); | ||
39 | }; | ||
diff --git a/framework/src/frameworkplugin.cpp b/framework/src/frameworkplugin.cpp index 9c79f515..33bc8cbc 100644 --- a/framework/src/frameworkplugin.cpp +++ b/framework/src/frameworkplugin.cpp | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "settings/settings.h" | 34 | #include "settings/settings.h" |
35 | #include "fabric.h" | 35 | #include "fabric.h" |
36 | #include "kubeimage.h" | 36 | #include "kubeimage.h" |
37 | #include "clipboardproxy.h" | ||
37 | 38 | ||
38 | #include <QtQml> | 39 | #include <QtQml> |
39 | 40 | ||
@@ -65,4 +66,5 @@ void FrameworkPlugin::registerTypes (const char *uri) | |||
65 | qmlRegisterSingletonType<Kube::Fabric::Fabric>(uri, 1, 0, "Fabric", fabric_singletontype_provider); | 66 | qmlRegisterSingletonType<Kube::Fabric::Fabric>(uri, 1, 0, "Fabric", fabric_singletontype_provider); |
66 | 67 | ||
67 | qmlRegisterType<KubeImage>(uri, 1, 0, "KubeImage"); | 68 | qmlRegisterType<KubeImage>(uri, 1, 0, "KubeImage"); |
69 | qmlRegisterType<ClipboardProxy>(uri, 1, 0, "Clipboard"); | ||
68 | } | 70 | } |