Changeset View
Changeset View
Standalone View
Standalone View
kcms/nightcolor/package/contents/ui/main.qml
Show All 21 Lines | |||||
22 | import org.kde.kcm 1.2 as KCM | 22 | import org.kde.kcm 1.2 as KCM | ||
23 | 23 | | |||
24 | import org.kde.colorcorrect 0.1 as CC | 24 | import org.kde.colorcorrect 0.1 as CC | ||
25 | 25 | | |||
26 | KCM.SimpleKCM { | 26 | KCM.SimpleKCM { | ||
27 | id: root | 27 | id: root | ||
28 | property int error: cA.error | 28 | property int error: cA.error | ||
29 | property bool defaultRequested: false | 29 | property bool defaultRequested: false | ||
30 | implicitHeight: Kirigami.Units.gridUnit * 29 | 30 | implicitHeight: Kirigami.Units.gridUnit * 30 | ||
31 | implicitWidth: Kirigami.Units.gridUnit * 35 | ||||
31 | 32 | | |||
32 | CC.CompositorAdaptor { | 33 | CC.CompositorAdaptor { | ||
33 | id: cA | 34 | id: cA | ||
34 | } | 35 | } | ||
35 | 36 | | |||
36 | CC.Geolocator { | 37 | CC.Geolocator { | ||
37 | id: locator | 38 | id: locator | ||
38 | } | 39 | } | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 101 | ColumnLayout { | |||
103 | QQC2.Label { | 104 | QQC2.Label { | ||
104 | Layout.topMargin: Kirigami.Units.largeSpacing * 2 | 105 | Layout.topMargin: Kirigami.Units.largeSpacing * 2 | ||
105 | Layout.bottomMargin: Kirigami.Units.largeSpacing * 4 | 106 | Layout.bottomMargin: Kirigami.Units.largeSpacing * 4 | ||
106 | Layout.leftMargin: Kirigami.Units.smallSpacing | 107 | Layout.leftMargin: Kirigami.Units.smallSpacing | ||
107 | Layout.rightMargin: Kirigami.Units.smallSpacing | 108 | Layout.rightMargin: Kirigami.Units.smallSpacing | ||
108 | Layout.alignment: Qt.AlignHCenter | 109 | Layout.alignment: Qt.AlignHCenter | ||
109 | Layout.maximumWidth: Math.round(root.width * 0.5) | 110 | Layout.maximumWidth: Math.round(root.width * 0.5) | ||
110 | 111 | | |||
111 | text: i18n("Night Color makes the colors on the screen warmer to reduce eye strain.") | 112 | text: i18n("Night Color makes the colors on the screen warmer to reduce eye strain at the time of your choosing.") | ||
112 | wrapMode: Text.WordWrap | 113 | wrapMode: Text.WordWrap | ||
113 | } | 114 | } | ||
114 | 115 | | |||
115 | Kirigami.FormLayout { | 116 | Kirigami.FormLayout { | ||
116 | id: parentLayout | 117 | id: parentLayout | ||
117 | 118 | | |||
118 | QQC2.CheckBox { | 119 | QQC2.CheckBox { | ||
119 | id: activator | 120 | id: activator | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
171 | } | 172 | } | ||
172 | 173 | | |||
173 | Item { | 174 | Item { | ||
174 | Kirigami.FormData.isSection: true | 175 | Kirigami.FormData.isSection: true | ||
175 | } | 176 | } | ||
176 | 177 | | |||
177 | QQC2.ComboBox { | 178 | QQC2.ComboBox { | ||
178 | id: modeSwitcher | 179 | id: modeSwitcher | ||
179 | Kirigami.FormData.label: i18n("Operation mode:") | 180 | // Work around https://bugs.kde.org/show_bug.cgi?id=403153 | ||
181 | Layout.minimumWidth: Kirigami.Units.gridUnit * 17 | ||||
182 | Kirigami.FormData.label: i18n("Time:") | ||||
180 | enabled: activator.checked | 183 | enabled: activator.checked | ||
181 | model: [ | 184 | model: [ | ||
182 | i18n("Automatic"), | 185 | i18n("Sunset to sunrise at current location"), | ||
183 | i18n("Location"), | 186 | i18n("Sunset to sunrise at manual location"), | ||
184 | i18n("Times"), | 187 | i18n("Custom time"), | ||
185 | i18n("Constant") | 188 | i18n("Always on") | ||
186 | ] | 189 | ] | ||
187 | currentIndex: cA.mode | 190 | currentIndex: cA.mode | ||
188 | onCurrentIndexChanged: { | 191 | onCurrentIndexChanged: { | ||
189 | cA.modeStaged = currentIndex; | 192 | cA.modeStaged = currentIndex; | ||
190 | advancedControlLoader.updatePage(currentIndex); | | |||
191 | calcNeedsSave(); | 193 | calcNeedsSave(); | ||
192 | } | 194 | } | ||
193 | } | 195 | } | ||
194 | } | 196 | } | ||
195 | 197 | | |||
196 | Kirigami.FormLayout { | 198 | // Show current location in auto mode | ||
197 | 199 | QQC2.Label { | |||
198 | Loader { | | |||
199 | id: advancedControlLoader | | |||
200 | | ||||
201 | | ||||
202 | function updatePage(index) { | | |||
203 | switch (index) { | | |||
204 | case CC.CompositorAdaptor.ModeAutomatic: | | |||
205 | sourceComponent = automaticView; | | |||
206 | break; | | |||
207 | case CC.CompositorAdaptor.ModeLocation: | | |||
208 | sourceComponent = manualLocationsView; | | |||
209 | break; | | |||
210 | case CC.CompositorAdaptor.ModeTimings: | | |||
211 | sourceComponent = manualTimingsView; | | |||
212 | break; | | |||
213 | case CC.CompositorAdaptor.ModeConstant: | | |||
214 | default: | | |||
215 | sourceComponent = undefined; | | |||
216 | break; | | |||
217 | } | | |||
218 | } | | |||
219 | } | | |||
220 | | ||||
221 | Component { | | |||
222 | id: automaticView | | |||
223 | | ||||
224 | ColumnLayout { | | |||
225 | | ||||
226 | Loader { | | |||
227 | sourceComponent: TimingsView { | | |||
228 | latitude: locator.latitude | | |||
229 | longitude: locator.longitude | | |||
230 | } | | |||
231 | } | | |||
232 | | ||||
233 | Kirigami.Separator { | | |||
234 | Layout.fillWidth: true | 200 | Layout.fillWidth: true | ||
235 | Kirigami.FormData.isSection: true | 201 | horizontalAlignment: Text.AlignHCenter | ||
236 | } | 202 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeAutomatic | ||
237 | 203 | enabled: activator.checked | |||
238 | Loader { | 204 | elide: Text.elideMiddle | ||
239 | sourceComponent: LocationsAutoView { | 205 | text: i18n("Latitude: %1 Longitude: %2", locator.latitude, locator.longitude) | ||
240 | latitude: locator.latitude | | |||
241 | longitude: locator.longitude | | |||
242 | } | | |||
243 | } | | |||
244 | } | | |||
245 | } | | |||
246 | | ||||
247 | Component { | | |||
248 | id: manualLocationsView | | |||
249 | | ||||
250 | ColumnLayout { | | |||
251 | id: manualLocationsViewRow | | |||
252 | signal change() | | |||
253 | | ||||
254 | Loader { | | |||
255 | sourceComponent: TimingsView { | | |||
256 | latitude: cA.latitudeFixedStaged | | |||
257 | longitude: cA.longitudeFixedStaged | | |||
258 | | ||||
259 | Connections { | | |||
260 | target: manualLocationsViewRow | | |||
261 | onChange: { | | |||
262 | reset(); | | |||
263 | } | | |||
264 | } | | |||
265 | } | | |||
266 | } | 206 | } | ||
267 | 207 | | |||
268 | Kirigami.Separator { | 208 | // Show location chooser in manual location mode | ||
269 | Layout.fillWidth: true | 209 | LocationsFixedView { | ||
270 | Kirigami.FormData.isSection: true | 210 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeLocation | ||
211 | enabled: activator.checked | ||||
271 | } | 212 | } | ||
272 | 213 | | |||
273 | Loader { | 214 | // Show start/end times in automatic and manual location modes | ||
274 | sourceComponent: LocationsFixedView {} | 215 | TimingsView { | ||
275 | } | 216 | id: timings | ||
276 | } | 217 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeAutomatic || | ||
218 | modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeLocation | ||||
219 | enabled: activator.checked | ||||
220 | latitude: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeAutomatic ? locator.latitude : cA.latitudeFixedStaged | ||||
221 | longitude: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeAutomatic ? locator.longitude : cA.longitudeFixedStaged | ||||
277 | } | 222 | } | ||
278 | 223 | | |||
279 | Component { | 224 | // Show time entry fields in manual timings mode | ||
280 | id: manualTimingsView | 225 | Kirigami.FormLayout { | ||
281 | 226 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings | |||
282 | ColumnLayout { | | |||
283 | Loader { | | |||
284 | sourceComponent: Kirigami.FormLayout { | | |||
285 | twinFormLayouts: parentLayout | 227 | twinFormLayouts: parentLayout | ||
286 | enabled: activator.checked && cA.timingsEnabled | 228 | enabled: activator.checked && cA.timingsEnabled | ||
287 | 229 | | |||
288 | Connections { | 230 | Connections { | ||
289 | target: root | 231 | target: root | ||
290 | onReset: { | 232 | onReset: { | ||
291 | mornBeginManField.backend = cA.morningBeginFixed; | 233 | mornBeginManField.backend = cA.morningBeginFixed; | ||
292 | evenBeginManField.backend = cA.eveningBeginFixed; | 234 | evenBeginManField.backend = cA.eveningBeginFixed; | ||
293 | transTimeField.backend = cA.transitionTime; | 235 | transTimeField.backend = cA.transitionTime; | ||
294 | } | 236 | } | ||
295 | } | 237 | } | ||
296 | 238 | | |||
297 | TimeField { | 239 | TimeField { | ||
298 | id: mornBeginManField | 240 | id: evenBeginManField | ||
299 | Kirigami.FormData.label: i18n("Sunrise begins:") | 241 | Kirigami.FormData.label: i18n("Turn on at:") | ||
300 | backend: cA.morningBeginFixedStaged | 242 | backend: cA.eveningBeginFixedStaged | ||
301 | onBackendChanged: {cA.morningBeginFixedStaged = backend; | 243 | onBackendChanged: {cA.eveningBeginFixedStaged = backend; | ||
302 | calcNeedsSave(); | 244 | calcNeedsSave(); | ||
303 | } | 245 | } | ||
304 | 246 | | |||
305 | QQC2.ToolTip { | 247 | QQC2.ToolTip { | ||
306 | text: i18n("(Input format: HH:MM)") | 248 | text: i18n("Input format: HH:MM") | ||
307 | } | 249 | } | ||
308 | } | 250 | } | ||
309 | 251 | | |||
310 | TimeField { | 252 | TimeField { | ||
311 | id: evenBeginManField | 253 | id: mornBeginManField | ||
312 | Kirigami.FormData.label: i18n("Sunset begins:") | 254 | Kirigami.FormData.label: i18n("Turn off at:") | ||
313 | backend: cA.eveningBeginFixedStaged | 255 | backend: cA.morningBeginFixedStaged | ||
314 | onBackendChanged: {cA.eveningBeginFixedStaged = backend; | 256 | onBackendChanged: {cA.morningBeginFixedStaged = backend; | ||
315 | calcNeedsSave(); | 257 | calcNeedsSave(); | ||
316 | } | 258 | } | ||
317 | 259 | | |||
318 | QQC2.ToolTip { | 260 | QQC2.ToolTip { | ||
319 | text: i18n("Input format: HH:MM") | 261 | text: i18n("Input format: HH:MM") | ||
320 | } | 262 | } | ||
321 | } | 263 | } | ||
322 | 264 | | |||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 299 | visible: { | |||
365 | return eve - mor <= trTime || eve - mor >= 86400000 - trTime; | 307 | return eve - mor <= trTime || eve - mor >= 86400000 - trTime; | ||
366 | } | 308 | } | ||
367 | font.italic: true | 309 | font.italic: true | ||
368 | text: i18n("Error: Transition time overlaps.") | 310 | text: i18n("Error: Transition time overlaps.") | ||
369 | } | 311 | } | ||
370 | } | 312 | } | ||
371 | } | 313 | } | ||
372 | } | 314 | } | ||
373 | } | | |||
374 | } | | |||
375 | } | | |||
376 | } | |