Warning, /plasma/plasma-workspace/components/calendar/qml/MonthViewHeader.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2022 Tanbir Jishan <tantalising007@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 import QtQuick 2.15 0007 import QtQuick.Layouts 1.1 0008 0009 import org.kde.plasma.components 3.0 as PlasmaComponents3 0010 import org.kde.plasma.extras 2.0 as PlasmaExtras 0011 import org.kde.kirigami 2.20 as Kirigami 0012 0013 // NOTE : This header is designed to be usable by both the generic calendar component and the digital clock applet 0014 // which requires a little different layout to accomodate for configure and pin buttons because it may be in panel 0015 0016 // CALENDAR DIGTAL CLOCK 0017 // |---------------------------------------------------| |----------------------------------------------------| 0018 // | January < today > | | January config+ pin/ | 0019 // | Days Months Year | | Days Months Year < today > | 0020 // | | | | 0021 // | Rest of the calendar | | Rest of the calendar | 0022 // |...................................................| |....................................................| 0023 // 0024 0025 0026 Item { 0027 id: root 0028 0029 required property var swipeView 0030 required property var monthViewRoot 0031 0032 readonly property bool isDigitalClock: monthViewRoot.showDigitalClockHeader 0033 readonly property var buttons: isDigitalClock ? dateManipulationButtonsForDigitalClock : dateManipulationButtons 0034 readonly property var tabButton: isDigitalClock ? configureButton : todayButton 0035 readonly property var previousButton: buttons.previousButton 0036 readonly property var todayButton: buttons.todayButton 0037 readonly property var nextButton: buttons.nextButton 0038 readonly property alias tabBar: tabBar 0039 readonly property alias heading: heading 0040 readonly property alias configureButton: dateAndPinButtons.configureButton 0041 readonly property alias pinButton: dateAndPinButtons.pinButton 0042 0043 implicitWidth: viewHeader.implicitWidth 0044 implicitHeight: viewHeader.implicitHeight 0045 0046 KeyNavigation.up: configureButton 0047 0048 Loader { 0049 anchors.fill: parent 0050 sourceComponent: PlasmaExtras.PlasmoidHeading {} 0051 active: isDigitalClock 0052 } 0053 0054 ColumnLayout { 0055 id: viewHeader 0056 width: parent.width 0057 0058 RowLayout { 0059 spacing: 0 0060 Layout.leftMargin: Kirigami.Units.largeSpacing 0061 0062 Kirigami.Heading { 0063 id: heading 0064 // Needed for Appium testing 0065 objectName: "monthHeader" 0066 0067 text: root.swipeView.currentIndex > 0 || monthViewRoot.selectedYear !== today.getFullYear() ? i18ndc("plasmashellprivateplugin", "Format: month year", "%1 %2", monthViewRoot.selectedMonth, monthViewRoot.selectedYear.toString()) : monthViewRoot.selectedMonth 0068 textFormat: Text.PlainText 0069 level: root.isDigitalClock ? 1 : 2 0070 elide: Text.ElideRight 0071 font.capitalization: Font.Capitalize 0072 Layout.fillWidth: true 0073 } 0074 0075 Loader { 0076 id: dateManipulationButtons 0077 0078 property var previousButton: item && item.previousButton 0079 property var todayButton: item && item.todayButton 0080 property var nextButton: item && item.nextButton 0081 0082 sourceComponent: buttonsGroup 0083 active: !root.isDigitalClock 0084 } 0085 0086 Loader { 0087 id: dateAndPinButtons 0088 0089 readonly property var configureButton: item && item.configureButton 0090 readonly property var pinButton: item && item.pinButton 0091 0092 sourceComponent: dateAndPin 0093 active: root.isDigitalClock 0094 } 0095 } 0096 0097 RowLayout { 0098 spacing: 0 0099 PlasmaComponents3.TabBar { 0100 id: tabBar 0101 0102 currentIndex: root.swipeView.currentIndex 0103 Layout.fillWidth: true 0104 Layout.bottomMargin: root.isDigitalClock ? 0 : Kirigami.Units.smallSpacing 0105 0106 KeyNavigation.up: root.isDigitalClock ? root.configureButton : root.previousButton 0107 KeyNavigation.right: dateManipulationButtonsForDigitalClock.previousButton 0108 KeyNavigation.left: root.monthViewRoot.eventButton && root.monthViewRoot.eventButton.visible ? 0109 root.monthViewRoot.eventButton : 0110 root.monthViewRoot.eventButton && root.monthViewRoot.eventButton.KeyNavigation.down 0111 0112 PlasmaComponents3.TabButton { 0113 Accessible.onPressAction: clicked() 0114 text: i18nd("plasmashellprivateplugin", "Days"); 0115 onClicked: monthViewRoot.showMonthView(); 0116 display: PlasmaComponents3.AbstractButton.TextOnly 0117 } 0118 PlasmaComponents3.TabButton { 0119 Accessible.onPressAction: clicked() 0120 text: i18nd("plasmashellprivateplugin", "Months"); 0121 onClicked: monthViewRoot.showYearView(); 0122 display: PlasmaComponents3.AbstractButton.TextOnly 0123 } 0124 PlasmaComponents3.TabButton { 0125 Accessible.onPressAction: clicked() 0126 text: i18nd("plasmashellprivateplugin", "Years"); 0127 onClicked: monthViewRoot.showDecadeView(); 0128 display: PlasmaComponents3.AbstractButton.TextOnly 0129 } 0130 } 0131 0132 Loader { 0133 id: dateManipulationButtonsForDigitalClock 0134 0135 property var previousButton: item && item.previousButton 0136 property var todayButton: item && item.todayButton 0137 property var nextButton: item && item.nextButton 0138 0139 sourceComponent: buttonsGroup 0140 active: root.isDigitalClock 0141 } 0142 } 0143 } 0144 0145 // ------------------------------------------ UI ends ------------------------------------------------- // 0146 0147 Component { 0148 id: buttonsGroup 0149 0150 RowLayout { 0151 spacing: 0 0152 0153 readonly property alias previousButton: previousButton 0154 readonly property alias todayButton: todayButton 0155 readonly property alias nextButton: nextButton 0156 0157 KeyNavigation.up: root.configureButton 0158 0159 PlasmaComponents3.ToolButton { 0160 id: previousButton 0161 text: { 0162 switch(monthViewRoot.calendarViewDisplayed) { 0163 case MonthView.CalendarView.DayView: 0164 return i18nd("plasmashellprivateplugin", "Previous Month") 0165 case MonthView.CalendarView.MonthView: 0166 return i18nd("plasmashellprivateplugin", "Previous Year") 0167 case MonthView.CalendarView.YearView: 0168 return i18nd("plasmashellprivateplugin", "Previous Decade") 0169 default: 0170 return ""; 0171 } 0172 } 0173 0174 icon.name: Qt.application.layoutDirection === Qt.RightToLeft ? "go-next" : "go-previous" 0175 display: PlasmaComponents3.AbstractButton.IconOnly 0176 KeyNavigation.right: todayButton 0177 0178 onClicked: monthViewRoot.previousView() 0179 0180 PlasmaComponents3.ToolTip { text: parent.text } 0181 } 0182 0183 PlasmaComponents3.ToolButton { 0184 id: todayButton 0185 text: i18ndc("plasmashellprivateplugin", "Reset calendar to today", "Today") 0186 Accessible.description: i18nd("plasmashellprivateplugin", "Reset calendar to today") 0187 KeyNavigation.right: nextButton 0188 0189 onClicked: monthViewRoot.resetToToday() 0190 } 0191 0192 PlasmaComponents3.ToolButton { 0193 id: nextButton 0194 text: { 0195 switch(monthViewRoot.calendarViewDisplayed) { 0196 case MonthView.CalendarView.DayView: 0197 return i18nd("plasmashellprivateplugin", "Next Month") 0198 case MonthView.CalendarView.MonthView: 0199 return i18nd("plasmashellprivateplugin", "Next Year") 0200 case MonthView.CalendarView.YearView: 0201 return i18nd("plasmashellprivateplugin", "Next Decade") 0202 default: 0203 return ""; 0204 } 0205 } 0206 0207 icon.name: Qt.application.layoutDirection === Qt.RightToLeft ? "go-previous" : "go-next" 0208 display: PlasmaComponents3.AbstractButton.IconOnly 0209 KeyNavigation.tab: root.swipeView 0210 0211 onClicked: monthViewRoot.nextView(); 0212 0213 PlasmaComponents3.ToolTip { text: parent.text } 0214 } 0215 } 0216 } 0217 0218 Component { 0219 id: dateAndPin 0220 0221 RowLayout { 0222 spacing: 0 0223 0224 readonly property alias configureButton: configureButton 0225 readonly property alias pinButton: pinButton 0226 0227 KeyNavigation.up: pinButton 0228 0229 PlasmaComponents3.ToolButton { 0230 id: configureButton 0231 0232 visible: root.monthViewRoot.digitalClock.internalAction("configure").enabled 0233 0234 display: PlasmaComponents3.AbstractButton.IconOnly 0235 icon.name: "configure" 0236 text: root.monthViewRoot.digitalClock.internalAction("configure").text 0237 0238 KeyNavigation.left: tabBar.KeyNavigation.left 0239 KeyNavigation.right: pinButton 0240 KeyNavigation.down: root.todayButton 0241 0242 onClicked: root.monthViewRoot.digitalClock.internalAction("configure").trigger() 0243 PlasmaComponents3.ToolTip { 0244 text: parent.text 0245 } 0246 } 0247 0248 // Allows the user to keep the calendar open for reference 0249 PlasmaComponents3.ToolButton { 0250 id: pinButton 0251 0252 checkable: true 0253 checked: root.monthViewRoot.digitalClock.configuration.pin 0254 0255 display: PlasmaComponents3.AbstractButton.IconOnly 0256 icon.name: "window-pin" 0257 text: i18n("Keep Open") 0258 0259 KeyNavigation.down: root.nextButton 0260 0261 onToggled: root.monthViewRoot.digitalClock.configuration.pin = checked 0262 0263 PlasmaComponents3.ToolTip { 0264 text: parent.text 0265 } 0266 } 0267 } 0268 } 0269 }