11import "." as Skin
22import QtQuick 2.12
33import QtQuick.Controls 2.12
4+ import QtQuick.Shapes
5+ import Qt5Compat.GraphicalEffects
46import "Theme"
57
68ComboBox {
79 id: root
810
911 property alias popupWidth: popup .width
1012 property bool clip: false
13+ property int popupMaxItem: 3
1114
1215 background: Skin .EmbeddedBackground {
1316 }
@@ -17,28 +20,31 @@ ComboBox {
1720
1821 required property int index
1922
20- width: parent .width
2123 highlighted: root .highlightedIndex === this .index
2224 text: root .textAt (this .index )
25+ padding: 4
26+ verticalPadding: 8
2327
2428 contentItem: Text {
2529 text: itemDlgt .text
30+ font: root .font
2631 color: Theme .deckTextColor
2732 elide: Text .ElideRight
2833 verticalAlignment: Text .AlignVCenter
2934 }
3035
3136 background: Rectangle {
3237 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 "
3540 color: " transparent"
3641 }
3742 }
3843
44+ indicator .width : 20
45+
3946 contentItem: Text {
4047 leftPadding: 5
41- rightPadding: root .indicator .width + root .spacing
4248 text: root .displayText
4349 font: root .font
4450 color: Theme .deckTextColor
@@ -49,21 +55,71 @@ ComboBox {
4955
5056 popup: Popup {
5157 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
5598
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
61103
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
63120 }
64121 }
65122
66- background: Skin .EmbeddedBackground {
67- }
123+ background: Item {}
68124 }
69125}
0 commit comments