Skip to content

Commit f592706

Browse files
committed
PrefsComboBoxLabel added and someminor fix
1 parent 61a4372 commit f592706

File tree

2 files changed

+143
-5
lines changed

2 files changed

+143
-5
lines changed

Diff for: common/PrefsComboBox.qml

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import QtQuick.Controls 2.0
33
import QtQuick.Layouts 1.3
44
ComboBox {
55
id: root
6-
property color checkedColor: "#1ABC9C"
6+
property color checkedColor: "#dde4de"
77

88
delegate:ItemDelegate {
99
id:itemDelegate
10-
property string iconRectColor: iconColor
11-
property string iconRectIcon: iconName
10+
property string iconRectColor: iconColor ? iconColor : ""
11+
property string iconRectIcon: iconName ? iconName : ""
1212

1313
width: root.width * 1.4
1414
height: 40
@@ -133,7 +133,7 @@ ComboBox {
133133
font.weight: Font.Medium
134134
verticalAlignment: Image.AlignVCenter
135135
Layout.alignment: Qt.AlignVCenter
136-
color: "white"
136+
color: Qt.darkGray
137137
elide: Text.ElideRight
138138
Layout.leftMargin:iconRect.visible ? 0 : 10
139139
}
@@ -145,7 +145,7 @@ ComboBox {
145145
implicitWidth: 200
146146
implicitHeight: 41
147147
color: root.down ? Qt.darker(root.checkedColor, 1.2) : root.checkedColor
148-
radius: 5
148+
radius: 4
149149
}
150150

151151
popup: Popup {

Diff for: common/PrefsComboBoxLabel.qml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import QtQuick 2.9
2+
import QtQuick.Controls 2.0
3+
import QtQuick.Layouts 1.3
4+
ComboBox {
5+
id: root
6+
property color checkedColor: "#dde4de"
7+
8+
delegate:ItemDelegate {
9+
id:itemDelegate
10+
property string iconRectIcon: iconName ? iconName : ""
11+
12+
width: root.width * 1.4
13+
height: 40
14+
hoverEnabled: true
15+
focus: true
16+
17+
background: Rectangle{
18+
color: itemDelegate.hovered ? "blue" : "transparent"
19+
anchors.fill: parent
20+
radius: 8
21+
}
22+
23+
RowLayout {
24+
Layout.alignment: Qt.AlignVCenter
25+
width: parent.width
26+
height: parent.height
27+
anchors.fill: parent
28+
spacing: 10
29+
Layout.leftMargin: 10
30+
Layout.rightMargin: 10
31+
32+
Label {
33+
opacity: 0.87
34+
font.pointSize: 12
35+
text: name
36+
Layout.fillWidth: true
37+
font.weight: Font.Medium
38+
verticalAlignment: Image.AlignVCenter
39+
Layout.alignment: Qt.AlignVCenter
40+
color: itemDelegate.hovered ? "white" : Qt.darkGray
41+
Layout.leftMargin: 10
42+
}
43+
44+
Label {
45+
opacity: 0.87
46+
font.pointSize: 12
47+
text: ""
48+
visible: root.currentIndex == index
49+
Layout.fillWidth: true
50+
font.weight: Font.Medium
51+
verticalAlignment: Image.AlignVCenter
52+
horizontalAlignment: Image.AlignRight
53+
Layout.alignment: Qt.AlignVCenter
54+
Layout.rightMargin: 10
55+
}
56+
}
57+
58+
}
59+
60+
indicator: Canvas {
61+
id: canvas
62+
x: root.width - width - 10
63+
y: (root.availableHeight - height) / 2
64+
width: 12
65+
height: 8
66+
contextType: "2d"
67+
68+
Connections {
69+
target: root
70+
function onPressedChanged(){
71+
canvas.requestPaint()
72+
}
73+
}
74+
75+
onPaint: {
76+
context.reset();
77+
context.moveTo(0, 0);
78+
context.lineTo(width, 0);
79+
context.lineTo(width / 2, height);
80+
context.closePath();
81+
context.fillStyle = "white"
82+
context.fill();
83+
}
84+
}
85+
86+
contentItem: Item {
87+
width: root.background.width - root.indicator.width - 10
88+
height: root.background.height
89+
90+
RowLayout {
91+
anchors.fill: parent
92+
spacing: 10
93+
Label {
94+
opacity: 0.87
95+
font.pointSize: 12
96+
text: model.get(currentIndex).name
97+
Layout.fillWidth: true
98+
font.weight: Font.Medium
99+
verticalAlignment: Image.AlignVCenter
100+
Layout.alignment: Qt.AlignVCenter
101+
color: Qt.darkGray
102+
elide: Text.ElideRight
103+
Layout.leftMargin: 10
104+
}
105+
}
106+
107+
}
108+
109+
background: Rectangle {
110+
implicitWidth: 200
111+
implicitHeight: 41
112+
color: root.down ? Qt.darker(root.checkedColor, 1.2) : root.checkedColor
113+
radius: 4
114+
}
115+
116+
popup: Popup {
117+
y: root.height - 1
118+
width: root.width * 1.5
119+
implicitHeight: contentItem.implicitHeight > 250 ? 250 : contentItem.implicitHeight
120+
padding: 4
121+
contentItem: ListView {
122+
leftMargin: 5
123+
implicitHeight: contentHeight
124+
keyNavigationEnabled: true
125+
model: root.popup.visible ? root.delegateModel : null
126+
clip: true
127+
focus: true
128+
currentIndex: root.highlightedIndex
129+
}
130+
131+
background: Rectangle {
132+
anchors.fill: parent
133+
color: "#dde4de"
134+
radius: 4
135+
clip: true
136+
}
137+
}
138+
}

0 commit comments

Comments
 (0)