diff options
author | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-07-26 21:27:27 +0200 |
---|---|---|
committer | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-07-26 21:27:27 +0200 |
commit | 001e863e345cedaa8c292c522de83cb87616360f (patch) | |
tree | 348cc4c83f08607e41ed9520a24c7e237a5f5e4b /framework/qml | |
parent | d3b07cd2025b0ee1ba76b8e92492f035ff447f33 (diff) | |
download | kube-001e863e345cedaa8c292c522de83cb87616360f.tar.gz kube-001e863e345cedaa8c292c522de83cb87616360f.zip |
use Kube.ListDelegate in Kube.ComboBox
Diffstat (limited to 'framework/qml')
-rw-r--r-- | framework/qml/ComboBox.qml | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/framework/qml/ComboBox.qml b/framework/qml/ComboBox.qml index a22ed73c..82416175 100644 --- a/framework/qml/ComboBox.qml +++ b/framework/qml/ComboBox.qml | |||
@@ -19,22 +19,22 @@ | |||
19 | import QtQuick 2.7 | 19 | import QtQuick 2.7 |
20 | import QtQuick.Controls 2.0 | 20 | import QtQuick.Controls 2.0 |
21 | import QtQuick.Templates 2.0 as T | 21 | import QtQuick.Templates 2.0 as T |
22 | import org.kube.framework 1.0 | 22 | import org.kube.framework 1.0 as Kube |
23 | 23 | ||
24 | T.ComboBox { | 24 | T.ComboBox { |
25 | id: root | 25 | id: root |
26 | 26 | ||
27 | implicitWidth: Units.gridUnit * 10 | 27 | implicitWidth: Kube.Units.gridUnit * 10 |
28 | implicitHeight: Units.gridUnit + Units.smallSpacing * 2 | 28 | implicitHeight: Kube.Units.gridUnit + Kube.Units.smallSpacing * 2 |
29 | 29 | ||
30 | baselineOffset: contentItem.y + contentItem.baselineOffset | 30 | baselineOffset: contentItem.y + contentItem.baselineOffset |
31 | 31 | ||
32 | spacing: Units.largeSpacing | 32 | spacing: Kube.Units.largeSpacing |
33 | padding: Units.smallSpacing | 33 | padding: Kube.Units.smallSpacing |
34 | 34 | ||
35 | contentItem: Label { | 35 | contentItem: Kube.Label { |
36 | leftPadding: Units.smallSpacing | 36 | leftPadding: Kube.Units.smallSpacing |
37 | rightPadding: Units.largeSpacing | 37 | rightPadding: Kube.Units.largeSpacing |
38 | 38 | ||
39 | text: root.displayText | 39 | text: root.displayText |
40 | horizontalAlignment: Text.AlignLeft | 40 | horizontalAlignment: Text.AlignLeft |
@@ -42,23 +42,23 @@ T.ComboBox { | |||
42 | elide: Text.ElideRight | 42 | elide: Text.ElideRight |
43 | } | 43 | } |
44 | 44 | ||
45 | indicator: Icon { | 45 | indicator: Kube.Icon { |
46 | x: root.mirrored ? root.leftPadding : root.width - width - root.rightPadding | 46 | x: root.mirrored ? root.leftPadding : root.width - width - root.rightPadding |
47 | y: root.topPadding + (root.availableHeight - height) / 2 | 47 | y: root.topPadding + (root.availableHeight - height) / 2 |
48 | iconName: Icons.goDown | 48 | iconName: Kube.Icons.goDown |
49 | } | 49 | } |
50 | 50 | ||
51 | background: Rectangle { | 51 | background: Rectangle { |
52 | border.width: 1 | 52 | border.width: 1 |
53 | border.color: root.activeFocus ? Colors.highlightColor : Colors.buttonColor | 53 | border.color: root.activeFocus ? Kube.Colors.highlightColor : Kube.Colors.buttonColor |
54 | color: Colors.viewBackgroundColor | 54 | color: Kube.Colors.viewBackgroundColor |
55 | } | 55 | } |
56 | 56 | ||
57 | popup: T.Popup { | 57 | popup: T.Popup { |
58 | width: root.width | 58 | width: root.width |
59 | implicitHeight: Math.min(Units.gridUnit * 5, contentItem.implicitHeight) | 59 | implicitHeight: Math.min(Kube.Units.gridUnit * 5, contentItem.implicitHeight) |
60 | 60 | ||
61 | contentItem: ListView { | 61 | contentItem: Kube.ListView { |
62 | clip: true | 62 | clip: true |
63 | implicitHeight: contentHeight | 63 | implicitHeight: contentHeight |
64 | model: root.popup.visible ? root.delegateModel : null | 64 | model: root.popup.visible ? root.delegateModel : null |
@@ -68,26 +68,20 @@ T.ComboBox { | |||
68 | } | 68 | } |
69 | 69 | ||
70 | background: Rectangle { | 70 | background: Rectangle { |
71 | color: Colors.backgroundColor | 71 | color: Kube.Colors.backgroundColor |
72 | border.color: Colors.buttonColor | 72 | border.color: Kube.Colors.buttonColor |
73 | border.width: 1 | 73 | border.width: 1 |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | delegate: T.ItemDelegate { | 77 | delegate: Kube.ListDelegate { |
78 | width: root.popup.width | 78 | width: root.popup.width |
79 | height: Units.gridUnit * 1.5 | 79 | height: Kube.Units.gridUnit * 1.5 |
80 | 80 | ||
81 | contentItem: Label { | 81 | contentItem: Kube.Label { |
82 | padding: Units.smallSpacing | 82 | padding: Kube.Units.smallSpacing |
83 | text: root.textRole ? (Array.isArray(root.model) ? modelData[root.textRole] : model[root.textRole]) : modelData | 83 | text: root.textRole ? (Array.isArray(root.model) ? modelData[root.textRole] : model[root.textRole]) : modelData |
84 | color: root.highlightedIndex === index ? Colors.highlightedTextColor : Colors.textColor | 84 | color: root.highlightedIndex === index ? Kube.Colors.highlightedTextColor : Kube.Colors.textColor |
85 | } | ||
86 | |||
87 | background: Rectangle { | ||
88 | color: root.highlightedIndex === index ? Colors.highlightColor : Colors.viewBackgroundColor | ||
89 | border.width: 1 | ||
90 | border.color: Colors.buttonColor | ||
91 | } | 85 | } |
92 | } | 86 | } |
93 | } | 87 | } |