Changeset View
Changeset View
Standalone View
Standalone View
kcms/nightcolor/package/contents/ui/main.qml
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 26 | KCM.SimpleKCM { | |||
---|---|---|---|---|---|
43 | } | 43 | } | ||
44 | 44 | | |||
45 | function calcNeedsSave() { | 45 | function calcNeedsSave() { | ||
46 | kcm.needsSave = cA.checkStaged(); | 46 | kcm.needsSave = cA.checkStaged(); | ||
47 | // If the user changes something manually again after | 47 | // If the user changes something manually again after | ||
48 | // Default was triggered, only allow a normal | 48 | // Default was triggered, only allow a normal | ||
49 | // configuration change again: | 49 | // configuration change again: | ||
50 | defaultRequested = false; | 50 | defaultRequested = false; | ||
51 | | ||||
52 | calcRepresentsDefault(); | ||||
53 | } | ||||
54 | function calcRepresentsDefault() { | ||||
55 | if (cA.nightColorAvailable) { | ||||
56 | kcm.representsDefaults = activator.checked === cA.activeDefault && | ||||
57 | tempSlider.value === cA.nightTemperatureDefault && | ||||
58 | modeSwitcher.currentIndex === cA.modeDefault && | ||||
59 | cA.latitudeFixedStaged === cA.latitudeFixedDefault && | ||||
60 | cA.longitudeFixedStaged === cA.longitudeFixedDefault && | ||||
61 | cA.morningBeginFixedStaged.toString() === cA.morningBeginFixedDefault.toString() && | ||||
62 | cA.eveningBeginFixedStaged.toString() === cA.eveningBeginFixedDefault.toString() && | ||||
63 | cA.transitionTimeStaged === cA.transitionTimeDefault; | ||||
64 | } else { | ||||
65 | kcm.representsDefaults = true; | ||||
romangg: What is this supposed to do? | |||||
meven: Disable the restore default button | |||||
66 | } | ||||
51 | } | 67 | } | ||
52 | 68 | | |||
53 | Connections { | 69 | Connections { | ||
54 | target: kcm | 70 | target: kcm | ||
55 | onLoadRelay: cA.reloadData() | 71 | onLoadRelay: cA.reloadData() | ||
56 | onSaveRelay: defaultRequested ? cA.sendConfigurationAll() : cA.sendConfiguration(); | 72 | onSaveRelay: { | ||
73 | defaultRequested ? cA.sendConfigurationAll() : cA.sendConfiguration(); | ||||
74 | } | ||||
57 | onDefaultsRelay: { | 75 | onDefaultsRelay: { | ||
58 | if (!cA.nightColorAvailable) { | 76 | if (!cA.nightColorAvailable) { | ||
59 | return; | 77 | return; | ||
60 | } | 78 | } | ||
61 | activator.checked = cA.activeDefault; | 79 | activator.checked = cA.activeDefault; | ||
62 | tempSlider.value = cA.nightTemperatureDefault; | 80 | tempSlider.value = cA.nightTemperatureDefault; | ||
63 | modeSwitcher.currentIndex = cA.modeDefault; | 81 | modeSwitcher.currentIndex = cA.modeDefault; | ||
64 | 82 | | |||
65 | // set everything else to default as well | 83 | // set everything else to default as well | ||
66 | cA.latitudeFixedStaged = cA.latitudeFixedDefault; | 84 | defaults() | ||
67 | cA.longitudeFixedStaged = cA.longitudeFixedDefault; | | |||
68 | 85 | | |||
69 | cA.morningBeginFixedStaged = cA.morningBeginFixedDefault; | 86 | mornBeginManField.backend = cA.morningBeginFixedDefault; | ||
70 | cA.eveningBeginFixedStaged = cA.eveningBeginFixedDefault; | 87 | evenBeginManField.backend = cA.eveningBeginFixedDefault; | ||
71 | cA.transitionTimeStaged = cA.transitionTimeDefault; | 88 | transTimeField.value = cA.transitionTimeDefault; | ||
davidedmundson: Please split. | |||||
89 | cA.transitionTimeStaged = transTimeField.value; | ||||
72 | 90 | | |||
73 | kcm.needsSave = cA.checkStagedAll(); | 91 | kcm.needsSave = cA.checkStagedAll(); | ||
74 | defaultRequested = true; | 92 | defaultRequested = true; | ||
93 | | ||||
94 | calcRepresentsDefault(); | ||||
75 | } | 95 | } | ||
76 | } | 96 | } | ||
97 | signal defaults() | ||||
77 | 98 | | |||
78 | Connections { | 99 | Connections { | ||
79 | target: cA | 100 | target: cA | ||
80 | onDataUpdated: calcNeedsSave() | 101 | onDataUpdated: calcNeedsSave() | ||
81 | onStagedDataReset: { | 102 | onStagedDataReset: { | ||
82 | activator.checked = cA.active; | 103 | activator.checked = cA.active; | ||
83 | tempSlider.value = cA.nightTemperature; | 104 | tempSlider.value = cA.nightTemperature; | ||
84 | modeSwitcher.currentIndex = cA.mode; | 105 | modeSwitcher.currentIndex = cA.mode; | ||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Line(s) | 137 | Kirigami.FormLayout { | |||
215 | // Show time entry fields in manual timings mode | 236 | // Show time entry fields in manual timings mode | ||
216 | TimeField { | 237 | TimeField { | ||
217 | id: evenBeginManField | 238 | id: evenBeginManField | ||
218 | // Match combobox width | 239 | // Match combobox width | ||
219 | Layout.minimumWidth: modeSwitcher.width | 240 | Layout.minimumWidth: modeSwitcher.width | ||
220 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings | 241 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings | ||
221 | Kirigami.FormData.label: i18n("Turn on at:") | 242 | Kirigami.FormData.label: i18n("Turn on at:") | ||
222 | backend: cA.eveningBeginFixedStaged | 243 | backend: cA.eveningBeginFixedStaged | ||
223 | onBackendChanged: {cA.eveningBeginFixedStaged = backend; | 244 | onBackendChanged: { | ||
245 | cA.eveningBeginFixedStaged = backend; | ||||
224 | calcNeedsSave(); | 246 | calcNeedsSave(); | ||
225 | } | 247 | } | ||
226 | 248 | | |||
227 | QQC2.ToolTip { | 249 | QQC2.ToolTip { | ||
228 | text: i18n("Input format: HH:MM") | 250 | text: i18n("Input format: HH:MM") | ||
229 | } | 251 | } | ||
230 | } | 252 | } | ||
231 | 253 | | |||
232 | TimeField { | 254 | TimeField { | ||
233 | id: mornBeginManField | 255 | id: mornBeginManField | ||
234 | // Match combobox width | 256 | // Match combobox width | ||
235 | Layout.minimumWidth: modeSwitcher.width | 257 | Layout.minimumWidth: modeSwitcher.width | ||
236 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings | 258 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings | ||
237 | Kirigami.FormData.label: i18n("Turn off at:") | 259 | Kirigami.FormData.label: i18n("Turn off at:") | ||
238 | backend: cA.morningBeginFixedStaged | 260 | backend: cA.morningBeginFixedStaged | ||
239 | onBackendChanged: {cA.morningBeginFixedStaged = backend; | 261 | onBackendChanged: { | ||
262 | cA.morningBeginFixedStaged = backend; | ||||
240 | calcNeedsSave(); | 263 | calcNeedsSave(); | ||
241 | } | 264 | } | ||
242 | 265 | | |||
243 | QQC2.ToolTip { | 266 | QQC2.ToolTip { | ||
244 | text: i18n("Input format: HH:MM") | 267 | text: i18n("Input format: HH:MM") | ||
245 | } | 268 | } | ||
246 | } | 269 | } | ||
247 | 270 | | |||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |
What is this supposed to do?