blob: 42a200a9368a41cb5d4a6d8b7c775a25220e5709 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
Item {
id: selector
property alias list: view.model
property alias selectedIndex: view.currentIndex
property alias label: labelText.text
property bool expanded
width: 100; height: labelText.implicitHeight + 26
Rectangle {
anchors { left: parent.left; right: parent.right; bottom: parent.bottom; }
height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20)
Behavior on height { NumberAnimation { duration: 300 } }
radius: 2
border.width: 1
border.color: "yellow"
color: "yellow"
MouseArea {
anchors.fill: parent
onClicked: selector.expanded = !selector.expanded
Text {
id: labelText
anchors { left: parent.left; top: parent.top; margins: 2 }
}
Rectangle {
anchors {
left: parent.left; top: labelText.bottom;
right: parent.right; bottom: parent.bottom;
margins: 2
leftMargin: 10
}
radius: 2
color: "white"
ListView {
id: view
anchors.fill: parent
clip: true
delegate: Text {
anchors { left: parent.left; right: parent.right }
height: 20
verticalAlignment: Text.AlignVCenter
text: modelData
MouseArea {
anchors.fill: parent
onClicked: {
view.currentIndex = index
selector.expanded = !selector.expanded
}
}
}
highlight: Rectangle {
anchors { left: parent.left; right: parent.right }
height: 20
radius: 2
color: "yellow"
}
}
}
}
}
}
|