blob: c9e78c06a91da07fcb50fb0b610d8552f5a443a2 (
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
|
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import QtQuick
import "../.."
// One mode: a label, a line saying what it does, and a switch.
Item {
id: row
required property string mode
required property string label
required property string description
required property bool value
implicitHeight: Math.max(texts.implicitHeight, sw.implicitHeight) + 16
Column {
id: texts
anchors {
left: parent.left
right: sw.left; rightMargin: 12
verticalCenter: parent.verticalCenter
}
spacing: 2
Text {
text: row.label
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true }
color: Theme.text
}
Text {
width: parent.width
wrapMode: Text.WordWrap
text: row.description
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
color: Theme.subtext
}
}
Switch {
id: sw
anchors { right: parent.right; verticalCenter: parent.verticalCenter }
checked: row.value
onToggled: Status.toggleMode(row.mode)
}
// The shared Switch's click handler writes `checked` directly, which drops
// the declarative binding above. Resync on any value change so an external
// write (statusctl, waybar) moves the switch back into agreement.
onValueChanged: sw.checked = row.value
}
|