Changeset View
Changeset View
Standalone View
Standalone View
applets/digital-clock/package/contents/ui/DigitalClock.qml
Context not available. | |||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
---|---|---|---|---|---|
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.5 | 21 | import QtQuick 2.7 | ||
22 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
23 | import org.kde.plasma.core 2.0 as PlasmaCore | 23 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
24 | import org.kde.plasma.components 2.0 as Components | 24 | import org.kde.plasma.components 2.0 as Components | ||
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 oneLineMode: plasmoid.formFactor == PlasmaCore.Types.Horizontal && | ||
mart: here you are comparing points and pixels | |||||
58 | main.height <= 2 * theme.smallestFont.pixelSize | ||||
58 | 59 | | |||
59 | onDateFormatChanged: { | 60 | onDateFormatChanged: { | ||
60 | setupLabels(); | 61 | setupLabels(); | ||
Context not available. | |||||
87 | states: [ | 88 | states: [ | ||
88 | State { | 89 | State { | ||
89 | name: "horizontalPanel" | 90 | name: "horizontalPanel" | ||
90 | when: plasmoid.formFactor == PlasmaCore.Types.Horizontal && !main.tooSmall | 91 | when: plasmoid.formFactor == PlasmaCore.Types.Horizontal && !main.oneLineMode | ||
91 | 92 | | |||
92 | PropertyChanges { | 93 | PropertyChanges { | ||
93 | target: main | 94 | target: main | ||
94 | Layout.fillHeight: true | 95 | Layout.fillHeight: true | ||
95 | Layout.fillWidth: false | 96 | Layout.fillWidth: false | ||
96 | Layout.minimumWidth: Math.max(labelsFlow.width, dateLabel.paintedWidth) | 97 | Layout.minimumWidth: contentItem.width | ||
97 | Layout.maximumWidth: Layout.minimumWidth | 98 | Layout.maximumWidth: Layout.minimumWidth | ||
99 | } | ||||
100 | | ||||
101 | PropertyChanges { | ||||
102 | target: contentItem | ||||
98 | 103 | | |||
104 | height: timeLabel.height + (main.showDate || timezoneLabel.visible ? 0.8 * timeLabel.height : 0) | ||||
105 | width: Math.max(labelsGrid.width, dateLabel.paintedWidth) | ||||
106 | } | ||||
107 | | ||||
108 | PropertyChanges { | ||||
109 | target: labelsGrid | ||||
110 | | ||||
111 | rows: main.showDate ? 1 : 2 | ||||
112 | } | ||||
113 | | ||||
114 | AnchorChanges { | ||||
115 | target: labelsGrid | ||||
116 | | ||||
117 | anchors.horizontalCenter: contentItem.horizontalCenter | ||||
99 | } | 118 | } | ||
100 | 119 | | |||
101 | PropertyChanges { | 120 | PropertyChanges { | ||
102 | target: timeLabel | 121 | target: timeLabel | ||
103 | 122 | | |||
104 | height: sizehelper.height | 123 | height: sizehelper.height | ||
105 | width: sizehelper.width | 124 | width: sizehelper.contentWidth | ||
106 | 125 | | |||
107 | wrapMode: Text.NoWrap | 126 | font.pixelSize: timeLabel.height | ||
108 | fontSizeMode: Text.VerticalFit | | |||
109 | } | 127 | } | ||
110 | 128 | | |||
111 | PropertyChanges { | 129 | PropertyChanges { | ||
112 | target: timezoneLabel | 130 | target: timezoneLabel | ||
113 | 131 | | |||
114 | height: main.showDate ? timeLabel.height : Math.round(2 * (timeLabel.height / 3)) | 132 | height: main.showDate ? 0.7 * timeLabel.height : 0.8 * timeLabel.height | ||
115 | width: main.showDate ? timezoneLabel.paintedWidth : timeLabel.width | 133 | width: main.showDate ? timezoneLabel.paintedWidth : timeLabel.width | ||
116 | 134 | | |||
117 | fontSizeMode: Text.VerticalFit | 135 | font.pixelSize: timezoneLabel.height | ||
118 | minimumPointSize: 1 | | |||
119 | font.pointSize: 1024 | | |||
120 | elide: Text.ElideNone | | |||
121 | horizontalAlignment: Text.AlignHCenter | | |||
122 | } | 136 | } | ||
123 | 137 | | |||
124 | PropertyChanges { | 138 | PropertyChanges { | ||
125 | target: dateLabel | 139 | target: dateLabel | ||
126 | 140 | | |||
127 | height: Math.round(2 * (main.height / 5)) | 141 | height: 0.8 * timeLabel.height | ||
128 | width: dateLabel.paintedWidth | 142 | width: dateLabel.paintedWidth | ||
129 | 143 | | |||
130 | anchors.horizontalCenter: main.horizontalCenter | 144 | font.pixelSize: dateLabel.height | ||
131 | } | 145 | } | ||
132 | 146 | | |||
133 | PropertyChanges { | 147 | AnchorChanges { | ||
134 | target: labelsFlow | 148 | target: dateLabel | ||
135 | 149 | | |||
136 | flow: main.showDate ? Flow.LeftToRight : Flow.TopToBottom | 150 | anchors.top: labelsGrid.bottom | ||
151 | anchors.horizontalCenter: labelsGrid.horizontalCenter | ||||
137 | } | 152 | } | ||
138 | 153 | | |||
139 | PropertyChanges { | 154 | PropertyChanges { | ||
140 | target: sizehelper | 155 | target: sizehelper | ||
141 | 156 | | |||
142 | height: main.showDate || timezoneLabel.visible ? Math.round(3 * (main.height / 5)) : main.height | 157 | height: Math.min(main.showDate || timezoneLabel.visible ? 0.56 * main.height : main.height, 3 * theme.defaultFont.pixelSize) | ||
143 | width: sizehelper.paintedWidth | | |||
144 | 158 | | |||
145 | fontSizeMode: Text.VerticalFit | 159 | font.pixelSize: sizehelper.height | ||
146 | } | 160 | } | ||
147 | }, | 161 | }, | ||
148 | 162 | | |||
149 | State { | 163 | State { | ||
150 | name: "horizontalPanelSmall" | 164 | name: "horizontalPanelSmall" | ||
151 | when: plasmoid.formFactor == PlasmaCore.Types.Horizontal && main.tooSmall | 165 | when: plasmoid.formFactor == PlasmaCore.Types.Horizontal && main.oneLineMode | ||
152 | 166 | | |||
153 | PropertyChanges { | 167 | PropertyChanges { | ||
154 | target: main | 168 | target: main | ||
155 | Layout.fillHeight: true | 169 | Layout.fillHeight: true | ||
156 | Layout.fillWidth: false | 170 | Layout.fillWidth: false | ||
157 | Layout.minimumWidth: labelsFlow.width | 171 | Layout.minimumWidth: contentItem.width | ||
158 | Layout.maximumWidth: Layout.minimumWidth | 172 | Layout.maximumWidth: Layout.minimumWidth | ||
159 | 173 | | |||
160 | } | 174 | } | ||
161 | 175 | | |||
162 | PropertyChanges { | 176 | PropertyChanges { | ||
163 | target: timeLabel | 177 | target: contentItem | ||
164 | 178 | | |||
165 | height: sizehelper.height | 179 | height: sizehelper.height | ||
166 | width: sizehelper.width | 180 | width: dateLabel.width + dateLabel.anchors.rightMargin + labelsGrid.width | ||
181 | } | ||||
182 | | ||||
183 | AnchorChanges { | ||||
184 | target: labelsGrid | ||||
185 | | ||||
186 | anchors.right: contentItem.right | ||||
187 | } | ||||
188 | | ||||
189 | PropertyChanges { | ||||
190 | target: dateLabel | ||||
191 | | ||||
192 | height: timeLabel.height | ||||
193 | width: dateLabel.paintedWidth | ||||
194 | | ||||
195 | anchors.rightMargin: labelsGrid.columnSpacing | ||||
167 | 196 | | |||
168 | wrapMode: Text.NoWrap | | |||
169 | fontSizeMode: Text.VerticalFit | 197 | fontSizeMode: Text.VerticalFit | ||
170 | font.pointSize: theme.defaultFont.pointSize | 198 | } | ||
199 | | ||||
200 | AnchorChanges { | ||||
201 | target: dateLabel | ||||
202 | | ||||
203 | anchors.right: labelsGrid.left | ||||
204 | anchors.verticalCenter: labelsGrid.verticalCenter | ||||
171 | } | 205 | } | ||
172 | 206 | | |||
173 | PropertyChanges { | 207 | PropertyChanges { | ||
174 | target: timezoneLabel | 208 | target: timeLabel | ||
175 | 209 | | |||
176 | height: sizehelper.height | 210 | height: sizehelper.height | ||
177 | width: timezoneLabel.paintedWidth | 211 | width: sizehelper.contentWidth | ||
@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… | |||||
178 | 212 | | |||
179 | fontSizeMode: Text.VerticalFit | 213 | fontSizeMode: Text.VerticalFit | ||
180 | minimumPointSize: 1 | | |||
181 | font.pointSize: theme.defaultFont.pointSize | | |||
182 | elide: Text.ElideNone | | |||
183 | horizontalAlignment: Text.AlignHCenter | | |||
184 | } | 214 | } | ||
185 | 215 | | |||
186 | PropertyChanges { | 216 | PropertyChanges { | ||
187 | target: labelsFlow | 217 | target: timezoneLabel | ||
188 | 218 | | |||
189 | flow: Flow.LeftToRight | 219 | height: 0.7 * timeLabel.height | ||
220 | width: timezoneLabel.paintedWidth | ||||
221 | | ||||
222 | fontSizeMode: Text.VerticalFit | ||||
223 | horizontalAlignment: Text.AlignHCenter | ||||
190 | } | 224 | } | ||
191 | 225 | | |||
192 | PropertyChanges { | 226 | PropertyChanges { | ||
193 | target: sizehelper | 227 | target: sizehelper | ||
194 | 228 | | |||
195 | height: main.height | 229 | height: Math.min(main.height, 3 * theme.defaultFont.pixelSize) | ||
196 | width: sizehelper.paintedWidth | | |||
197 | 230 | | |||
198 | fontSizeMode: Text.VerticalFit | 231 | fontSizeMode: Text.VerticalFit | ||
199 | } | 232 | } | ||
Context not available. | |||||
207 | target: main | 240 | target: main | ||
208 | Layout.fillHeight: false | 241 | Layout.fillHeight: false | ||
209 | Layout.fillWidth: true | 242 | Layout.fillWidth: true | ||
210 | Layout.maximumHeight: main.showDate ? labelsFlow.height + dateLabel.height : labelsFlow.height | 243 | Layout.maximumHeight: contentItem.height | ||
211 | Layout.minimumHeight: Layout.maximumHeight | 244 | Layout.minimumHeight: Layout.maximumHeight | ||
212 | } | 245 | } | ||
213 | 246 | | |||
214 | PropertyChanges { | 247 | PropertyChanges { | ||
248 | target: contentItem | ||||
249 | | ||||
250 | height: main.showDate ? labelsGrid.height + dateLabel.height : labelsGrid.height | ||||
251 | width: main.width | ||||
252 | } | ||||
253 | | ||||
254 | PropertyChanges { | ||||
255 | target: labelsGrid | ||||
256 | | ||||
257 | rows: 2 | ||||
258 | } | ||||
259 | | ||||
260 | PropertyChanges { | ||||
215 | target: timeLabel | 261 | target: timeLabel | ||
216 | 262 | | |||
217 | height: sizehelper.height | 263 | height: sizehelper.contentHeight | ||
218 | width: sizehelper.width | 264 | width: main.width | ||
219 | minimumPointSize: 0 | | |||
220 | 265 | | |||
266 | font.pixelSize: Math.min(timeLabel.height, 3 * theme.defaultFont.pixelSize) | ||||
221 | fontSizeMode: Text.HorizontalFit | 267 | fontSizeMode: Text.HorizontalFit | ||
222 | } | 268 | } | ||
223 | 269 | | |||
224 | PropertyChanges { | 270 | PropertyChanges { | ||
225 | target: timezoneLabel | 271 | target: timezoneLabel | ||
226 | 272 | | |||
227 | height: Math.max(sizehelper.lineCount > 1 ? 2 * Math.round(timeLabel.height / 6) : 2 * Math.round(timeLabel.height / 3), theme.smallestFont.pixelSize) | 273 | height: Math.max(0.7 * timeLabel.height, minimumPixelSize) | ||
228 | width: main.width | 274 | width: main.width | ||
229 | 275 | | |||
230 | fontSizeMode: Text.HorizontalFit | 276 | fontSizeMode: Text.Fit | ||
231 | minimumPointSize: 0 | 277 | minimumPixelSize: dateLabel.minimumPixelSize | ||
232 | elide: Text.ElideRight | 278 | elide: Text.ElideRight | ||
233 | } | 279 | } | ||
234 | 280 | | |||
235 | PropertyChanges { | 281 | PropertyChanges { | ||
236 | target: dateLabel | 282 | target: dateLabel | ||
237 | 283 | | |||
238 | height: timezoneLabel.height | 284 | // this can be marginal bigger than contentHeight because of the horizontal fit | ||
239 | width: timezoneLabel.width | 285 | height: Math.max(0.8 * timeLabel.height, minimumPixelSize) | ||
286 | width: main.width | ||||
240 | 287 | | |||
241 | fontSizeMode: Text.HorizontalFit | 288 | fontSizeMode: Text.Fit | ||
242 | minimumPointSize: 0 | 289 | minimumPixelSize: Math.min(0.7 * theme.smallestFont.pixelSize, timeLabel.height) | ||
243 | elide: Text.ElideRight | 290 | elide: Text.ElideRight | ||
244 | } | 291 | } | ||
245 | 292 | | |||
293 | AnchorChanges { | ||||
294 | target: dateLabel | ||||
295 | | ||||
296 | anchors.top: labelsGrid.bottom | ||||
297 | anchors.horizontalCenter: labelsGrid.horizontalCenter | ||||
298 | } | ||||
299 | | ||||
246 | PropertyChanges { | 300 | PropertyChanges { | ||
247 | target: sizehelper | 301 | target: sizehelper | ||
248 | 302 | | |||
249 | height: sizehelper.paintedHeight | | |||
250 | width: main.width | 303 | width: main.width | ||
251 | 304 | | |||
252 | minimumPointSize: 0 | | |||
253 | | ||||
254 | fontSizeMode: Text.HorizontalFit | 305 | fontSizeMode: Text.HorizontalFit | ||
255 | horizontalAlignment: Text.AlignHCenter | 306 | font.pixelSize: 3 * theme.defaultFont.pixelSize | ||
256 | wrapMode: Text.WordWrap | 307 | minimumPixelSize: 1 | ||
257 | } | 308 | } | ||
258 | }, | 309 | }, | ||
259 | 310 | | |||
Context not available. | |||||
266 | Layout.fillHeight: false | 317 | Layout.fillHeight: false | ||
267 | Layout.fillWidth: false | 318 | Layout.fillWidth: false | ||
268 | Layout.minimumWidth: units.gridUnit * 3 | 319 | Layout.minimumWidth: units.gridUnit * 3 | ||
269 | Layout.maximumWidth: Math.max(labelsFlow.width, dateLabel.width) | | |||
270 | Layout.minimumHeight: units.gridUnit * 3 | 320 | Layout.minimumHeight: units.gridUnit * 3 | ||
271 | Layout.maximumHeight: main.showDate ? labelsFlow.height + dateLabel.height : labelsFlow.height | 321 | } | ||
322 | | ||||
323 | PropertyChanges { | ||||
324 | target: contentItem | ||||
325 | | ||||
326 | height: main.height | ||||
327 | width: main.width | ||||
328 | } | ||||
329 | | ||||
330 | PropertyChanges { | ||||
331 | target: labelsGrid | ||||
332 | | ||||
333 | rows: 2 | ||||
272 | } | 334 | } | ||
273 | 335 | | |||
274 | PropertyChanges { | 336 | PropertyChanges { | ||
Context not available. | |||||
277 | height: sizehelper.height | 339 | height: sizehelper.height | ||
278 | width: main.width | 340 | width: main.width | ||
279 | 341 | | |||
280 | wrapMode: Text.NoWrap | | |||
281 | fontSizeMode: Text.Fit | 342 | fontSizeMode: Text.Fit | ||
282 | } | 343 | } | ||
283 | 344 | | |||
284 | PropertyChanges { | 345 | PropertyChanges { | ||
285 | target: timezoneLabel | 346 | target: timezoneLabel | ||
286 | 347 | | |||
287 | height: dateLabel.visible ? Math.round(1 * (main.height / 5)) : Math.round(2 * (main.height / 5)) | 348 | height: 0.7 * timeLabel.height | ||
288 | width: main.width | 349 | width: Math.max(timeLabel.contentWidth, units.gridUnit * 3) | ||
289 | 350 | | |||
290 | fontSizeMode: Text.Fit | 351 | fontSizeMode: Text.Fit | ||
291 | minimumPixelSize: 0 | 352 | minimumPixelSize: 1 | ||
292 | elide: Text.ElideRight | | |||
293 | } | 353 | } | ||
294 | 354 | | |||
295 | PropertyChanges { | 355 | PropertyChanges { | ||
296 | target: dateLabel | 356 | target: dateLabel | ||
297 | 357 | | |||
298 | height: timezoneLabel.visible ? Math.round(1 * (main.height / 5)) : Math.round(2 * (main.height / 5)) | 358 | height: 0.8 * timeLabel.height | ||
299 | width: main.width | 359 | width: Math.max(timeLabel.contentWidth, units.gridUnit * 3) | ||
300 | 360 | | |||
301 | anchors.horizontalCenter: main.horizontalCenter | | |||
302 | fontSizeMode: Text.Fit | 361 | fontSizeMode: Text.Fit | ||
362 | minimumPixelSize: 1 | ||||
363 | } | ||||
364 | | ||||
365 | AnchorChanges { | ||||
366 | target: dateLabel | ||||
367 | | ||||
368 | anchors.top: labelsGrid.bottom | ||||
369 | anchors.horizontalCenter: labelsGrid.horizontalCenter | ||||
303 | } | 370 | } | ||
304 | 371 | | |||
305 | PropertyChanges { | 372 | PropertyChanges { | ||
306 | target: sizehelper | 373 | target: sizehelper | ||
307 | 374 | | |||
308 | height: main.showDate || timezoneLabel.visible ? Math.round(3 * (main.height / 5)) : main.height | 375 | height: { | ||
376 | if (main.showDate) { | ||||
377 | if (timezoneLabel.visible) { | ||||
378 | return 0.4 * main.height | ||||
379 | } | ||||
380 | return 0.56 * main.height | ||||
381 | } else if (timezoneLabel.visible) { | ||||
382 | return 0.59 * main.height | ||||
383 | } | ||||
384 | return main.height | ||||
385 | } | ||||
309 | width: main.width | 386 | width: main.width | ||
310 | 387 | | |||
311 | fontSizeMode: Text.Fit | 388 | fontSizeMode: Text.Fit | ||
312 | } | 389 | } | ||
313 | } | 390 | } | ||
314 | | ||||
315 | ] | 391 | ] | ||
316 | 392 | | |||
317 | MouseArea { | 393 | MouseArea { | ||
Context not available. | |||||
357 | } | 433 | } | ||
358 | } | 434 | } | ||
359 | 435 | | |||
360 | Flow { | 436 | /* | ||
361 | id: labelsFlow | 437 | * Visible elements | ||
362 | 438 | * | |||
363 | anchors.horizontalCenter: main.horizontalCenter | 439 | */ | ||
364 | 440 | | |||
365 | flow: Flow.TopToBottom | 441 | Item { | ||
366 | spacing: flow == Flow.LeftToRight && (timezoneLabel.visible || main.tooSmall) ? units.smallSpacing : 0 | 442 | id: contentItem | ||
443 | anchors.verticalCenter: main.verticalCenter | ||||
367 | 444 | | |||
368 | Components.Label { | 445 | Grid { | ||
369 | id: dateLabelLeft | 446 | id: labelsGrid | ||
370 | 447 | | |||
371 | height: sizehelper.height | 448 | rows: 1 | ||
372 | visible: main.showDate && main.tooSmall | 449 | horizontalItemAlignment: Grid.AlignHCenter | ||
450 | verticalItemAlignment: Grid.AlignVCenter | ||||
373 | 451 | | |||
374 | font { | 452 | flow: Grid.TopToBottom | ||
375 | weight: timeLabel.font.weight | 453 | columnSpacing: units.smallSpacing | ||
376 | italic: timeLabel.font.italic | | |||
377 | pointSize: theme.defaultFont.pointSize | | |||
378 | } | | |||
379 | minimumPixelSize: 0 | | |||
380 | | ||||
381 | fontSizeMode: Text.VerticalFit | | |||
382 | | ||||
383 | horizontalAlignment: Text.AlignHCenter | | |||
384 | verticalAlignment: Text.AlignVCenter | | |||
385 | } | | |||
386 | | ||||
387 | Item { | | |||
388 | height: dateLabelLeft.height | | |||
389 | width: 1 | | |||
390 | visible: main.showDate && main.tooSmall | | |||
391 | 454 | | |||
392 | Rectangle { | 455 | Rectangle { | ||
393 | id: delimiter | 456 | height: 0.8 * sizehelper.height | ||
394 | | ||||
395 | height: dateLabelLeft.font.pixelSize | | |||
396 | width: 1 | 457 | width: 1 | ||
397 | anchors.verticalCenter: parent.verticalCenter | 458 | visible: main.showDate && main.oneLineMode | ||
398 | 459 | | |||
399 | color: theme.textColor | 460 | color: theme.textColor | ||
400 | opacity: 0.4 | 461 | opacity: 0.4 | ||
401 | } | 462 | } | ||
402 | } | | |||
403 | 463 | | |||
404 | Components.Label { | 464 | Components.Label { | ||
405 | id: timeLabel | 465 | id: timeLabel | ||
406 | 466 | | |||
407 | font { | 467 | font { | ||
408 | family: plasmoid.configuration.fontFamily || theme.defaultFont.family | 468 | family: plasmoid.configuration.fontFamily || theme.defaultFont.family | ||
409 | weight: plasmoid.configuration.boldText ? Font.Bold : theme.defaultFont.weight | 469 | weight: plasmoid.configuration.boldText ? Font.Bold : theme.defaultFont.weight | ||
410 | italic: plasmoid.configuration.italicText | 470 | italic: plasmoid.configuration.italicText | ||
411 | pointSize: 1024 | 471 | pixelSize: 1024 | ||
412 | } | 472 | } | ||
473 | minimumPixelSize: 1 | ||||
474 | | ||||
475 | text: { | ||||
476 | // get the time for the given timezone from the dataengine | ||||
477 | var now = dataSource.data[plasmoid.configuration.lastSelectedTimezone]["DateTime"]; | ||||
478 | // get current UTC time | ||||
479 | var msUTC = now.getTime() + (now.getTimezoneOffset() * 60000); | ||||
480 | // add the dataengine TZ offset to it | ||||
481 | var currentTime = new Date(msUTC + (dataSource.data[plasmoid.configuration.lastSelectedTimezone]["Offset"] * 1000)); | ||||
413 | 482 | | |||
414 | text: { | 483 | main.currentTime = currentTime; | ||
415 | // get the time for the given timezone from the dataengine | 484 | return Qt.formatTime(currentTime, main.timeFormat); | ||
416 | var now = dataSource.data[plasmoid.configuration.lastSelectedTimezone]["DateTime"]; | 485 | } | ||
417 | // get current UTC time | | |||
418 | var msUTC = now.getTime() + (now.getTimezoneOffset() * 60000); | | |||
419 | // add the dataengine TZ offset to it | | |||
420 | var currentTime = new Date(msUTC + (dataSource.data[plasmoid.configuration.lastSelectedTimezone]["Offset"] * 1000)); | | |||
421 | 486 | | |||
422 | main.currentTime = currentTime; | 487 | verticalAlignment: Text.AlignVCenter | ||
423 | return Qt.formatTime(currentTime, main.timeFormat); | 488 | horizontalAlignment: Text.AlignHCenter | ||
424 | } | 489 | } | ||
425 | 490 | | |||
426 | verticalAlignment: Text.AlignVCenter | 491 | Components.Label { | ||
427 | horizontalAlignment: Text.AlignHCenter | 492 | id: timezoneLabel | ||
493 | | ||||
494 | font.weight: timeLabel.font.weight | ||||
495 | font.italic: timeLabel.font.italic | ||||
496 | font.pixelSize: 1024 | ||||
497 | minimumPixelSize: 1 | ||||
498 | | ||||
499 | visible: text.length > 0 | ||||
500 | horizontalAlignment: Text.AlignHCenter | ||||
501 | verticalAlignment: Text.AlignVCenter | ||||
502 | } | ||||
428 | } | 503 | } | ||
429 | 504 | | |||
430 | Components.Label { | 505 | Components.Label { | ||
431 | id: timezoneLabel | 506 | id: dateLabel | ||
432 | 507 | | |||
508 | visible: main.showDate | ||||
509 | | ||||
510 | font.family: timeLabel.font.family | ||||
433 | font.weight: timeLabel.font.weight | 511 | font.weight: timeLabel.font.weight | ||
434 | font.italic: timeLabel.font.italic | 512 | font.italic: timeLabel.font.italic | ||
435 | font.pointSize: 1024 | 513 | font.pixelSize: 1024 | ||
436 | minimumPixelSize: 0 | 514 | minimumPixelSize: 1 | ||
437 | 515 | | |||
438 | visible: text.length > 0 | | |||
439 | horizontalAlignment: Text.AlignHCenter | 516 | horizontalAlignment: Text.AlignHCenter | ||
517 | verticalAlignment: Text.AlignVCenter | ||||
440 | } | 518 | } | ||
441 | } | 519 | } | ||
442 | 520 | /* | |||
443 | Components.Label { | 521 | * end | ||
444 | id: dateLabel | 522 | * | ||
445 | 523 | */ | |||
446 | anchors.top: labelsFlow.bottom | | |||
447 | visible: main.showDate && !main.tooSmall | | |||
448 | | ||||
449 | font.family: timeLabel.font.family | | |||
450 | font.weight: timeLabel.font.weight | | |||
451 | font.italic: timeLabel.font.italic | | |||
452 | font.pointSize: 1024 | | |||
453 | minimumPixelSize: 0 | | |||
454 | | ||||
455 | fontSizeMode: Text.VerticalFit | | |||
456 | | ||||
457 | horizontalAlignment: Text.AlignHCenter | | |||
458 | verticalAlignment: Text.AlignVCenter | | |||
459 | } | | |||
460 | 524 | | |||
461 | Components.Label { | 525 | Components.Label { | ||
462 | id: sizehelper | 526 | id: sizehelper | ||
Context not available. | |||||
464 | font.family: timeLabel.font.family | 528 | font.family: timeLabel.font.family | ||
465 | font.weight: timeLabel.font.weight | 529 | font.weight: timeLabel.font.weight | ||
466 | font.italic: timeLabel.font.italic | 530 | font.italic: timeLabel.font.italic | ||
467 | font.pointSize: 1024 | 531 | minimumPixelSize: 1 | ||
add the following line here: mart: add the following line here:
font.pixelSize: 1024
it fixes the smallhorizontalpanel case for me | |||||
468 | | ||||
469 | verticalAlignment: Text.AlignVCenter | | |||
470 | 532 | | |||
471 | visible: false | 533 | visible: false | ||
472 | } | 534 | } | ||
Context not available. | |||||
523 | if (showTimezone) { | 585 | if (showTimezone) { | ||
524 | timezoneString = plasmoid.configuration.displayTimezoneAsCode ? dataSource.data[plasmoid.configuration.lastSelectedTimezone]["Timezone Abbreviation"] | 586 | timezoneString = plasmoid.configuration.displayTimezoneAsCode ? dataSource.data[plasmoid.configuration.lastSelectedTimezone]["Timezone Abbreviation"] | ||
525 | : TimezonesI18n.i18nCity(dataSource.data[plasmoid.configuration.lastSelectedTimezone]["Timezone City"]); | 587 | : TimezonesI18n.i18nCity(dataSource.data[plasmoid.configuration.lastSelectedTimezone]["Timezone City"]); | ||
526 | timezoneLabel.text = (main.showDate || main.tooSmall) && plasmoid.formFactor == PlasmaCore.Types.Horizontal ? "(" + timezoneString + ")" : timezoneString; | 588 | timezoneLabel.text = (main.showDate || main.oneLineMode) && plasmoid.formFactor == PlasmaCore.Types.Horizontal ? "(" + timezoneString + ")" : timezoneString; | ||
527 | } else { | 589 | } else { | ||
528 | // this clears the label and that makes it hidden | 590 | // this clears the label and that makes it hidden | ||
529 | timezoneLabel.text = timezoneString; | 591 | timezoneLabel.text = timezoneString; | ||
Context not available. | |||||
531 | 593 | | |||
532 | 594 | | |||
533 | if (main.showDate) { | 595 | if (main.showDate) { | ||
534 | if (main.tooSmall) { | 596 | dateLabel.text = Qt.formatDate(main.currentTime, main.dateFormat); | ||
535 | dateLabelLeft.text = Qt.formatDate(main.currentTime, main.dateFormat); | | |||
536 | } else { | | |||
537 | dateLabel.text = Qt.formatDate(main.currentTime, main.dateFormat); | | |||
538 | } | | |||
539 | } else { | 597 | } else { | ||
540 | // clear it so it doesn't take space in the layout | 598 | // clear it so it doesn't take space in the layout | ||
541 | dateLabel.text = ""; | 599 | dateLabel.text = ""; | ||
542 | dateLabelLeft.text = ""; | | |||
543 | } | 600 | } | ||
544 | 601 | | |||
545 | // find widest character between 0 and 9 | 602 | // find widest character between 0 and 9 | ||
Context not available. |
here you are comparing points and pixels