Changeset View
Changeset View
Standalone View
Standalone View
org.kde.desktop/ComboBox.qml
Show All 20 Lines | |||||
21 | 21 | | |||
22 | 22 | | |||
23 | import QtQuick 2.6 | 23 | import QtQuick 2.6 | ||
24 | import QtQuick.Window 2.2 | 24 | import QtQuick.Window 2.2 | ||
25 | import QtQuick.Templates 2.0 as T | 25 | import QtQuick.Templates 2.0 as T | ||
26 | import QtQuick.Controls 2.0 as Controls | 26 | import QtQuick.Controls 2.0 as Controls | ||
27 | import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate | 27 | import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate | ||
28 | import QtGraphicalEffects 1.0 | 28 | import QtGraphicalEffects 1.0 | ||
29 | import org.kde.kirigami 2.2 as Kirigami | ||||
29 | 30 | | |||
30 | T.ComboBox { | 31 | T.ComboBox { | ||
31 | id: controlRoot | 32 | id: controlRoot | ||
33 | Kirigami.Theme.colorSet: Kirigami.Theme.Button | ||||
34 | Kirigami.Theme.inherit: false | ||||
32 | 35 | | |||
33 | implicitWidth: background.implicitWidth + leftPadding + rightPadding | 36 | implicitWidth: background.implicitWidth + leftPadding + rightPadding | ||
34 | implicitHeight: background.implicitHeight | 37 | implicitHeight: background.implicitHeight | ||
35 | baselineOffset: contentItem.y + contentItem.baselineOffset | 38 | baselineOffset: contentItem.y + contentItem.baselineOffset | ||
36 | 39 | | |||
37 | hoverEnabled: true | 40 | hoverEnabled: true | ||
38 | padding: 5 | 41 | padding: 5 | ||
39 | leftPadding: padding + 5 | 42 | leftPadding: padding + 5 | ||
40 | rightPadding: padding + 5 | 43 | rightPadding: padding + 5 | ||
41 | 44 | | |||
42 | delegate: ItemDelegate { | 45 | delegate: ItemDelegate { | ||
43 | width: controlRoot.popup.width | 46 | width: controlRoot.popup.width | ||
44 | text: controlRoot.textRole ? (Array.isArray(controlRoot.model) ? modelData[controlRoot.textRole] : model[controlRoot.textRole]) : modelData | 47 | text: controlRoot.textRole ? (Array.isArray(controlRoot.model) ? modelData[controlRoot.textRole] : model[controlRoot.textRole]) : modelData | ||
45 | highlighted: controlRoot.highlightedIndex == index | 48 | highlighted: controlRoot.highlightedIndex == index | ||
46 | property bool separatorVisible: false | 49 | property bool separatorVisible: false | ||
50 | Kirigami.Theme.colorSet: controlRoot.Kirigami.Theme.inherit ? controlRoot.Kirigami.Theme.colorSet : Kirigami.Theme.View | ||||
51 | Kirigami.Theme.inherit: controlRoot.Kirigami.Theme.inherit | ||||
47 | } | 52 | } | ||
48 | 53 | | |||
49 | indicator: Item {} | 54 | indicator: Item {} | ||
50 | 55 | | |||
51 | contentItem: MouseArea { | 56 | contentItem: MouseArea { | ||
52 | onPressed: mouse.accepted = false; | 57 | onPressed: mouse.accepted = false; | ||
53 | onWheel: { | 58 | onWheel: { | ||
54 | if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) { | 59 | if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) { | ||
Show All 16 Lines | |||||
71 | } | 76 | } | ||
72 | 77 | | |||
73 | popup: T.Popup { | 78 | popup: T.Popup { | ||
74 | y: controlRoot.height | 79 | y: controlRoot.height | ||
75 | width: Math.max(controlRoot.width, 150) | 80 | width: Math.max(controlRoot.width, 150) | ||
76 | implicitHeight: contentItem.implicitHeight | 81 | implicitHeight: contentItem.implicitHeight | ||
77 | topMargin: 6 | 82 | topMargin: 6 | ||
78 | bottomMargin: 6 | 83 | bottomMargin: 6 | ||
84 | Kirigami.Theme.colorSet: Kirigami.Theme.View | ||||
85 | Kirigami.Theme.inherit: controlRoot.Kirigami.Theme.inherit | ||||
79 | 86 | | |||
80 | contentItem: ListView { | 87 | contentItem: ListView { | ||
81 | id: listview | 88 | id: listview | ||
82 | clip: true | 89 | clip: true | ||
83 | implicitHeight: contentHeight | 90 | implicitHeight: contentHeight | ||
84 | model: controlRoot.popup.visible ? controlRoot.delegateModel : null | 91 | model: controlRoot.popup.visible ? controlRoot.delegateModel : null | ||
85 | currentIndex: controlRoot.highlightedIndex | 92 | currentIndex: controlRoot.highlightedIndex | ||
86 | highlightRangeMode: ListView.ApplyRange | 93 | highlightRangeMode: ListView.ApplyRange | ||
87 | highlightMoveDuration: 0 | 94 | highlightMoveDuration: 0 | ||
88 | T.ScrollBar.vertical: Controls.ScrollBar { } | 95 | T.ScrollBar.vertical: Controls.ScrollBar { } | ||
89 | } | 96 | } | ||
90 | background: Rectangle { | 97 | background: Rectangle { | ||
91 | anchors { | 98 | anchors { | ||
92 | fill: parent | 99 | fill: parent | ||
93 | margins: -1 | 100 | margins: -1 | ||
94 | } | 101 | } | ||
95 | radius: 2 | 102 | radius: 2 | ||
96 | color: StylePrivate.SystemPaletteSingleton.base(controlRoot.enabled) | 103 | color: Kirigami.Theme.backgroundColor | ||
97 | property color borderColor: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) | 104 | property color borderColor: Kirigami.Theme.textColor | ||
98 | border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) | 105 | border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) | ||
99 | layer.enabled: true | 106 | layer.enabled: true | ||
100 | 107 | | |||
101 | layer.effect: DropShadow { | 108 | layer.effect: DropShadow { | ||
102 | transparentBorder: true | 109 | transparentBorder: true | ||
103 | radius: 4 | 110 | radius: 4 | ||
104 | samples: 8 | 111 | samples: 8 | ||
105 | horizontalOffset: 2 | 112 | horizontalOffset: 2 | ||
106 | verticalOffset: 2 | 113 | verticalOffset: 2 | ||
107 | color: Qt.rgba(0, 0, 0, 0.3) | 114 | color: Qt.rgba(0, 0, 0, 0.3) | ||
108 | } | 115 | } | ||
109 | } | 116 | } | ||
110 | } | 117 | } | ||
111 | } | 118 | } |