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
161
162
163
|
pragma ComponentBehavior: Bound
import QtQuick
import qs.Common
import qs.Widgets
import qs.Modules.Settings.Widgets
Column {
id: root
property string instanceId: ""
property var instanceData: null
readonly property var cfg: instanceData?.config ?? {}
function updateConfig(key, value) {
if (!instanceId)
return;
var updates = {};
updates[key] = value;
SettingsData.updateDesktopWidgetInstanceConfig(instanceId, updates);
}
width: parent?.width ?? 400
spacing: 0
SettingsDropdownRow {
text: I18n.tr("Clock Style")
options: [I18n.tr("Digital"), I18n.tr("Analog"), I18n.tr("Stacked")]
currentValue: {
switch (cfg.style) {
case "analog":
return I18n.tr("Analog");
case "stacked":
return I18n.tr("Stacked");
default:
return I18n.tr("Digital");
}
}
onValueChanged: value => {
switch (value) {
case I18n.tr("Analog"):
root.updateConfig("style", "analog");
return;
case I18n.tr("Stacked"):
root.updateConfig("style", "stacked");
return;
default:
root.updateConfig("style", "digital");
}
}
}
SettingsDivider {
visible: cfg.style === "analog"
}
SettingsToggleRow {
visible: cfg.style === "analog"
text: I18n.tr("Show Hour Numbers")
checked: cfg.showAnalogNumbers ?? false
onToggled: checked => root.updateConfig("showAnalogNumbers", checked)
}
SettingsDivider {
visible: cfg.style === "analog"
}
SettingsToggleRow {
visible: cfg.style === "analog"
text: I18n.tr("Show Seconds")
checked: cfg.showAnalogSeconds ?? true
onToggled: checked => root.updateConfig("showAnalogSeconds", checked)
}
SettingsDivider {
visible: cfg.style === "digital" || cfg.style === "stacked"
}
SettingsToggleRow {
visible: cfg.style === "digital" || cfg.style === "stacked"
text: I18n.tr("Show Seconds")
checked: cfg.showDigitalSeconds ?? false
onToggled: checked => root.updateConfig("showDigitalSeconds", checked)
}
SettingsDivider {}
SettingsToggleRow {
text: I18n.tr("Show Date")
checked: cfg.showDate ?? true
onToggled: checked => root.updateConfig("showDate", checked)
}
SettingsDivider {}
SettingsSliderRow {
text: I18n.tr("Transparency")
minimum: 0
maximum: 100
value: Math.round((cfg.transparency ?? 0.8) * 100)
unit: "%"
onSliderValueChanged: newValue => root.updateConfig("transparency", newValue / 100)
}
SettingsDivider {}
SettingsColorPicker {
colorMode: cfg.colorMode ?? "primary"
customColor: cfg.customColor ?? "#ffffff"
onColorModeSelected: mode => root.updateConfig("colorMode", mode)
onCustomColorSelected: selectedColor => root.updateConfig("customColor", selectedColor.toString())
}
SettingsDivider {}
SettingsDisplayPicker {
displayPreferences: cfg.displayPreferences ?? ["all"]
onPreferencesChanged: prefs => root.updateConfig("displayPreferences", prefs)
}
SettingsDivider {}
Item {
width: parent.width
height: resetRow.height + Theme.spacingM * 2
Row {
id: resetRow
x: Theme.spacingM
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingM
DankButton {
text: I18n.tr("Reset Position")
backgroundColor: Theme.surfaceHover
textColor: Theme.surfaceText
buttonHeight: 36
onClicked: {
if (!root.instanceId)
return;
SettingsData.updateDesktopWidgetInstance(root.instanceId, {
positions: {}
});
}
}
DankButton {
text: I18n.tr("Reset Size")
backgroundColor: Theme.surfaceHover
textColor: Theme.surfaceText
buttonHeight: 36
onClicked: {
if (!root.instanceId)
return;
SettingsData.updateDesktopWidgetInstance(root.instanceId, {
positions: {}
});
}
}
}
}
}
|