summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bohlender <michael.bohlender@kdemail.net>2017-04-07 11:57:19 +0200
committerMichael Bohlender <michael.bohlender@kdemail.net>2017-04-07 11:57:19 +0200
commit1d94783dfc45f4d215ba59ddbb3f4392b004cbae (patch)
tree3f8436e1a74d80f17a0f5be279d2c8974ec25547
parentede077f0b908464f820fc476c76f09599790e5a5 (diff)
downloadkube-1d94783dfc45f4d215ba59ddbb3f4392b004cbae.tar.gz
kube-1d94783dfc45f4d215ba59ddbb3f4392b004cbae.zip
add initial Kube.ComboBox and use it in composer
-rw-r--r--framework/qml/ComboBox.qml95
-rw-r--r--framework/qml/FocusComposer.qml2
-rw-r--r--framework/qmldir1
3 files changed, 97 insertions, 1 deletions
diff --git a/framework/qml/ComboBox.qml b/framework/qml/ComboBox.qml
new file mode 100644
index 00000000..9fea0ca3
--- /dev/null
+++ b/framework/qml/ComboBox.qml
@@ -0,0 +1,95 @@
1/*
2 * Copyright (C) 2017 Michael Bohlender, <bohlender@kolabsys.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19import QtQuick 2.7
20import QtQuick.Controls 2.0
21import QtQuick.Templates 2.0 as T
22import org.kube.framework 1.0
23
24T.ComboBox {
25 id: root
26
27 implicitWidth: Units.gridUnit * 10
28 implicitHeight: Units.gridUnit + Units.smallSpacing * 2
29
30 baselineOffset: contentItem.y + contentItem.baselineOffset
31
32 spacing: Units.largeSpacing
33 padding: Units.smallSpacing
34
35 contentItem: Text {
36 leftPadding: Units.smallSpacing
37 rightPadding: Units.largeSpacing
38
39 color: Colors.textColor
40 text: root.displayText
41 //TODO font:
42 horizontalAlignment: Text.AlignLeft
43 verticalAlignment: Text.AlignVCenter
44 elide: Text.ElideRight
45 }
46
47 indicator: Icon {
48 x: root.mirrored ? root.leftPadding : root.width - width - root.rightPadding
49 y: root.topPadding + (root.availableHeight - height) / 2
50 iconName: Icons.goDown
51 }
52
53 background: Rectangle {
54 border.width: 1
55 border.color: Colors.buttonColor
56 color: Colors.viewBackgroundColor
57 }
58
59 popup: T.Popup {
60 width: root.width
61 implicitHeight: Math.min(Units.gridUnit * 5, contentItem.implicitHeight)
62
63 contentItem: ListView {
64 clip: true
65 implicitHeight: contentHeight
66 model: root.popup.visible ? root.delegateModel : null
67 currentIndex: root.highlightedIndex
68 //FIXME use Kube.Scrollbar once available
69 T.ScrollIndicator.vertical: ScrollIndicator { }
70 }
71
72 background: Rectangle {
73 color: Colors.backgroundColor
74 border.color: Colors.buttonColor
75 border.width: 1
76 }
77 }
78
79 delegate: T.ItemDelegate {
80 width: root.popup.width
81 height: Units.gridUnit * 1.5
82
83 contentItem: Text {
84 padding: Units.smallSpacing
85 text: root.textRole ? (Array.isArray(root.model) ? modelData[root.textRole] : model[root.textRole]) : modelData
86 color: root.highlightedIndex === index ? Colors.highlightedTextColor : Colors.textColor
87 }
88
89 background: Rectangle {
90 color: root.highlightedIndex === index ? Colors.highlightColor : Colors.viewBackgroundColor
91 border.width: 1
92 border.color: Colors.buttonColor
93 }
94 }
95}
diff --git a/framework/qml/FocusComposer.qml b/framework/qml/FocusComposer.qml
index 08eafe36..bd5612f1 100644
--- a/framework/qml/FocusComposer.qml
+++ b/framework/qml/FocusComposer.qml
@@ -146,7 +146,7 @@ Kube.Popup {
146 146
147 RowLayout { 147 RowLayout {
148 148
149 Controls2.ComboBox { 149 Kube.ComboBox {
150 id: identityCombo 150 id: identityCombo
151 model: composerController.identitySelector.model 151 model: composerController.identitySelector.model
152 textRole: "displayName" 152 textRole: "displayName"
diff --git a/framework/qmldir b/framework/qmldir
index 1ca1cb72..7b1f0be6 100644
--- a/framework/qmldir
+++ b/framework/qmldir
@@ -15,6 +15,7 @@ NotificationPopup 1.0 NotificationPopup.qml
15Icon 1.0 Icon.qml 15Icon 1.0 Icon.qml
16Button 1.0 Button.qml 16Button 1.0 Button.qml
17Popup 1.0 Popup.qml 17Popup 1.0 Popup.qml
18ComboBox 1.0 ComboBox.qml
18PositiveButton 1.0 PositiveButton.qml 19PositiveButton 1.0 PositiveButton.qml
19singleton Colors 1.0 Colors.qml 20singleton Colors 1.0 Colors.qml
20singleton Icons 1.0 Icons.qml 21singleton Icons 1.0 Icons.qml