1
1
import "." as Skin
2
2
import QtQuick 2.12
3
3
import QtQuick.Controls 2.12
4
+ import QtQuick.Shapes
5
+ import Qt5Compat.GraphicalEffects
4
6
import "Theme"
5
7
6
8
ComboBox {
7
9
id: root
8
10
9
11
property alias popupWidth: popup .width
10
12
property bool clip: false
13
+ property int popupMaxItem: 3
11
14
12
15
background: Skin .EmbeddedBackground {
13
16
}
@@ -17,28 +20,31 @@ ComboBox {
17
20
18
21
required property int index
19
22
20
- width: parent .width
21
23
highlighted: root .highlightedIndex === this .index
22
24
text: root .textAt (this .index )
25
+ padding: 4
26
+ verticalPadding: 8
23
27
24
28
contentItem: Text {
25
29
text: itemDlgt .text
30
+ font: root .font
26
31
color: Theme .deckTextColor
27
32
elide: Text .ElideRight
28
33
verticalAlignment: Text .AlignVCenter
29
34
}
30
35
31
36
background: Rectangle {
32
37
radius: 5
33
- border .width : itemDlgt . highlighted ? 1 : 0
34
- border .color : Theme .deckLineColor
38
+ border .width : 1
39
+ border .color : itemDlgt . highlighted ? Theme .deckLineColor : " transparent "
35
40
color: " transparent"
36
41
}
37
42
}
38
43
44
+ indicator .width : 20
45
+
39
46
contentItem: Text {
40
47
leftPadding: 5
41
- rightPadding: root .indicator .width + root .spacing
42
48
text: root .displayText
43
49
font: root .font
44
50
color: Theme .deckTextColor
@@ -49,21 +55,71 @@ ComboBox {
49
55
50
56
popup: Popup {
51
57
id: popup
52
- y: root .height
53
- width: root .width
54
- implicitHeight: contentItem .implicitHeight
58
+ y: root .height / 2
59
+ width: root .width - root .indicator .width / 2
60
+ x: root .indicator .width / 2
61
+ height: root .indicator .implicitHeight * Math .min (root .popupMaxItem , root .count ) + root .indicator .width
62
+
63
+ padding: 0
64
+
65
+ contentItem: Item {
66
+ Item {
67
+ id: content
68
+ anchors .fill : parent
69
+ Shape {
70
+ id: arrow
71
+ anchors .top : parent .top
72
+ anchors .right : parent .right
73
+ anchors .rightMargin : 3
74
+ width: root .indicator .width - 4
75
+ height: width
76
+ antialiasing: true
77
+ layer .enabled : true
78
+ layer .samples : 4
79
+ ShapePath {
80
+ fillColor: Theme .embeddedBackgroundColor
81
+ strokeColor: Theme .deckBackgroundColor
82
+ strokeWidth: 2
83
+ startX: arrow .width / 2 ; startY: 0
84
+ fillRule: ShapePath .WindingFill
85
+ capStyle: ShapePath .RoundCap
86
+ PathLine { x: root .indicator .width ; y: root .indicator .width }
87
+ PathLine { x: 0 ; y: root .indicator .width }
88
+ PathLine { x: (root .indicator .width ) / 2 ; y: 0 }
89
+ }
90
+ }
91
+ Skin .EmbeddedBackground {
92
+ anchors .topMargin : root .indicator .width - 6
93
+ anchors .fill : parent
94
+ ListView {
95
+ clip: true
96
+
97
+ anchors .fill : parent
55
98
56
- contentItem: ListView {
57
- clip: true
58
- implicitHeight: contentHeight
59
- model: root .popup .visible ? root .delegateModel : null
60
- currentIndex: root .highlightedIndex
99
+ bottomMargin: 0
100
+ leftMargin: 0
101
+ rightMargin: 0
102
+ topMargin: 0
61
103
62
- ScrollIndicator .vertical : ScrollIndicator {
104
+ model: root .popup .visible ? root .delegateModel : null
105
+ currentIndex: root .highlightedIndex
106
+
107
+ ScrollBar .vertical : ScrollBar {
108
+ policy: ScrollBar .AlwaysOn
109
+ }
110
+ }
111
+ }
112
+ }
113
+ DropShadow {
114
+ anchors .fill : parent
115
+ horizontalOffset: 0
116
+ verticalOffset: 0
117
+ radius: 8.0
118
+ color: " #000000"
119
+ source: content
63
120
}
64
121
}
65
122
66
- background: Skin .EmbeddedBackground {
67
- }
123
+ background: Item {}
68
124
}
69
125
}
0 commit comments