This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SortFilterItem.qml
120 lines (108 loc) · 3.69 KB
/
SortFilterItem.qml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3
CheckBox {
id: control
leftPadding: 0
rightPadding: 0
topPadding: 0
bottomPadding: 0
spacing: 0
tristate: true
autoExclusive: true
focusPolicy: Qt.NoFocus
property int innerPadding: 5
property bool filter: false
property bool sort: false
property alias filterText: filter.text
function clear() { filter.clear() }
contentItem: Rectangle {
color: 'transparent'
Label {
width: parent.width - control.indicator.width
height: parent.height
padding: control.innerPadding
text: control.text
verticalAlignment: Text.AlignVCenter
font: control.font
visible: !control.filter
}
TextInput {
id: filter
width: parent.width - control.indicator.width
height: parent.height
padding: control.innerPadding
verticalAlignment: Text.AlignVCenter
font: control.font
visible: control.filter
clip: true
activeFocusOnTab: true
selectByMouse: true
color: Material.foreground
selectionColor: Material.accent
selectedTextColor: 'white'
cursorDelegate: Rectangle {
width: 2
color: Material.accent
visible: parent.activeFocus && parent.selectedText == ""
SequentialAnimation on opacity {
running: parent.visible
loops: Animation.Infinite;
NumberAnimation { to: 1; duration: 500; easing.type: "InQuad"}
NumberAnimation { to: 0; duration: 500; easing.type: "OutQuad"}
}
}
Text {
anchors.fill: parent
padding: control.innerPadding
verticalAlignment: Text.AlignVCenter
font: control.font
color: Material.foreground
opacity: 0.35
visible: !parent.text
text: control.text
}
Rectangle {
anchors.bottom: parent.bottom
width: parent.width
height: parent.activeFocus ? 2 : 1
color: parent.activeFocus ? Material.accent : Material.foreground
opacity: parent.activeFocus ? 1 : 0.35
}
}
Component.onCompleted: {
textMetrics.text = control.text
implicitWidth = textMetrics.width + control.innerPadding * 2 + control.indicator.width
implicitHeight = textMetrics.height + control.innerPadding * 2
}
}
indicator: Rectangle {
implicitWidth: control.font.pixelSize + control.innerPadding
height: control.contentItem.height
x: control.width - width - control.spacing
y: control.height / 2 - height / 2
color: 'transparent'
visible: control.sort
Text {
anchors.fill: parent
text: (checkState == Qt.PartiallyChecked || checkState == Qt.Unchecked ) ? '' : ''
color: Material.foreground
opacity: checkState != Qt.Unchecked ? 1.0 : 0.35
font.pixelSize: control.font.pixelSize
font.family: faSolid.name
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
background: Rectangle {
anchors.fill: parent
visible: control.down
opacity: 0.3
color: Material.accent
}
TextMetrics {
id: textMetrics
font: control.font
}
}