summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-29 16:42:52 -0600
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-29 16:44:27 -0600
commitc092d555bd6d3e93a11625bfe76bb59b2e64e994 (patch)
tree0c899e74cafdb8878f92405d7b0e3df2b41078b5 /framework
parent51fbcca97ef9058cdb75c52ac77bdc728a296e4a (diff)
downloadkube-c092d555bd6d3e93a11625bfe76bb59b2e64e994.tar.gz
kube-c092d555bd6d3e93a11625bfe76bb59b2e64e994.zip
SelectableLabel to support copying individual labels
Diffstat (limited to 'framework')
-rw-r--r--framework/qml/Icons.qml1
-rw-r--r--framework/qml/SelectableLabel.qml45
-rw-r--r--framework/qmldir1
-rw-r--r--framework/src/CMakeLists.txt1
-rw-r--r--framework/src/clipboardproxy.cpp52
-rw-r--r--framework/src/clipboardproxy.h39
-rw-r--r--framework/src/frameworkplugin.cpp2
7 files changed, 141 insertions, 0 deletions
diff --git a/framework/qml/Icons.qml b/framework/qml/Icons.qml
index 3126c797..d9612013 100644
--- a/framework/qml/Icons.qml
+++ b/framework/qml/Icons.qml
@@ -42,6 +42,7 @@ Item {
42 property string replyToSender: "mail-reply-sender" 42 property string replyToSender: "mail-reply-sender"
43 property string outbox: "mail-folder-outbox" 43 property string outbox: "mail-folder-outbox"
44 property string outbox_inverted: "mail-folder-outbox-inverted" 44 property string outbox_inverted: "mail-folder-outbox-inverted"
45 property string copy: "edit-copy"
45 46
46 property string menu_inverted: "application-menu-inverted" 47 property string menu_inverted: "application-menu-inverted"
47 property string user: "im-user" 48 property string user: "im-user"
diff --git a/framework/qml/SelectableLabel.qml b/framework/qml/SelectableLabel.qml
new file mode 100644
index 00000000..920f5c7a
--- /dev/null
+++ b/framework/qml/SelectableLabel.qml
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2017 Michael Bohlender, <bohlender@kolabsys.com>
3 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick 2.7
21import QtQuick.Templates 2.0 as T
22import org.kube.framework 1.0 as Kube
23
24Kube.Label {
25 id: root
26 MouseArea {
27 id: mouseArea
28 anchors.fill: parent
29 hoverEnabled: true
30 z: 1
31 }
32 Kube.IconButton {
33 anchors {
34 left: parent.right
35 verticalCenter: parent.verticalCenter
36 }
37 iconName: Kube.Icons.copy
38 visible: mouseArea.containsMouse || hovered
39 color: Kube.Colors.backgroundColor
40 onClicked: clipboard.text = root.text
41 Kube.Clipboard {
42 id: clipboard
43 }
44 }
45}
diff --git a/framework/qmldir b/framework/qmldir
index c8e0ae58..d4ec9619 100644
--- a/framework/qmldir
+++ b/framework/qmldir
@@ -27,6 +27,7 @@ TextArea 1.0 TextArea.qml
27TextEditor 1.0 TextEditor.qml 27TextEditor 1.0 TextEditor.qml
28ToolTip 1.0 ToolTip.qml 28ToolTip 1.0 ToolTip.qml
29Label 1.0 Label.qml 29Label 1.0 Label.qml
30SelectableLabel 1.0 SelectableLabel.qml
30Heading 1.0 Heading.qml 31Heading 1.0 Heading.qml
31View 1.0 View.qml 32View 1.0 View.qml
32AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml 33AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml
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
45add_library(frameworkplugin SHARED ${SRCS}) 46add_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
24ClipboardProxy::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
34void ClipboardProxy::setDataText(const QString &text)
35{
36 QApplication::clipboard()->setText(text, QClipboard::Clipboard);
37}
38
39QString ClipboardProxy::dataText() const
40{
41 return QGuiApplication::clipboard()->text(QClipboard::Clipboard);
42}
43
44void ClipboardProxy::setSelectionText(const QString &text)
45{
46 QApplication::clipboard()->setText(text, QClipboard::Selection);
47}
48
49QString 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>
22class 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)
27public:
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
36signals:
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}