Repository navigation
Expand file tree
/
Copy pathCheckbox.qml
More file actions
160 lines (135 loc) · 3.94 KB
/
Copy pathCheckbox.qml
File metadata and controls
160 lines (135 loc) · 3.94 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls.Universal 2.12
CheckBox {
id: settingsCheckbox
property double labelFontSize
property double circleSize
property var actionId
property bool activeCheckbox: false
property bool hasRemoveButton: false
property bool hasDescriptionButton: false
property bool isToggle: false
property int startX: 0
property var accentColor
width: parent.width
text: qsTr("Chip")
spacing: leftPadding / 2
opacity: 0.0
contentItem: Text {
text: settingsCheckbox.text
elide: Text.ElideRight
width: parent.width - leftPadding * 2 - removeButton.width
leftPadding: settingsCheckbox.indicator.width + settingsCheckbox.spacing
font.pointSize: labelFontSize
font.weight: Font.Normal
color: Universal.foreground
opacity: settingsCheckbox.checked ? 1.0 : 0.7
verticalAlignment: Text.AlignVCenter
}
FontLoader {
source: "qrc:/fonts/Poppins-Regular.ttf"
}
FontLoader {
source: "qrc:/fonts/Poppins-Bold.ttf"
}
FontLoader {
source: "qrc:/fonts/Poppins-Italic.ttf"
}
FontLoader {
source: "qrc:/fonts/selawk.ttf"
}
FontLoader {
source: "qrc:/fonts/selawkb.ttf"
}
FontLoader {
source: "qrc:/fonts/Lato-Regular.ttf"
}
FontLoader {
source: "qrc:/fonts/Lato-Bold.ttf"
}
FontLoader {
source: "qrc:/fonts/Lato-Italic.ttf"
}
FontLoader {
source: "qrc:/fonts/Rubik-Regular.ttf"
}
FontLoader {
source: "qrc:/fonts/Rubik-Bold.ttf"
}
FontLoader {
source: "qrc:/fonts/Rubik-Italic.ttf"
}
FontLoader {
source: "qrc:/fonts/IBMPlexSans-Regular.ttf"
}
FontLoader {
source: "qrc:/fonts/IBMPlexSans-Bold.ttf"
}
FontLoader {
source: "qrc:/fonts/IBMPlexSans-Italic.ttf"
}
Button {
id: removeButton
anchors.right: parent.right
rightPadding: settingsCheckbox.leftPadding
leftPadding: settingsCheckbox.leftPadding
flat: true
text: "<font color='#808080'>×</font>"
font.pointSize: labelFontSize
onClicked: {
console.log("Checkbox | Remove item from settings: " + settingsCheckbox.text)
settingsCheckbox.parent.removeSettings(actionId)
}
visible: settingsCheckbox.hasRemoveButton
}
Button {
id: descriptionButton
anchors.right: parent.right
rightPadding: settingsCheckbox.leftPadding
leftPadding: settingsCheckbox.leftPadding
flat: true
text: "<font color='#808080'>ⓘ</font>"
font.pointSize: labelFontSize
onClicked: {
console.log("Checkbox | Show description: " + settingsCheckbox.text)
settingsCheckbox.parent.showDescription(actionId)
}
visible: settingsCheckbox.hasDescriptionButton
}
indicator: Rectangle {
width: circleSize
height: circleSize
x: settingsCheckbox.leftPadding
y: settingsCheckbox.height / 2 - circleSize / 2
radius: width / 2
color: settingsCheckbox.checked ? accentColor : Universal.foreground
opacity: settingsCheckbox.checked ? 1.0 : 0.3
}
onVisibleChanged: {
if (!visible) {
console.log("Checkbox | Force visibility")
visible = true
}
}
onCheckedChanged: {
console.log("Checkbox | Checked changed for " + text + ", " + checked)
if (activeCheckbox) {
if (isToggle && !checked) {
activeCheckbox = false
checked = true
} else {
parent.updateSettings(actionId, checked)
}
}
}
Component.onCompleted: {
opacity = 1.0
}
Behavior on opacity {
NumberAnimation {
duration: 250
}
}
}