Changeset View
Changeset View
Standalone View
Standalone View
kcms/nightcolor/package/contents/ui/main.qml
Show All 22 Lines | |||||
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 * 29 | ||
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 | | |||
119 | Connections { | ||||
120 | target: root | ||||
121 | onReset: { | ||||
122 | mornBeginManField.backend = cA.morningBeginFixed; | ||||
123 | evenBeginManField.backend = cA.eveningBeginFixed; | ||||
124 | transTimeField.value = cA.transitionTime; | ||||
125 | } | ||||
126 | } | ||||
127 | | ||||
118 | QQC2.CheckBox { | 128 | QQC2.CheckBox { | ||
119 | id: activator | 129 | id: activator | ||
120 | text: i18n("Activate Night Color") | 130 | text: i18n("Activate Night Color") | ||
121 | enabled: cA.nightColorAvailable | 131 | enabled: cA.nightColorAvailable | ||
122 | checked: cA.active | 132 | checked: cA.active | ||
123 | 133 | | |||
124 | onCheckedChanged: { | 134 | onCheckedChanged: { | ||
125 | cA.activeStaged = checked; | 135 | cA.activeStaged = checked; | ||
126 | calcNeedsSave(); | 136 | calcNeedsSave(); | ||
127 | } | 137 | } | ||
128 | } | 138 | } | ||
129 | 139 | | |||
130 | Item { | 140 | Item { | ||
131 | Kirigami.FormData.isSection: true | 141 | Kirigami.FormData.isSection: true | ||
132 | } | 142 | } | ||
133 | 143 | | |||
134 | GridLayout { | 144 | GridLayout { | ||
135 | Kirigami.FormData.label: i18n("Night Color temperature:") | 145 | Kirigami.FormData.label: i18n("Night Color Temperature:") | ||
136 | Kirigami.FormData.buddyFor: tempSlider | 146 | Kirigami.FormData.buddyFor: tempSlider | ||
137 | enabled: activator.checked | 147 | enabled: activator.checked | ||
138 | 148 | | |||
139 | columns: 4 | 149 | columns: 4 | ||
140 | 150 | | |||
141 | QQC2.Slider { | 151 | QQC2.Slider { | ||
142 | id: tempSlider | 152 | id: tempSlider | ||
153 | // Match combobox width | ||||
154 | Layout.minimumWidth: modeSwitcher.width | ||||
143 | enabled: activator.checked | 155 | enabled: activator.checked | ||
144 | from: cA.minimalTemperature | 156 | from: cA.minimalTemperature | ||
145 | implicitWidth: modeSwitcher.width | | |||
146 | to: cA.neutralTemperature | 157 | to: cA.neutralTemperature | ||
147 | value: cA.nightTemperature | 158 | value: cA.nightTemperature | ||
148 | stepSize: 100 | 159 | stepSize: 100 | ||
149 | 160 | | |||
150 | Layout.columnSpan: 3 | 161 | Layout.columnSpan: 3 | ||
151 | 162 | | |||
152 | onValueChanged: { | 163 | onValueChanged: { | ||
153 | cA.nightTemperatureStaged = value; | 164 | cA.nightTemperatureStaged = value; | ||
Show All 17 Lines | |||||
171 | } | 182 | } | ||
172 | 183 | | |||
173 | Item { | 184 | Item { | ||
174 | Kirigami.FormData.isSection: true | 185 | Kirigami.FormData.isSection: true | ||
175 | } | 186 | } | ||
176 | 187 | | |||
177 | QQC2.ComboBox { | 188 | QQC2.ComboBox { | ||
178 | id: modeSwitcher | 189 | id: modeSwitcher | ||
179 | Kirigami.FormData.label: i18n("Operation mode:") | 190 | // Work around https://bugs.kde.org/show_bug.cgi?id=403153 | ||
191 | Layout.minimumWidth: Kirigami.Units.gridUnit * 17 | ||||
192 | Kirigami.FormData.label: i18n("Activation time:") | ||||
180 | enabled: activator.checked | 193 | enabled: activator.checked | ||
181 | model: [ | 194 | model: [ | ||
182 | i18n("Automatic"), | 195 | i18n("Sunset to sunrise at current location"), | ||
183 | i18n("Location"), | 196 | i18n("Sunset to sunrise at manual location"), | ||
184 | i18n("Times"), | 197 | i18n("Custom time"), | ||
185 | i18n("Constant") | 198 | i18n("Always on") | ||
186 | ] | 199 | ] | ||
187 | currentIndex: cA.mode | 200 | currentIndex: cA.mode | ||
188 | onCurrentIndexChanged: { | 201 | onCurrentIndexChanged: { | ||
189 | cA.modeStaged = currentIndex; | 202 | cA.modeStaged = currentIndex; | ||
190 | advancedControlLoader.updatePage(currentIndex); | | |||
191 | calcNeedsSave(); | 203 | calcNeedsSave(); | ||
192 | } | 204 | } | ||
193 | } | 205 | } | ||
194 | } | | |||
195 | | ||||
196 | Kirigami.FormLayout { | | |||
197 | 206 | | |||
198 | Loader { | 207 | // Show current location in auto mode | ||
199 | id: advancedControlLoader | 208 | QQC2.Label { | ||
200 | 209 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeAutomatic | |||
201 | 210 | enabled: activator.checked | |||
202 | function updatePage(index) { | 211 | wrapMode: Text.Wrap | ||
203 | switch (index) { | 212 | text: i18n("Latitude: %1 Longitude: %2", locator.latitude, locator.longitude) | ||
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 | | |||
235 | Kirigami.FormData.isSection: true | | |||
236 | } | | |||
237 | | ||||
238 | Loader { | | |||
239 | sourceComponent: LocationsAutoView { | | |||
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 | } | | |||
267 | | ||||
268 | Kirigami.Separator { | | |||
269 | Layout.fillWidth: true | | |||
270 | Kirigami.FormData.isSection: true | | |||
271 | } | | |||
272 | | ||||
273 | Loader { | | |||
274 | sourceComponent: LocationsFixedView {} | | |||
275 | } | | |||
276 | } | | |||
277 | } | | |||
278 | | ||||
279 | Component { | | |||
280 | id: manualTimingsView | | |||
281 | | ||||
282 | ColumnLayout { | | |||
283 | Loader { | | |||
284 | sourceComponent: Kirigami.FormLayout { | | |||
285 | twinFormLayouts: parentLayout | | |||
286 | enabled: activator.checked && cA.timingsEnabled | | |||
287 | | ||||
288 | Connections { | | |||
289 | target: root | | |||
290 | onReset: { | | |||
291 | mornBeginManField.backend = cA.morningBeginFixed; | | |||
292 | evenBeginManField.backend = cA.eveningBeginFixed; | | |||
293 | transTimeField.backend = cA.transitionTime; | | |||
294 | } | | |||
295 | } | 213 | } | ||
296 | 214 | | |||
215 | // Show time entry fields in manual timings mode | ||||
297 | TimeField { | 216 | TimeField { | ||
298 | id: mornBeginManField | 217 | id: evenBeginManField | ||
299 | Kirigami.FormData.label: i18n("Sunrise begins:") | 218 | // Match combobox width | ||
300 | backend: cA.morningBeginFixedStaged | 219 | Layout.minimumWidth: modeSwitcher.width | ||
301 | onBackendChanged: {cA.morningBeginFixedStaged = backend; | 220 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings | ||
221 | Kirigami.FormData.label: i18n("Turn on at:") | ||||
222 | backend: cA.eveningBeginFixedStaged | ||||
223 | onBackendChanged: {cA.eveningBeginFixedStaged = backend; | ||||
302 | calcNeedsSave(); | 224 | calcNeedsSave(); | ||
303 | } | 225 | } | ||
304 | 226 | | |||
305 | QQC2.ToolTip { | 227 | QQC2.ToolTip { | ||
306 | text: i18n("(Input format: HH:MM)") | 228 | text: i18n("Input format: HH:MM") | ||
307 | } | 229 | } | ||
308 | } | 230 | } | ||
309 | 231 | | |||
310 | TimeField { | 232 | TimeField { | ||
311 | id: evenBeginManField | 233 | id: mornBeginManField | ||
312 | Kirigami.FormData.label: i18n("Sunset begins:") | 234 | // Match combobox width | ||
313 | backend: cA.eveningBeginFixedStaged | 235 | Layout.minimumWidth: modeSwitcher.width | ||
314 | onBackendChanged: {cA.eveningBeginFixedStaged = backend; | 236 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings | ||
237 | Kirigami.FormData.label: i18n("Turn off at:") | ||||
238 | backend: cA.morningBeginFixedStaged | ||||
239 | onBackendChanged: {cA.morningBeginFixedStaged = backend; | ||||
315 | calcNeedsSave(); | 240 | calcNeedsSave(); | ||
316 | } | 241 | } | ||
317 | 242 | | |||
318 | QQC2.ToolTip { | 243 | QQC2.ToolTip { | ||
319 | text: i18n("Input format: HH:MM") | 244 | text: i18n("Input format: HH:MM") | ||
320 | } | 245 | } | ||
321 | } | 246 | } | ||
322 | 247 | | |||
323 | QQC2.SpinBox { | 248 | QQC2.SpinBox { | ||
324 | id: transTimeField | 249 | id: transTimeField | ||
325 | // Match width of other text fields | 250 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings | ||
326 | Layout.minimumWidth: 200 | 251 | // Match width of combobox and input fields | ||
252 | Layout.minimumWidth: modeSwitcher.width | ||||
327 | Kirigami.FormData.label: i18n("Transition duration:") | 253 | Kirigami.FormData.label: i18n("Transition duration:") | ||
328 | from: 1 | 254 | from: 1 | ||
329 | to: 600 // less than 12 hours (in minutes: 720) | 255 | to: 600 // less than 12 hours (in minutes: 720) | ||
330 | value: cA.transitionTimeStaged | 256 | value: cA.transitionTimeStaged | ||
331 | editable: true | 257 | editable: true | ||
332 | onValueModified: { | 258 | onValueModified: { | ||
333 | cA.transitionTimeStaged = value; | 259 | cA.transitionTimeStaged = value; | ||
334 | calcNeedsSave(); | 260 | calcNeedsSave(); | ||
Show All 28 Lines | 283 | visible: { | |||
363 | var eve = evenBeginManField.getNormedDate(); | 289 | var eve = evenBeginManField.getNormedDate(); | ||
364 | 290 | | |||
365 | return eve - mor <= trTime || eve - mor >= 86400000 - trTime; | 291 | return eve - mor <= trTime || eve - mor >= 86400000 - trTime; | ||
366 | } | 292 | } | ||
367 | font.italic: true | 293 | font.italic: true | ||
368 | text: i18n("Error: Transition time overlaps.") | 294 | text: i18n("Error: Transition time overlaps.") | ||
369 | } | 295 | } | ||
370 | } | 296 | } | ||
297 | | ||||
298 | // Show location chooser in manual location mode | ||||
299 | LocationsFixedView { | ||||
300 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeLocation | ||||
301 | enabled: activator.checked | ||||
371 | } | 302 | } | ||
372 | } | 303 | | ||
373 | } | 304 | // Show start/end times in automatic and manual location modes | ||
305 | TimingsView { | ||||
306 | id: timings | ||||
307 | visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeAutomatic || | ||||
308 | modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeLocation | ||||
309 | enabled: activator.checked | ||||
310 | latitude: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeAutomatic ? locator.latitude : cA.latitudeFixedStaged | ||||
311 | longitude: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeAutomatic ? locator.longitude : cA.longitudeFixedStaged | ||||
374 | } | 312 | } | ||
375 | } | 313 | } | ||
376 | } | 314 | } |