Debian Codegraph @

app/qml/Settings/ComboBoxQQ1.qml

raw
1 /*
2 * Copyright (C) 2016 Canonical Ltd
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 version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored-by: Florian Boucault <[email protected]>
17 */
18 import QtQuick 2.4
19 import Lomiri.Components 1.3
20 import QtQuick.Controls 1.4 as QtQuickControls
21 import QtQuick.Controls.Styles 1.4
22
23 QtQuickControls.ComboBox {
24 id: comboBox
25
26 style: ComboBoxStyle {
27 id: comboBoxStyle
28
29 padding {
30 top: 0
31 left: units.gu(2)
32 right: units.gu(5)
33 bottom: 0
34 }
35
36 background: Rectangle {
37 implicitWidth: units.gu(27)
38 implicitHeight: units.gu(4)
39
40 color: theme.palette.normal.field
41 border.color: theme.palette.normal.base
42 border.width: units.dp(1)
43 radius: units.dp(3)
44
45 Icon {
46 anchors {
47 right: parent.right
48 rightMargin: units.gu(2)
49 verticalCenter: parent.verticalCenter
50 verticalCenterOffset: -units.gu(0.5)
51 }
52
53 width: units.gu(1)
54 height: units.gu(1)
55 asynchronous: true
56 name: "up"
57 }
58
59 Icon {
60 anchors {
61 right: parent.right
62 rightMargin: units.gu(2)
63 verticalCenter: parent.verticalCenter
64 verticalCenterOffset: units.gu(0.5)
65 }
66
67 width: units.gu(1)
68 height: units.gu(1)
69 asynchronous: true
70 name: "down"
71 }
72 }
73 label: Label {
74 text: control.currentText
75 elide: Text.ElideRight
76 verticalAlignment: Text.AlignVCenter
77 color: comboBoxStyle.textColor
78 }
79
80 selectionColor: theme.palette.selected.overlay
81 textColor: theme.palette.normal.overlayText
82 selectedTextColor: theme.palette.selected.overlayText
83
84 __dropDownStyle: MenuStyle {
85 id: menuStyle
86
87 font: comboBoxStyle.font
88 __labelColor: comboBoxStyle.textColor
89 __selectedLabelColor: comboBoxStyle.selectedTextColor
90 __maxPopupHeight: units.gu(30)
91 __backgroundColor: theme.palette.normal.overlay
92 __selectedBackgroundColor: comboBoxStyle.selectionColor
93
94 frame: Rectangle {
95 color: menuStyle.__backgroundColor
96 }
97
98 __leftLabelMargin: units.gu(2)
99 __rightLabelMargin: units.gu(2)
100 itemDelegate.label: Label {
101 width: units.gu(27) - menuStyle.__leftLabelMargin - menuStyle.__rightLabelMargin
102 height: units.gu(4)
103 text: formatMnemonic(styleData.text, styleData.underlineMnemonic)
104 elide: Text.ElideRight
105 verticalAlignment: Text.AlignVCenter
106 color: __currentTextColor
107 }
108 itemDelegate.checkmarkIndicator: Rectangle {
109 visible: styleData.checked
110 x: menuStyle.__leftLabelMargin / 2 - width / 2 + (__mirrored ? 4 : -4)
111 width: units.gu(0.5)
112 height: width
113 color: __labelColor
114 antialiasing: true
115 radius: width/2
116 }
117 itemDelegate.background: Rectangle {
118 visible: styleData.selected && styleData.enabled
119 color: __selectedBackgroundColor
120 border.width: units.dp(1)
121 border.color: Qt.darker(__selectedBackgroundColor, 1.02)
122 antialiasing: true
123 }
124 __scrollerStyle: ScrollViewStyle {
125 transientScrollBars: true
126 }
127 }
128 }
129 }