diff options
Diffstat (limited to 'framework/qml/SelectableItem.qml')
-rw-r--r-- | framework/qml/SelectableItem.qml | 87 |
1 files changed, 87 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 | |||
20 | import QtQuick 2.7 | ||
21 | import QtQuick.Controls 2.2 | ||
22 | import org.kube.framework 1.0 as Kube | ||
23 | import QtQuick.Layouts 1.3 | ||
24 | |||
25 | // QtObject { | ||
26 | Item { | ||
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 | } | ||