Warning, /plasma/plasma-workspace/applets/calendar/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2013 Heena Mahour <heena393@gmail.com>
0003 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
0004 SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
0005
0006 SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 import QtQuick 2.12
0009 import QtQuick.Layouts 1.12
0010
0011 import org.kde.plasma.plasmoid 2.0
0012 import org.kde.plasma.plasma5support 2.0 as P5Support
0013 import org.kde.plasma.components 3.0 as PlasmaComponents3
0014 import org.kde.kirigami 2.20 as Kirigami
0015
0016 import org.kde.plasma.workspace.calendar 2.0
0017
0018 PlasmoidItem {
0019 id: root
0020 switchWidth: Kirigami.Units.gridUnit * 12
0021 switchHeight: Kirigami.Units.gridUnit * 12
0022
0023 toolTipMainText: Qt.formatDate(dataSource.data.Local.DateTime, "dddd")
0024 toolTipSubText: {
0025 // this logic is taken from digital-clock:
0026 // remove "dddd" from the locale format string
0027 // /all/ locales in LongFormat have "dddd" either
0028 // at the beginning or at the end. so we just
0029 // remove it + the delimiter and space
0030 var format = Qt.locale().dateFormat(Locale.LongFormat);
0031 format = format.replace(/(^dddd.?\s)|(,?\sdddd$)/, "");
0032 return Qt.formatDate(dataSource.data.Local.DateTime, format)
0033 }
0034
0035 Layout.minimumWidth: Kirigami.Units.iconSizes.large
0036 Layout.minimumHeight: Kirigami.Units.iconSizes.large
0037
0038 P5Support.DataSource {
0039 id: dataSource
0040 engine: "time"
0041 connectedSources: ["Local"]
0042 interval: 60000
0043 intervalAlignment: P5Support.Types.AlignToMinute
0044 }
0045
0046 // Only exists because the default CompactRepresentation doesn't expose a
0047 // generic way to overlay something on top of the icon.
0048 // TODO remove once it gains that feature.
0049 compactRepresentation: MouseArea {
0050 onClicked: root.expanded = !root.expanded
0051
0052 Kirigami.Icon {
0053 anchors.fill: parent
0054
0055 source: Qt.resolvedUrl("../images/mini-calendar.svgz")
0056
0057 PlasmaComponents3.Label {
0058 id: monthLabel
0059 y: parent.y + parent.height * 0.05;
0060 x: 0
0061 width: parent.width
0062 height: parent.height * 0.2
0063
0064 horizontalAlignment: Text.AlignHCenter
0065 verticalAlignment: Text.AlignBottom
0066 fontSizeMode: Text.Fit
0067 minimumPointSize: 1
0068
0069 /* color must be black because it's set on top of a white icon */
0070 color: "black"
0071
0072 text: {
0073 var d = new Date(dataSource.data.Local.DateTime);
0074 return Qt.formatDate(d, "MMM");
0075 }
0076 textFormat: Text.PlainText
0077 visible: parent.width > Kirigami.Units.gridUnit * 3
0078 }
0079
0080 PlasmaComponents3.Label {
0081 anchors.top: monthLabel.bottom
0082 x: 0
0083 width: parent.width
0084 height: parent.height * 0.6
0085 horizontalAlignment: Text.AlignHCenter
0086 verticalAlignment: Text.AlignTop
0087 minimumPointSize: 1
0088 font.pixelSize: 1000
0089
0090 fontSizeMode: Text.Fit
0091
0092 /* color must be black because it's set on top of a white icon */
0093 color: "black"
0094 text: {
0095 var d = new Date(dataSource.data.Local.DateTime)
0096 var format = Plasmoid.configuration.compactDisplay
0097
0098 if (format === "w") {
0099 return Plasmoid.weekNumber(d)
0100 }
0101
0102 return Qt.formatDate(d, format)
0103 }
0104 textFormat: Text.PlainText
0105 }
0106 }
0107 }
0108
0109 fullRepresentation: Item {
0110
0111 // sizing taken from digital clock
0112 readonly property int _minimumWidth: calendar.showWeekNumbers ? Math.round(_minimumHeight * 1.75) : Math.round(_minimumHeight * 1.5)
0113 readonly property int _minimumHeight: Kirigami.Units.gridUnit * 14
0114 readonly property var appletInterface: root
0115
0116 Layout.minimumWidth: _minimumWidth
0117 Layout.maximumWidth: Kirigami.Units.gridUnit * 80
0118 Layout.minimumHeight: _minimumHeight
0119 Layout.maximumHeight: Kirigami.Units.gridUnit * 40
0120
0121 MonthView {
0122 id: calendar
0123 today: dataSource.data["Local"]["DateTime"]
0124 showWeekNumbers: Plasmoid.configuration.showWeekNumbers
0125
0126 anchors.fill: parent
0127 }
0128 }
0129 }