Changeset View
Changeset View
Standalone View
Standalone View
applets/digital-clock/package/contents/ui/DigitalClock.qml
Context not available. | |||||
54 | property int tzIndex: 0 | 54 | property int tzIndex: 0 | ||
---|---|---|---|---|---|
55 | 55 | | |||
56 | // if the date/timezone cannot be fit with the smallest font to its designated space | 56 | // if the date/timezone cannot be fit with the smallest font to its designated space | ||
57 | readonly property bool tooSmall: plasmoid.formFactor == PlasmaCore.Types.Horizontal && Math.round(2 * (main.height / 5)) <= theme.smallestFont.pixelSize | 57 | readonly property bool tooSmall: plasmoid.formFactor == PlasmaCore.Types.Horizontal && Math.floor(0.4 * main.height) <= theme.smallestFont.pointSize | ||
mart: here you are comparing points and pixels | |||||
58 | 58 | | |||
59 | onDateFormatChanged: { | 59 | onDateFormatChanged: { | ||
60 | setupLabels(); | 60 | setupLabels(); | ||
Context not available. | |||||
93 | target: main | 93 | target: main | ||
94 | Layout.fillHeight: true | 94 | Layout.fillHeight: true | ||
95 | Layout.fillWidth: false | 95 | Layout.fillWidth: false | ||
96 | Layout.minimumWidth: Math.max(labelsFlow.width, dateLabel.paintedWidth) | 96 | Layout.minimumWidth: Math.max(labelsGrid.width, dateLabelUnder.paintedWidth) | ||
97 | Layout.maximumWidth: Layout.minimumWidth | 97 | Layout.maximumWidth: Layout.minimumWidth | ||
98 | 98 | | |||
99 | } | 99 | } | ||
Context not available. | |||||
101 | PropertyChanges { | 101 | PropertyChanges { | ||
102 | target: timeLabel | 102 | target: timeLabel | ||
103 | 103 | | |||
104 | height: sizehelper.height | | |||
105 | width: sizehelper.width | | |||
106 | | ||||
107 | wrapMode: Text.NoWrap | 104 | wrapMode: Text.NoWrap | ||
108 | fontSizeMode: Text.VerticalFit | 105 | fontSizeMode: Text.VerticalFit | ||
109 | } | 106 | } | ||
Context not available. | |||||
111 | PropertyChanges { | 108 | PropertyChanges { | ||
112 | target: timezoneLabel | 109 | target: timezoneLabel | ||
113 | 110 | | |||
114 | height: main.showDate ? timeLabel.height : Math.round(2 * (timeLabel.height / 3)) | 111 | height: 0.8 * timeLabel.height | ||
115 | width: main.showDate ? timezoneLabel.paintedWidth : timeLabel.width | 112 | width: main.showDate ? timezoneLabel.paintedWidth : timeLabel.width | ||
116 | 113 | | |||
117 | fontSizeMode: Text.VerticalFit | 114 | fontSizeMode: Text.VerticalFit | ||
118 | minimumPointSize: 1 | | |||
119 | font.pointSize: 1024 | 115 | font.pointSize: 1024 | ||
120 | elide: Text.ElideNone | 116 | elide: Text.ElideNone | ||
121 | horizontalAlignment: Text.AlignHCenter | | |||
122 | } | 117 | } | ||
123 | 118 | | |||
124 | PropertyChanges { | 119 | PropertyChanges { | ||
125 | target: dateLabel | 120 | target: dateLabelUnder | ||
126 | 121 | | |||
127 | height: Math.round(2 * (main.height / 5)) | 122 | width: dateLabelUnder.paintedWidth | ||
128 | width: dateLabel.paintedWidth | | |||
129 | 123 | | |||
130 | anchors.horizontalCenter: main.horizontalCenter | 124 | fontSizeMode: Text.VerticalFit | ||
131 | } | 125 | } | ||
132 | 126 | | |||
133 | PropertyChanges { | 127 | PropertyChanges { | ||
134 | target: labelsFlow | 128 | target: labelsGrid | ||
135 | 129 | | |||
136 | flow: main.showDate ? Flow.LeftToRight : Flow.TopToBottom | 130 | rows: main.showDate ? 1 : 2 | ||
137 | } | 131 | } | ||
138 | 132 | | |||
139 | PropertyChanges { | 133 | PropertyChanges { | ||
140 | target: sizehelper | 134 | target: sizehelper | ||
141 | 135 | | |||
142 | height: main.showDate || timezoneLabel.visible ? Math.round(3 * (main.height / 5)) : main.height | 136 | height: main.showDate || timezoneLabel.visible ? 0.6 * main.height : main.height | ||
143 | width: sizehelper.paintedWidth | 137 | width: sizehelper.paintedWidth | ||
144 | 138 | | |||
145 | fontSizeMode: Text.VerticalFit | 139 | fontSizeMode: Text.VerticalFit | ||
Context not available. | |||||
154 | target: main | 148 | target: main | ||
155 | Layout.fillHeight: true | 149 | Layout.fillHeight: true | ||
156 | Layout.fillWidth: false | 150 | Layout.fillWidth: false | ||
157 | Layout.minimumWidth: labelsFlow.width | 151 | Layout.minimumWidth: labelsGrid.width | ||
158 | Layout.maximumWidth: Layout.minimumWidth | 152 | Layout.maximumWidth: Layout.minimumWidth | ||
159 | 153 | | |||
160 | } | 154 | } | ||
Context not available. | |||||
162 | PropertyChanges { | 156 | PropertyChanges { | ||
163 | target: timeLabel | 157 | target: timeLabel | ||
164 | 158 | | |||
165 | height: sizehelper.height | | |||
166 | width: sizehelper.width | | |||
167 | | ||||
168 | wrapMode: Text.NoWrap | 159 | wrapMode: Text.NoWrap | ||
169 | fontSizeMode: Text.VerticalFit | 160 | fontSizeMode: Text.VerticalFit | ||
170 | font.pointSize: theme.defaultFont.pointSize | | |||
171 | } | 161 | } | ||
172 | 162 | | |||
173 | PropertyChanges { | 163 | PropertyChanges { | ||
174 | target: timezoneLabel | 164 | target: timezoneLabel | ||
175 | 165 | | |||
176 | height: sizehelper.height | 166 | height: 0.8 * timeLabel.height | ||
177 | width: timezoneLabel.paintedWidth | 167 | width: timezoneLabel.paintedWidth | ||
178 | 168 | | |||
179 | fontSizeMode: Text.VerticalFit | 169 | fontSizeMode: Text.VerticalFit | ||
180 | minimumPointSize: 1 | | |||
181 | font.pointSize: theme.defaultFont.pointSize | | |||
182 | elide: Text.ElideNone | 170 | elide: Text.ElideNone | ||
183 | horizontalAlignment: Text.AlignHCenter | 171 | horizontalAlignment: Text.AlignHCenter | ||
184 | } | 172 | } | ||
185 | 173 | | |||
186 | PropertyChanges { | 174 | PropertyChanges { | ||
187 | target: labelsFlow | 175 | target: dateLabelLeft | ||
188 | 176 | | |||
189 | flow: Flow.LeftToRight | 177 | fontSizeMode: Text.VerticalFit | ||
190 | } | 178 | } | ||
191 | 179 | | |||
192 | PropertyChanges { | 180 | PropertyChanges { | ||
Context not available. | |||||
207 | target: main | 195 | target: main | ||
208 | Layout.fillHeight: false | 196 | Layout.fillHeight: false | ||
209 | Layout.fillWidth: true | 197 | Layout.fillWidth: true | ||
210 | Layout.maximumHeight: main.showDate ? labelsFlow.height + dateLabel.height : labelsFlow.height | 198 | Layout.maximumHeight: main.showDate ? labelsGrid.height + dateLabelUnder.height : labelsGrid.height | ||
211 | Layout.minimumHeight: Layout.maximumHeight | 199 | Layout.minimumHeight: Layout.maximumHeight | ||
212 | } | 200 | } | ||
213 | 201 | | |||
214 | PropertyChanges { | 202 | PropertyChanges { | ||
215 | target: timeLabel | 203 | target: timeLabel | ||
216 | 204 | | |||
217 | height: sizehelper.height | 205 | minimumPointSize: 1 | ||
218 | width: sizehelper.width | | |||
219 | minimumPointSize: 0 | | |||
220 | | ||||
221 | fontSizeMode: Text.HorizontalFit | | |||
222 | } | 206 | } | ||
223 | 207 | | |||
224 | PropertyChanges { | 208 | PropertyChanges { | ||
225 | target: timezoneLabel | 209 | target: timezoneLabel | ||
226 | 210 | | |||
227 | height: Math.max(sizehelper.lineCount > 1 ? 2 * Math.round(timeLabel.height / 6) : 2 * Math.round(timeLabel.height / 3), theme.smallestFont.pixelSize) | 211 | height: Math.min(Math.max(sizehelper.lineCount > 1 ? 2 * Math.round(timeLabel.height / 6) : 2 * Math.round(timeLabel.height / 3), theme.smallestFont.pointSize), Math.round(timeLabel.height)) | ||
@mart : Should this also stay in pixelSize? I assume in general always when comparing heights and font sizes, right? romangg: @mart : Should this also stay in pixelSize? I assume in general always when comparing heights… | |||||
228 | width: main.width | 212 | width: main.width | ||
229 | 213 | | |||
230 | fontSizeMode: Text.HorizontalFit | 214 | fontSizeMode: Text.Fit | ||
231 | minimumPointSize: 0 | | |||
232 | elide: Text.ElideRight | 215 | elide: Text.ElideRight | ||
233 | } | 216 | } | ||
234 | 217 | | |||
235 | PropertyChanges { | 218 | PropertyChanges { | ||
236 | target: dateLabel | 219 | target: dateLabelUnder | ||
237 | 220 | | |||
238 | height: timezoneLabel.height | 221 | height: timeLabel.height | ||
239 | width: timezoneLabel.width | 222 | width: main.width | ||
240 | 223 | | |||
241 | fontSizeMode: Text.HorizontalFit | 224 | fontSizeMode: Text.Fit | ||
242 | minimumPointSize: 0 | 225 | minimumPointSize: 1 | ||
243 | elide: Text.ElideRight | | |||
244 | } | 226 | } | ||
245 | 227 | | |||
246 | PropertyChanges { | 228 | PropertyChanges { | ||
Context not available. | |||||
249 | height: sizehelper.paintedHeight | 231 | height: sizehelper.paintedHeight | ||
250 | width: main.width | 232 | width: main.width | ||
251 | 233 | | |||
252 | minimumPointSize: 0 | 234 | minimumPointSize: 1 | ||
253 | 235 | | |||
254 | fontSizeMode: Text.HorizontalFit | 236 | fontSizeMode: Text.HorizontalFit | ||
255 | horizontalAlignment: Text.AlignHCenter | 237 | horizontalAlignment: Text.AlignHCenter | ||
256 | wrapMode: Text.WordWrap | 238 | wrapMode: Text.WordWrap | ||
257 | } | 239 | } | ||
240 | | ||||
241 | PropertyChanges { | ||||
242 | target: labelsGrid | ||||
243 | | ||||
244 | rows: 2 | ||||
245 | } | ||||
258 | }, | 246 | }, | ||
259 | 247 | | |||
260 | State { | 248 | State { | ||
Context not available. | |||||
266 | Layout.fillHeight: false | 254 | Layout.fillHeight: false | ||
267 | Layout.fillWidth: false | 255 | Layout.fillWidth: false | ||
268 | Layout.minimumWidth: units.gridUnit * 3 | 256 | Layout.minimumWidth: units.gridUnit * 3 | ||
269 | Layout.maximumWidth: Math.max(labelsFlow.width, dateLabel.width) | 257 | Layout.maximumWidth: Math.max(labelsGrid.width, dateLabelUnder.width) | ||
270 | Layout.minimumHeight: units.gridUnit * 3 | 258 | Layout.minimumHeight: units.gridUnit * 3 | ||
271 | Layout.maximumHeight: main.showDate ? labelsFlow.height + dateLabel.height : labelsFlow.height | 259 | Layout.maximumHeight: main.showDate ? labelsGrid.height + dateLabelUnder.height : labelsGrid.height | ||
272 | } | 260 | } | ||
273 | 261 | | |||
274 | PropertyChanges { | 262 | PropertyChanges { | ||
275 | target: timeLabel | 263 | target: timeLabel | ||
276 | 264 | | |||
277 | height: sizehelper.height | | |||
278 | width: main.width | | |||
279 | | ||||
280 | wrapMode: Text.NoWrap | 265 | wrapMode: Text.NoWrap | ||
281 | fontSizeMode: Text.Fit | | |||
282 | } | 266 | } | ||
283 | 267 | | |||
284 | PropertyChanges { | 268 | PropertyChanges { | ||
285 | target: timezoneLabel | 269 | target: timezoneLabel | ||
286 | 270 | | |||
287 | height: dateLabel.visible ? Math.round(1 * (main.height / 5)) : Math.round(2 * (main.height / 5)) | 271 | height: dateLabelUnder.visible ? Math.round(0.2 * main.height) : Math.round(0.4 * main.height) | ||
288 | width: main.width | 272 | width: main.width | ||
289 | 273 | | |||
290 | fontSizeMode: Text.Fit | 274 | fontSizeMode: Text.Fit | ||
291 | minimumPixelSize: 0 | | |||
292 | elide: Text.ElideRight | 275 | elide: Text.ElideRight | ||
293 | } | 276 | } | ||
294 | 277 | | |||
295 | PropertyChanges { | 278 | PropertyChanges { | ||
296 | target: dateLabel | 279 | target: dateLabelUnder | ||
297 | 280 | | |||
298 | height: timezoneLabel.visible ? Math.round(1 * (main.height / 5)) : Math.round(2 * (main.height / 5)) | 281 | height: timezoneLabel.visible ? Math.round(0.2 * main.height) : Math.round(0.4 * main.height) | ||
299 | width: main.width | 282 | width: main.width | ||
300 | 283 | | |||
301 | anchors.horizontalCenter: main.horizontalCenter | | |||
302 | fontSizeMode: Text.Fit | 284 | fontSizeMode: Text.Fit | ||
303 | } | 285 | } | ||
304 | 286 | | |||
305 | PropertyChanges { | 287 | PropertyChanges { | ||
306 | target: sizehelper | 288 | target: sizehelper | ||
307 | 289 | | |||
308 | height: main.showDate || timezoneLabel.visible ? Math.round(3 * (main.height / 5)) : main.height | 290 | height: main.showDate || timezoneLabel.visible ? Math.round(0.6 * main.height) : main.height | ||
309 | width: main.width | 291 | width: main.width | ||
310 | 292 | | |||
311 | fontSizeMode: Text.Fit | 293 | fontSizeMode: Text.Fit | ||
Context not available. | |||||
357 | } | 339 | } | ||
358 | } | 340 | } | ||
359 | 341 | | |||
360 | Flow { | 342 | /* | ||
361 | id: labelsFlow | 343 | * Visual elements | ||
344 | * | ||||
345 | */ | ||||
346 | | ||||
347 | Grid { | ||||
348 | id: labelsGrid | ||||
362 | 349 | | |||
363 | anchors.horizontalCenter: main.horizontalCenter | 350 | anchors.horizontalCenter: main.horizontalCenter | ||
364 | 351 | | |||
352 | rows: 1 | ||||
353 | horizontalItemAlignment: Grid.AlignHCenter | ||||
354 | verticalItemAlignment: Grid.AlignVCenter | ||||
355 | | ||||
365 | flow: Flow.TopToBottom | 356 | flow: Flow.TopToBottom | ||
366 | spacing: flow == Flow.LeftToRight && (timezoneLabel.visible || main.tooSmall) ? units.smallSpacing : 0 | 357 | columnSpacing: units.smallSpacing | ||
367 | 358 | | |||
368 | Components.Label { | 359 | Components.Label { | ||
369 | id: dateLabelLeft | 360 | id: dateLabelLeft | ||
370 | 361 | | |||
371 | height: sizehelper.height | 362 | height: 0.8 * sizehelper.height | ||
363 | width: dateLabelLeft.paintedWidth | ||||
372 | visible: main.showDate && main.tooSmall | 364 | visible: main.showDate && main.tooSmall | ||
373 | 365 | | |||
374 | font { | 366 | font { | ||
375 | weight: timeLabel.font.weight | 367 | weight: timeLabel.font.weight | ||
376 | italic: timeLabel.font.italic | 368 | italic: timeLabel.font.italic | ||
377 | pointSize: theme.defaultFont.pointSize | 369 | pointSize: 1024 | ||
378 | } | 370 | } | ||
379 | minimumPixelSize: 0 | 371 | minimumPointSize: Math.floor(0.8 * theme.smallestFont.pointSize) | ||
380 | | ||||
381 | fontSizeMode: Text.VerticalFit | | |||
382 | 372 | | |||
383 | horizontalAlignment: Text.AlignHCenter | 373 | horizontalAlignment: Text.AlignHCenter | ||
384 | verticalAlignment: Text.AlignVCenter | 374 | verticalAlignment: Text.AlignVCenter | ||
385 | } | 375 | } | ||
386 | 376 | | |||
387 | Item { | 377 | Rectangle { | ||
388 | height: dateLabelLeft.height | 378 | height: 0.8 * sizehelper.height | ||
389 | width: 1 | 379 | width: 1 | ||
390 | visible: main.showDate && main.tooSmall | 380 | visible: main.showDate && main.tooSmall | ||
391 | 381 | | |||
392 | Rectangle { | 382 | color: theme.textColor | ||
393 | id: delimiter | 383 | opacity: 0.4 | ||
394 | | ||||
395 | height: dateLabelLeft.font.pixelSize | | |||
396 | width: 1 | | |||
397 | anchors.verticalCenter: parent.verticalCenter | | |||
398 | | ||||
399 | color: theme.textColor | | |||
400 | opacity: 0.4 | | |||
401 | } | | |||
402 | } | 384 | } | ||
403 | 385 | | |||
404 | Components.Label { | 386 | Components.Label { | ||
405 | id: timeLabel | 387 | id: timeLabel | ||
406 | 388 | | |||
389 | height: sizehelper.height | ||||
390 | width: sizehelper.width | ||||
391 | fontSizeMode: Text.Fit | ||||
392 | | ||||
407 | font { | 393 | font { | ||
408 | family: plasmoid.configuration.fontFamily || theme.defaultFont.family | 394 | family: plasmoid.configuration.fontFamily || theme.defaultFont.family | ||
409 | weight: plasmoid.configuration.boldText ? Font.Bold : theme.defaultFont.weight | 395 | weight: plasmoid.configuration.boldText ? Font.Bold : theme.defaultFont.weight | ||
410 | italic: plasmoid.configuration.italicText | 396 | italic: plasmoid.configuration.italicText | ||
411 | pointSize: 1024 | 397 | pointSize: 1024 | ||
412 | } | 398 | } | ||
399 | minimumPointSize: theme.smallestFont.pointSize | ||||
413 | 400 | | |||
414 | text: { | 401 | text: { | ||
415 | // get the time for the given timezone from the dataengine | 402 | // get the time for the given timezone from the dataengine | ||
Context not available. | |||||
433 | font.weight: timeLabel.font.weight | 420 | font.weight: timeLabel.font.weight | ||
434 | font.italic: timeLabel.font.italic | 421 | font.italic: timeLabel.font.italic | ||
435 | font.pointSize: 1024 | 422 | font.pointSize: 1024 | ||
436 | minimumPixelSize: 0 | 423 | minimumPointSize: 1 | ||
437 | 424 | | |||
438 | visible: text.length > 0 | 425 | visible: text.length > 0 | ||
439 | horizontalAlignment: Text.AlignHCenter | 426 | horizontalAlignment: Text.AlignHCenter | ||
427 | verticalAlignment: Text.AlignVCenter | ||||
440 | } | 428 | } | ||
441 | } | 429 | } | ||
442 | 430 | | |||
443 | Components.Label { | 431 | Components.Label { | ||
444 | id: dateLabel | 432 | id: dateLabelUnder | ||
445 | 433 | | |||
446 | anchors.top: labelsFlow.bottom | 434 | height: 0.4 * main.height | ||
435 | anchors.top: labelsGrid.bottom | ||||
447 | visible: main.showDate && !main.tooSmall | 436 | visible: main.showDate && !main.tooSmall | ||
448 | 437 | | |||
449 | font.family: timeLabel.font.family | 438 | font.family: timeLabel.font.family | ||
450 | font.weight: timeLabel.font.weight | 439 | font.weight: timeLabel.font.weight | ||
451 | font.italic: timeLabel.font.italic | 440 | font.italic: timeLabel.font.italic | ||
452 | font.pointSize: 1024 | 441 | font.pointSize: 1024 | ||
453 | minimumPixelSize: 0 | 442 | // in order to boost the size in very small layouts, use 0.8 instead of the ratio derived 2/3 | ||
443 | minimumPointSize: Math.floor(0.8 * theme.smallestFont.pointSize) | ||||
454 | 444 | | |||
455 | fontSizeMode: Text.VerticalFit | 445 | fontSizeMode: Text.VerticalFit | ||
456 | 446 | | |||
447 | anchors.horizontalCenter: main.horizontalCenter | ||||
448 | | ||||
457 | horizontalAlignment: Text.AlignHCenter | 449 | horizontalAlignment: Text.AlignHCenter | ||
458 | verticalAlignment: Text.AlignVCenter | 450 | verticalAlignment: Text.AlignVCenter | ||
459 | } | 451 | } | ||
Context not available. | |||||
461 | Components.Label { | 453 | Components.Label { | ||
462 | id: sizehelper | 454 | id: sizehelper | ||
463 | 455 | | |||
456 | // will always get changed by states | ||||
457 | height: 1 | ||||
458 | width: 1 | ||||
459 | | ||||
464 | font.family: timeLabel.font.family | 460 | font.family: timeLabel.font.family | ||
465 | font.weight: timeLabel.font.weight | 461 | font.weight: timeLabel.font.weight | ||
466 | font.italic: timeLabel.font.italic | 462 | font.italic: timeLabel.font.italic | ||
467 | font.pointSize: 1024 | 463 | font.pointSize: 1024 | ||
464 | minimumPointSize: 1 | ||||
468 | 465 | | |||
469 | verticalAlignment: Text.AlignVCenter | 466 | verticalAlignment: Text.AlignVCenter | ||
470 | 467 | | |||
471 | visible: false | 468 | visible: false | ||
472 | } | 469 | } | ||
473 | 470 | | |||
471 | /* | ||||
472 | * end | ||||
473 | * | ||||
474 | */ | ||||
475 | | ||||
474 | FontMetrics { | 476 | FontMetrics { | ||
475 | id: timeMetrics | 477 | id: timeMetrics | ||
476 | 478 | | |||
add the following line here: mart: add the following line here:
font.pixelSize: 1024
it fixes the smallhorizontalpanel case for me | |||||
Context not available. | |||||
534 | if (main.tooSmall) { | 536 | if (main.tooSmall) { | ||
535 | dateLabelLeft.text = Qt.formatDate(main.currentTime, main.dateFormat); | 537 | dateLabelLeft.text = Qt.formatDate(main.currentTime, main.dateFormat); | ||
536 | } else { | 538 | } else { | ||
537 | dateLabel.text = Qt.formatDate(main.currentTime, main.dateFormat); | 539 | dateLabelUnder.text = Qt.formatDate(main.currentTime, main.dateFormat); | ||
538 | } | 540 | } | ||
539 | } else { | 541 | } else { | ||
540 | // clear it so it doesn't take space in the layout | 542 | // clear it so it doesn't take space in the layout | ||
541 | dateLabel.text = ""; | | |||
542 | dateLabelLeft.text = ""; | 543 | dateLabelLeft.text = ""; | ||
544 | dateLabelUnder.text = ""; | ||||
543 | } | 545 | } | ||
544 | 546 | | |||
545 | // find widest character between 0 and 9 | 547 | // find widest character between 0 and 9 | ||
Context not available. |
here you are comparing points and pixels