summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-31 15:20:01 -0600
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-31 17:32:54 -0600
commit6bf396f79b926d6a1ea04226474550d9962d52a8 (patch)
treed976f91477b3f30ee8de292ce7494136cd439c6a
parented90f285745279e91743851ae49eeccf1d95710f (diff)
downloadkube-6bf396f79b926d6a1ea04226474550d9962d52a8.tar.gz
kube-6bf396f79b926d6a1ea04226474550d9962d52a8.zip
Experimental SelectableItem
-rw-r--r--framework/qml/SelectableItem.qml87
-rw-r--r--framework/qmldir1
2 files changed, 88 insertions, 0 deletions
diff --git a/framework/qml/SelectableItem.qml b/framework/qml/SelectableItem.qml
new file mode 100644
index 00000000..0e22ede5
--- /dev/null
+++ b/framework/qml/SelectableItem.qml
@@ -0,0 +1,87 @@
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.Controls 2.2
22import org.kube.framework 1.0 as Kube
23import QtQuick.Layouts 1.3
24
25// QtObject {
26Item {
27 id: root
28 property string text
29 Rectangle {
30 anchors.fill: parent
31 color: "transparent"
32 border.color: Kube.Colors.highlightColor
33 border.width: 1
34 visible: mouseArea.containsMouse || menu.visible
35 }
36 MouseArea {
37 id: mouseArea
38 anchors.fill: parent
39 hoverEnabled: true
40 acceptedButtons: Qt.RightButton
41 z: 1
42 onClicked: {
43 menu.x = mouseX
44 menu.y = mouseY
45 menu.open()
46 mouse.accepted = true
47 }
48 }
49 Menu {
50 id: menu
51
52 height: layout.height
53 width: layout.width
54 background: Rectangle {
55 anchors.fill: parent
56 color: "transparent"
57 }
58 RowLayout {
59 id: layout
60 width: button.width
61 height: button.height
62 Kube.TextButton {
63 id: button
64 text: "Copy"
65 onClicked: {
66 if (root.text) {
67 clipboard.text = root.text
68 }
69 menu.close()
70 }
71 }
72 }
73 }
74 // Kube.IconButton {
75 // anchors {
76 // left: parent.right
77 // verticalCenter: parent.verticalCenter
78 // }
79 // iconName: Kube.Icons.copy
80 // visible: mouseArea.containsMouse || hovered
81 // color: Kube.Colors.backgroundColor
82 // onClicked: clipboard.text = root.text
83 // }
84 Kube.Clipboard {
85 id: clipboard
86 }
87}
diff --git a/framework/qmldir b/framework/qmldir
index a0f58385..fe96835e 100644
--- a/framework/qmldir
+++ b/framework/qmldir
@@ -29,6 +29,7 @@ TextEditor 1.0 TextEditor.qml
29ToolTip 1.0 ToolTip.qml 29ToolTip 1.0 ToolTip.qml
30Label 1.0 Label.qml 30Label 1.0 Label.qml
31SelectableLabel 1.0 SelectableLabel.qml 31SelectableLabel 1.0 SelectableLabel.qml
32SelectableItem 1.0 SelectableItem.qml
32Heading 1.0 Heading.qml 33Heading 1.0 Heading.qml
33View 1.0 View.qml 34View 1.0 View.qml
34AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml 35AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml