CalendarView.qml 24.5 KB
Newer Older
1
/*
2
3
4
5
6
7
    SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
    SPDX-FileCopyrightText: 2015 Martin Klapetek <mklapetek@kde.org>
    SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>

    SPDX-License-Identifier: GPL-2.0-or-later
*/
8
import QtQuick 2.4
9
import QtQuick.Layouts 1.1
Konrad Materka's avatar
Konrad Materka committed
10
import QtQml 2.15
11
12

import org.kde.kquickcontrolsaddons 2.0 // For kcmshell
13
14
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.calendar 2.0 as PlasmaCalendar
15
import org.kde.plasma.components 3.0 as PlasmaComponents3
16
import org.kde.plasma.extras 2.0 as PlasmaExtras
Carl Schwan's avatar
Carl Schwan committed
17
import org.kde.plasma.private.digitalclock 1.0
18

Carl Schwan's avatar
Carl Schwan committed
19
20
21
22
// Top-level layout containing:
// - Left column with world clock and agenda view
// - Right column with current date header and calendar
PlasmaExtras.Representation {
23
24
    id: calendar

25
    // The "sensible" values
Carl Schwan's avatar
Carl Schwan committed
26
27
    property int _minimumWidth: (calendar.showAgenda || calendar.showClocks) ? PlasmaCore.Units.gridUnit * 45 : PlasmaCore.Units.gridUnit * 22
    property int _minimumHeight: PlasmaCore.Units.gridUnit * 25
28

29
30
31
    PlasmaCore.ColorScope.inherit: false
    PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.NormalColorGroup

32
33
34
    Layout.minimumWidth: _minimumWidth
    Layout.minimumHeight: _minimumHeight
    Layout.preferredWidth: _minimumWidth
35
36
37
    Layout.preferredHeight: _minimumHeight
    Layout.maximumWidth: _minimumWidth
    Layout.maximumHeight: _minimumHeight
38

Carl Schwan's avatar
Carl Schwan committed
39
40
    collapseMarginsHint: true

Nate Graham's avatar
Nate Graham committed
41
    readonly property int paddings: PlasmaCore.Units.smallSpacing
42
    readonly property bool showAgenda: PlasmaCalendar.EventPluginsManager.enabledPlugins.length > 0
43
    readonly property bool showClocks: plasmoid.configuration.selectedTimeZones.length > 1
44

45
46
47
48
49
    property alias borderWidth: monthView.borderWidth
    property alias monthView: monthView

    property bool debug: false

50
51
52
    property bool isExpanded: plasmoid.expanded

    onIsExpandedChanged: {
53
54
        // clear all the selections when the plasmoid is showing/hiding
        monthView.resetToToday();
55
56
    }

57
58
59
    // Header containing date and pin button
    header: PlasmaExtras.PlasmoidHeading {
        id: headerArea
Carl Schwan's avatar
Carl Schwan committed
60
        implicitHeight: calendarHeader.implicitHeight
61

Carl Schwan's avatar
Carl Schwan committed
62
63
64
65
        // Agenda view header
        // -----------------
        ColumnLayout {
            id: eventHeader
66
67

            anchors.left: parent.left
Carl Schwan's avatar
Carl Schwan committed
68
            width: visible ? parent.width / 2 - 1 : 0
69

Carl Schwan's avatar
Carl Schwan committed
70
71
72
73
74
            visible: calendar.showAgenda || calendar.showClocks
            RowLayout {
                PlasmaExtras.Heading {
                    Layout.fillWidth: true
                    Layout.leftMargin: calendar.paddings // Match calendar title
75

Carl Schwan's avatar
Carl Schwan committed
76
77
78
                    text: monthView.currentDate.toLocaleDateString(Qt.locale(), Locale.LongFormat)
                }
            }
Carl Schwan's avatar
Carl Schwan committed
79
80
81
82
            RowLayout {
                // Heading text
                PlasmaExtras.Heading {
                    visible: agenda.visible
Carl Schwan's avatar
Carl Schwan committed
83

Carl Schwan's avatar
Carl Schwan committed
84
85
                    Layout.fillWidth: true
                    Layout.leftMargin: calendar.paddings
86

Carl Schwan's avatar
Carl Schwan committed
87
                    level: 2
88

Carl Schwan's avatar
Carl Schwan committed
89
90
91
92
93
94
                    text: i18n("Events")
                    maximumLineCount: 1
                    elide: Text.ElideRight
                }
                PlasmaComponents3.ToolButton {
                    visible: agenda.visible && ApplicationIntegration.korganizerInstalled
95
                    text: i18nc("@action:button Add event", "Add…")
Carl Schwan's avatar
Carl Schwan committed
96
97
98
99
                    Layout.rightMargin: calendar.paddings
                    icon.name: "list-add"
                    onClicked: ApplicationIntegration.launchKorganizer()
                }
Carl Schwan's avatar
Carl Schwan committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
            }
        }

        // Vertical separator line between columns
        // =======================================
        PlasmaCore.SvgItem {
            id: headerSeparator
            anchors.left: eventHeader.right
            anchors.bottomMargin: PlasmaCore.Units.smallSpacing * 2
            width: visible ? 1 : 0
            height: calendarHeader.height - PlasmaCore.Units.smallSpacing * 2
            visible: eventHeader.visible

            elementId: "vertical-line"
            svg: PlasmaCore.Svg {
                imagePath: "widgets/line"
            }
        }

        GridLayout {
            id: calendarHeader
            width: calendar.showAgenda || calendar.showClocks ? parent.width / 2 : parent.width
            anchors.left: headerSeparator.right
            columns: 6
            rows: 2

            PlasmaExtras.Heading {
                Layout.row: 0
                Layout.column: 0
                Layout.columnSpan: 3
                Layout.fillWidth: true
                Layout.leftMargin: calendar.paddings + PlasmaCore.Units.smallSpacing
                text: monthView.selectedYear === (new Date()).getFullYear() ? monthView.selectedMonth : i18nc("Format: month year", "%1 %2", monthView.selectedMonth, monthView.selectedYear.toString())
133
            }
134
135

            PlasmaComponents3.ToolButton {
Carl Schwan's avatar
Carl Schwan committed
136
137
138
                Layout.row: 0
                Layout.column: 4
                Layout.alignment: Qt.AlignRight
139
140
141
142
143
144
145
146
                visible: plasmoid.action("configure").enabled
                icon.name: "configure"
                onClicked: plasmoid.action("configure").trigger()
                PlasmaComponents3.ToolTip {
                    text: plasmoid.action("configure").text
                }
            }

147
148
            // Allows the user to keep the calendar open for reference
            PlasmaComponents3.ToolButton {
Carl Schwan's avatar
Carl Schwan committed
149
150
                Layout.row: 0
                Layout.column: 5
151
152
153
154
155
156
157
158
                checkable: true
                checked: plasmoid.configuration.pin
                onToggled: plasmoid.configuration.pin = checked
                icon.name: "window-pin"
                PlasmaComponents3.ToolTip {
                    text: i18n("Keep Open")
                }
            }
Carl Schwan's avatar
Carl Schwan committed
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247

            PlasmaComponents3.TabBar {
                id: tabbar
                currentIndex: monthView.currentIndex
                Layout.row: 1
                Layout.column: 0
                Layout.columnSpan: 3
                Layout.topMargin: PlasmaCore.Units.smallSpacing
                Layout.fillWidth: true
                Layout.leftMargin: PlasmaCore.Units.smallSpacing

                PlasmaComponents3.TabButton {
                    text: i18n("Days");
                    onClicked: monthView.showMonthView();
                    display: PlasmaComponents3.AbstractButton.TextOnly
                }
                PlasmaComponents3.TabButton {
                    text: i18n("Months");
                    onClicked: monthView.showYearView();
                    display: PlasmaComponents3.AbstractButton.TextOnly
                }
                PlasmaComponents3.TabButton {
                    text: i18n("Years");
                    onClicked: monthView.showDecadeView();
                    display: PlasmaComponents3.AbstractButton.TextOnly
                }
            }

            PlasmaComponents3.ToolButton {
                id: previousButton
                property string tooltip
                Layout.row: 1
                Layout.column: 3

                Layout.leftMargin: PlasmaCore.Units.smallSpacing
                Layout.bottomMargin: PlasmaCore.Units.smallSpacing
                icon.name: Qt.application.layoutDirection === Qt.RightToLeft ? "go-next" : "go-previous"
                onClicked: monthView.previousView()
                Accessible.name: tooltip
                PlasmaComponents3.ToolTip {
                    text: {
                        switch(monthView.calendarViewDisplayed) {
                            case PlasmaCalendar.MonthView.CalendarView.DayView:
                                return i18n("Previous month")
                            case PlasmaCalendar.MonthView.CalendarView.MonthView:
                                return i18n("Previous year")
                            case PlasmaCalendar.MonthView.CalendarView.YearView:
                                return i18n("Previous decade")
                            default:
                                return "";
                        }
                    }
                }
            }

            PlasmaComponents3.ToolButton {
                Layout.bottomMargin: PlasmaCore.Units.smallSpacing
                Layout.row: 1
                Layout.column: 4
                onClicked: monthView.resetToToday()
                text: i18ndc("libplasma5", "Reset calendar to today", "Today")
                Accessible.description: i18nd("libplasma5", "Reset calendar to today")
            }

            PlasmaComponents3.ToolButton {
                id: nextButton
                property string tooltip
                Layout.bottomMargin: PlasmaCore.Units.smallSpacing
                Layout.row: 1
                Layout.column: 5

                icon.name: Qt.application.layoutDirection === Qt.RightToLeft ? "go-previous" : "go-next"
                onClicked: monthView.nextView()
                Accessible.name: tooltip
                PlasmaComponents3.ToolTip {
                    text: {
                        switch(monthView.calendarViewDisplayed) {
                            case PlasmaCalendar.MonthView.CalendarView.DayView:
                                return i18n("Next month")
                            case PlasmaCalendar.MonthView.CalendarView.MonthView:
                                return i18n("Next year")
                            case PlasmaCalendar.MonthView.CalendarView.YearView:
                                return i18n("Next decade")
                            default:
                                return "";
                        }
                    }
                }
            }
248
249
        }
    }
250

Carl Schwan's avatar
Carl Schwan committed
251
252
253
254
255
256
257
    // Left column containing agenda view and time zones
    // ==================================================
    ColumnLayout {
        id: leftColumn

        visible: calendar.showAgenda || calendar.showClocks
        width: parent.width / 2 - 1
258
259
        anchors {
            left: parent.left
Carl Schwan's avatar
Carl Schwan committed
260
261
            top: parent.top
            bottom: parent.bottom
262
263
        }

264

Carl Schwan's avatar
Carl Schwan committed
265
        // Agenda view itself
266
        Item {
Carl Schwan's avatar
Carl Schwan committed
267
268
269
            id: agenda
            visible: calendar.showAgenda

270
            Layout.fillWidth: true
Carl Schwan's avatar
Carl Schwan committed
271
272
273
274
275
276
277
278
279
280
281
282
            Layout.fillHeight: true
            Layout.minimumHeight: PlasmaCore.Units.gridUnit * 4

            function formatDateWithoutYear(date) {
                // Unfortunatelly Qt overrides ECMA's Date.toLocaleDateString(),
                // which is able to return locale-specific date-and-month-only date
                // formats, with its dumb version that only supports Qt::DateFormat
                // enum subset. So to get a day-and-month-only date format string we
                // must resort to this magic and hope there are no locales that use
                // other separators...
                var format = Qt.locale().dateFormat(Locale.ShortFormat).replace(/[./ ]*Y{2,4}[./ ]*/i, '');
                return Qt.formatDate(date, format);
283
            }
284

Carl Schwan's avatar
Carl Schwan committed
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
            function dateEquals(date1, date2) {
                const values1 = [
                    date1.getFullYear(),
                    date1.getMonth(),
                    date1.getDate()
                ];

                const values2 = [
                    date2.getFullYear(),
                    date2.getMonth(),
                    date2.getDate()
                ];

                return values1.every((value, index) => {
                    return (value === values2[index]);
                }, false)
            }
302

Carl Schwan's avatar
Carl Schwan committed
303
304
305
306
307
308
309
310
311
312
313
314
315
            Connections {
                target: monthView

                function onCurrentDateChanged() {
                    // Apparently this is needed because this is a simple QList being
                    // returned and if the list for the current day has 1 event and the
                    // user clicks some other date which also has 1 event, QML sees the
                    // sizes match and does not update the labels with the content.
                    // Resetting the model to null first clears it and then correct data
                    // are displayed.
                    holidaysList.model = null;
                    holidaysList.model = monthView.daysModel.eventsForDate(monthView.currentDate);
                }
316
317
            }

Carl Schwan's avatar
Carl Schwan committed
318
319
            Connections {
                target: monthView.daysModel
320

Carl Schwan's avatar
Carl Schwan committed
321
322
323
324
325
326
327
                function onAgendaUpdated(updatedDate) {
                    if (agenda.dateEquals(updatedDate, monthView.currentDate)) {
                        holidaysList.model = null;
                        holidaysList.model = monthView.daysModel.eventsForDate(monthView.currentDate);
                    }
                }
            }
328

Carl Schwan's avatar
Carl Schwan committed
329
330
            Connections {
                target: plasmoid.configuration
331

Carl Schwan's avatar
Carl Schwan committed
332
333
334
335
                onEnabledCalendarPluginsChanged: {
                    PlasmaCalendar.EventPluginsManager.enabledPlugins = plasmoid.configuration.enabledCalendarPlugins;
                }
            }
336

Carl Schwan's avatar
Carl Schwan committed
337
338
339
340
341
342
            Binding {
                target: plasmoid
                property: "hideOnWindowDeactivate"
                value: !plasmoid.configuration.pin
                restoreMode: Binding.RestoreBinding
            }
343

Carl Schwan's avatar
Carl Schwan committed
344
345
            TextMetrics {
                id: dateLabelMetrics
346

Carl Schwan's avatar
Carl Schwan committed
347
348
349
                // Date/time are arbitrary values with all parts being two-digit
                readonly property string timeString: Qt.formatTime(new Date(2000, 12, 12, 12, 12, 12, 12))
                readonly property string dateString: agenda.formatDateWithoutYear(new Date(2000, 12, 12, 12, 12, 12))
350

Carl Schwan's avatar
Carl Schwan committed
351
352
                font: PlasmaCore.Theme.defaultFont
                text: timeString.length > dateString.length ? timeString : dateString
353
            }
354

Carl Schwan's avatar
Carl Schwan committed
355
356
357
            PlasmaComponents3.ScrollView {
                id: holidaysView
                anchors.fill: parent
358

Carl Schwan's avatar
Carl Schwan committed
359
360
361
                ListView {
                    id: holidaysList
                    highlight: Item {}
362

Carl Schwan's avatar
Carl Schwan committed
363
364
365
366
367
368
                    delegate: PlasmaComponents3.ItemDelegate {
                        id: eventItem
                        width: holidaysList.width
                        padding: calendar.paddings
                        leftPadding: calendar.paddings + PlasmaCore.Units.smallSpacing * 2
                        text: eventTitle.text
369
                        hoverEnabled: true
Carl Schwan's avatar
Carl Schwan committed
370
371
372
373
374
375
376
377
378
379
380
                        property bool hasTime: {
                            // Explicitly all-day event
                            if (modelData.isAllDay) {
                                return false;
                            }
                            // Multi-day event which does not start or end today (so
                            // is all-day from today's point of view)
                            if (modelData.startDateTime - monthView.currentDate < 0 &&
                                modelData.endDateTime - monthView.currentDate > 86400000) { // 24hrs in ms
                                return false;
                            }
381

Carl Schwan's avatar
Carl Schwan committed
382
383
384
                            // Non-explicit all-day event
                            const startIsMidnight = modelData.startDateTime.getHours() === 0
                                            && modelData.startDateTime.getMinutes() === 0;
385

Carl Schwan's avatar
Carl Schwan committed
386
387
                            const endIsMidnight = modelData.endDateTime.getHours() === 0
                                            && modelData.endDateTime.getMinutes() === 0;
388

Carl Schwan's avatar
Carl Schwan committed
389
390
                            const sameDay = modelData.startDateTime.getDate() === modelData.endDateTime.getDate()
                                    && modelData.startDateTime.getDay() === modelData.endDateTime.getDay()
391

Carl Schwan's avatar
Carl Schwan committed
392
                            return !(startIsMidnight && endIsMidnight && sameDay);
393
                        }
394

Carl Schwan's avatar
Carl Schwan committed
395
396
                        PlasmaComponents3.ToolTip {
                            text: modelData.description
397
                            visible: text !== "" && eventItem.hovered
Carl Schwan's avatar
Carl Schwan committed
398
                        }
399

Carl Schwan's avatar
Carl Schwan committed
400
401
402
403
404
405
                        contentItem: GridLayout {
                            id: eventGrid
                            columns: 3
                            rows: 2
                            rowSpacing: 0
                            columnSpacing: 2 * PlasmaCore.Units.smallSpacing
406

Carl Schwan's avatar
Carl Schwan committed
407
408
                            Rectangle {
                                id: eventColor
409

Carl Schwan's avatar
Carl Schwan committed
410
411
412
413
                                Layout.row: 0
                                Layout.column: 0
                                Layout.rowSpan: 2
                                Layout.fillHeight: true
414

Carl Schwan's avatar
Carl Schwan committed
415
416
417
418
                                color: modelData.eventColor
                                width: 5 * PlasmaCore.Units.devicePixelRatio
                                visible: modelData.eventColor !== ""
                            }
419

Carl Schwan's avatar
Carl Schwan committed
420
421
422
423
424
                            PlasmaComponents3.Label {
                                id: startTimeLabel

                                readonly property bool startsToday: modelData.startDateTime - monthView.currentDate >= 0
                                readonly property bool startedYesterdayLessThan12HoursAgo: modelData.startDateTime - monthView.currentDate >= -43200000 //12hrs in ms
425

Carl Schwan's avatar
Carl Schwan committed
426
427
428
429
430
431
432
433
434
                                Layout.row: 0
                                Layout.column: 1
                                Layout.minimumWidth: dateLabelMetrics.width

                                text: startsToday || startedYesterdayLessThan12HoursAgo
                                        ? Qt.formatTime(modelData.startDateTime)
                                        : agenda.formatDateWithoutYear(modelData.startDateTime)
                                horizontalAlignment: Qt.AlignRight
                                visible: eventItem.hasTime
435
                            }
436

Carl Schwan's avatar
Carl Schwan committed
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
                            PlasmaComponents3.Label {
                                id: endTimeLabel

                                readonly property bool endsToday: modelData.endDateTime - monthView.currentDate <= 86400000 // 24hrs in ms
                                readonly property bool endsTomorrowInLessThan12Hours: modelData.endDateTime - monthView.currentDate <= 86400000 + 43200000 // 36hrs in ms

                                Layout.row: 1
                                Layout.column: 1
                                Layout.minimumWidth: dateLabelMetrics.width

                                text: endsToday || endsTomorrowInLessThan12Hours
                                        ? Qt.formatTime(modelData.endDateTime)
                                        : agenda.formatDateWithoutYear(modelData.endDateTime)
                                horizontalAlignment: Qt.AlignRight
                                opacity: 0.7

                                visible: eventItem.hasTime
                            }

                            PlasmaComponents3.Label {
                                id: eventTitle

                                Layout.row: 0
                                Layout.column: 2
                                Layout.fillWidth: true

                                elide: Text.ElideRight
                                text: modelData.title
                                verticalAlignment: Text.AlignVCenter
                                maximumLineCount: 2
467
                            }
468
469
                        }
                    }
470
                }
Carl Schwan's avatar
Carl Schwan committed
471
            }
472

Carl Schwan's avatar
Carl Schwan committed
473
474
475
476
477
478
479
480
481
482
483
            PlasmaExtras.Heading {
                anchors.fill: holidaysView
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                anchors.leftMargin: PlasmaCore.Units.largeSpacing
                anchors.rightMargin: PlasmaCore.Units.largeSpacing
                text: monthView.isToday(monthView.currentDate) ? i18n("No events for today")
                                                            : i18n("No events for this day");
                level: 3
                enabled: false
                visible: holidaysList.count == 0
484
            }
Carl Schwan's avatar
Carl Schwan committed
485
        }
486

Carl Schwan's avatar
Carl Schwan committed
487
488
489
        // Horizontal separator line between events and time zones
        PlasmaCore.SvgItem {
            visible: worldClocks.visible && agenda.visible
490

Carl Schwan's avatar
Carl Schwan committed
491
492
            Layout.fillWidth: true
            Layout.preferredHeight: naturalSize.height
493

Carl Schwan's avatar
Carl Schwan committed
494
495
496
            elementId: "horizontal-line"
            svg: PlasmaCore.Svg {
                imagePath: "widgets/line"
497
            }
Carl Schwan's avatar
Carl Schwan committed
498
        }
499

Carl Schwan's avatar
Carl Schwan committed
500
501
502
503
504
505
506
507
508
        // Clocks stuff
        // ------------
        // Header text + button to change time & timezone
        PlasmaExtras.PlasmoidHeading {
            visible: worldClocks.visible
            leftInset: 0
            rightInset: 0
            rightPadding: PlasmaCore.Units.smallSpacing
            contentItem: RowLayout {
509
                PlasmaExtras.Heading {
Carl Schwan's avatar
Carl Schwan committed
510
                    Layout.leftMargin: calendar.paddings + PlasmaCore.Units.smallSpacing * 2
511
                    Layout.fillWidth: true
512

513
                    level: 2
514

515
516
517
518
519
520
521
                    text: i18n("Time Zones")
                    maximumLineCount: 1
                    elide: Text.ElideRight
                }

                PlasmaComponents3.ToolButton {
                    visible: KCMShell.authorize("clock.desktop").length > 0
522
                    text: i18n("Switch…")
523
524
525
526
527
528
529
                    icon.name: "preferences-system-time"
                    onClicked: KCMShell.openSystemSettings("clock")

                    PlasmaComponents3.ToolTip {
                        text: i18n("Switch to another timezone")
                    }
                }
530
            }
Carl Schwan's avatar
Carl Schwan committed
531
        }
532

Carl Schwan's avatar
Carl Schwan committed
533
534
535
536
        // Clocks view itself
        PlasmaComponents3.ScrollView {
            id: worldClocks
            visible: calendar.showClocks
537

Carl Schwan's avatar
Carl Schwan committed
538
539
540
            Layout.fillWidth: true
            Layout.fillHeight: !agenda.visible
            Layout.minimumHeight: visible ? PlasmaCore.Units.gridUnit * 7 : 0
541
            Layout.maximumHeight: agenda.visible ? PlasmaCore.Units.gridUnit * 10 : -1
542

Carl Schwan's avatar
Carl Schwan committed
543
544
            ListView {
                id: clocksList
545
546
547
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.rightMargin: PlasmaCore.Units.smallSpacing * 2
548

Carl Schwan's avatar
Carl Schwan committed
549
                highlight: Item {}
550

Carl Schwan's avatar
Carl Schwan committed
551
552
553
554
                model: {
                    let timezones = [];
                    for (let i = 0; i < plasmoid.configuration.selectedTimeZones.length; i++) {
                        timezones.push(plasmoid.configuration.selectedTimeZones[i]);
555
                    }
556

Carl Schwan's avatar
Carl Schwan committed
557
558
                    return timezones;
                }
559

Carl Schwan's avatar
Carl Schwan committed
560
561
562
563
564
565
566
567
568
569
570
571
572
573
                delegate: PlasmaComponents3.ItemDelegate {
                    id: listItem
                    readonly property bool isCurrentTimeZone: modelData === plasmoid.configuration.lastSelectedTimezone
                    width: clocksList.width
                    padding: calendar.paddings
                    leftPadding: calendar.paddings + PlasmaCore.Units.smallSpacing * 2

                    contentItem: RowLayout {
                        PlasmaComponents3.Label {
                            text: root.nameForZone(modelData)
                            font.weight: listItem.isCurrentTimeZone ? Font.Bold : Font.Normal
                            maximumLineCount: 1
                            elide: Text.ElideRight
                        }
574

Carl Schwan's avatar
Carl Schwan committed
575
576
577
578
579
580
581
                        PlasmaComponents3.Label {
                            Layout.fillWidth: true
                            horizontalAlignment: Qt.AlignRight
                            text: root.timeForZone(modelData)
                            font.weight: listItem.isCurrentTimeZone ? Font.Bold : Font.Normal
                            elide: Text.ElideRight
                            maximumLineCount: 1
582
583
584
585
586
587
                        }
                    }
                }
            }
        }
    }
Carl Schwan's avatar
Carl Schwan committed
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626

    // Vertical separator line between columns
    // =======================================
    PlasmaCore.SvgItem {
        id: mainSeparator
        visible: leftColumn.visible
        anchors {
            right: monthViewWrapper.left
            top: parent.top
            bottom: parent.bottom
        }
        width: 1

        elementId: "vertical-line"
        svg: PlasmaCore.Svg {
            imagePath: "widgets/line"
        }
    }

    // Right column containing calendar
    // ===============================
    FocusScope {
        id: monthViewWrapper
        width: calendar.showAgenda || calendar.showClocks ? parent.width / 2 : parent.width
        anchors.right: parent.right
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        PlasmaCalendar.MonthView {
            id: monthView
            anchors.margins: PlasmaCore.Units.smallSpacing
            borderOpacity: 0.25
            today: root.tzDate
            firstDayOfWeek: plasmoid.configuration.firstDayOfWeek > -1
                ? plasmoid.configuration.firstDayOfWeek
                : Qt.locale().firstDayOfWeek
            showWeekNumbers: plasmoid.configuration.showWeekNumbers
            showCustomHeader: true
        }
    }
627
}