Warning, /plasma-mobile/calindori/src/contents/ui/CalendarMonthPage.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 import QtQuick 2.7 0008 import org.kde.kirigami 2.12 as Kirigami 0009 import org.kde.calindori 0.1 as Calindori 0010 0011 Kirigami.Page { 0012 id: root 0013 0014 property var appContextDrawer 0015 property string contextIconName: "view-calendar-tasks" 0016 property alias dayRectangleWidth: calendarMonthView.dayRectangleWidth 0017 property alias selectedDate: calendarMonthView.selectedDate 0018 0019 /** 0020 * @brief The active calendar, which is the host of todos, events, etc. 0021 * 0022 */ 0023 property var calendar 0024 0025 /** 0026 * @brief The index of the last contextual action triggered 0027 * 0028 */ 0029 property int latestContextualAction: -1 0030 0031 /** 0032 * @brief When set to a valid contextual action index, as soon as the page is loaded the corresponding contextual action is also opened 0033 * 0034 */ 0035 property int loadWithAction: -1 0036 0037 /** 0038 * @brief Emitted when the hosted SwipeView index is set to the first or the last container item 0039 * 0040 */ 0041 signal pageEnd(var lastDate, var lastActionIndex) 0042 0043 title: calendarMonthView.selectedDate.toLocaleDateString(_appLocale, Locale.ShortFormat) 0044 0045 actions { 0046 main: Kirigami.Action { 0047 iconName: "view-calendar-day" 0048 text: i18n("Today") 0049 0050 onTriggered: calendarMonthView.goToday() 0051 } 0052 0053 contextualActions: [ 0054 Kirigami.Action { 0055 iconName: "arrow-left" 0056 text: i18n("Previous") 0057 displayHint: Kirigami.Action.IconOnly 0058 onTriggered: calendarMonthView.previousMonth() 0059 }, 0060 0061 Kirigami.Action { 0062 iconName: "arrow-right" 0063 text: i18n("Next") 0064 displayHint: Kirigami.Action.IconOnly 0065 onTriggered: calendarMonthView.nextMonth() 0066 }, 0067 0068 Kirigami.Action { 0069 iconName: "view-calendar-tasks" 0070 text: i18n("Tasks") 0071 0072 onTriggered: { 0073 latestContextualAction = 0; 0074 pageStack.pop(root); 0075 pageStack.push(todosCardView); 0076 } 0077 }, 0078 0079 Kirigami.Action { 0080 iconName: "tag-events" 0081 text: i18n("Events") 0082 0083 onTriggered: { 0084 latestContextualAction = 1; 0085 pageStack.pop(root); 0086 pageStack.push(eventsCardView); 0087 } 0088 } 0089 ] 0090 } 0091 0092 Component.onCompleted: { 0093 if(loadWithAction >= 0) 0094 { 0095 contextualActions[loadWithAction].trigger(); 0096 } 0097 } 0098 0099 CalendarMonthView { 0100 id: calendarMonthView 0101 0102 anchors.fill: parent 0103 cal: root.calendar 0104 0105 showHeader: true 0106 showMonthName: false 0107 showYear: false 0108 0109 onSelectedDateChanged: { 0110 if (Kirigami.Settings.isMobile && pageStack.depth > 1) { 0111 pageStack.pop(null); 0112 } 0113 } 0114 0115 onDayPressed: { 0116 if (dayOfPress.toLocaleDateString() === selectedDate.toLocaleDateString()) { 0117 appContextDrawer.handleOpenIcon.color = Kirigami.Theme.highlightColor; 0118 appContextDrawer.handleClosedIcon.color = Kirigami.Theme.highlightColor; 0119 } 0120 } 0121 0122 onDayLongPressed: { 0123 if ((dayOfLongPress.toLocaleDateString() === selectedDate.toLocaleDateString()) && Kirigami.Settings.isMobile) { 0124 appContextDrawer.open(); 0125 } 0126 } 0127 0128 onDayReleased: { 0129 appContextDrawer.handleOpenIcon.color = ''; 0130 appContextDrawer.handleClosedIcon.color = ''; 0131 } 0132 0133 onViewEnd: pageEnd(lastDate, (pageStack.depth > 1) ? root.latestContextualAction : -1) 0134 } 0135 0136 Component { 0137 id: todosCardView 0138 0139 TodosCardView { 0140 calendar: Calindori.CalendarController.activeCalendar 0141 todoDt: root.selectedDate 0142 } 0143 } 0144 0145 Component { 0146 id: eventsCardView 0147 0148 EventsCardView { 0149 calendar: Calindori.CalendarController.activeCalendar 0150 eventStartDt: root.selectedDate 0151 } 0152 } 0153 }