Warning, /plasma-mobile/calindori/src/contents/ui/CalindoriGlobalDrawer.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net>
0003 * SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
0004 *
0005 * SPDX-License-Identifier: GPL-3.0-or-later
0006 */
0007
0008 import QtQuick 2.15
0009 import QtQuick.Controls 2.15
0010 import QtQml.Models 2.14
0011 import QtQuick.Layouts 1.14
0012 import org.kde.kirigami 2.6 as Kirigami
0013 import org.kde.calindori 0.1 as Calindori
0014
0015 Kirigami.OverlayDrawer {
0016 id: drawer
0017
0018 property var monthView
0019 property var calendar
0020 property bool wideScreen: false
0021 property var applicationFooter
0022
0023 modal: !wideScreen
0024 width: 200
0025 height: applicationWindow().height
0026
0027 Kirigami.Theme.colorSet: Kirigami.Theme.Window
0028 Kirigami.Theme.inherit: false
0029
0030 leftPadding: 0
0031 rightPadding: 0
0032 topPadding: 0
0033 bottomPadding: 0
0034
0035 handleClosedIcon.source: modal ? null : "sidebar-expand-left"
0036 handleOpenIcon.source: modal ? null : "sidebar-collapse-left"
0037 handleVisible: applicationWindow().pageStack.depth <= 1 && applicationWindow().pageStack.layers.depth <= 1
0038
0039 property var checkedSidebarItem: monthViewButton
0040
0041 contentItem: ColumnLayout {
0042 spacing: 0
0043
0044 // sidebar header
0045 ToolBar {
0046 visible: !drawer.modal
0047 Layout.fillWidth: true
0048 implicitHeight: applicationWindow().pageStack.globalToolBar.preferredHeight
0049
0050 Item {
0051 anchors.fill: parent
0052 Kirigami.Heading {
0053 level: 1
0054 text: i18n("Calendar")
0055 anchors.left: parent.left
0056 anchors.leftMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0057 anchors.verticalCenter: parent.verticalCenter
0058 }
0059 }
0060 }
0061
0062 Kirigami.Heading {
0063 visible: drawer.modal
0064 text: i18n("Calendar")
0065 type: Kirigami.Heading.Secondary
0066 Layout.margins: Kirigami.Units.gridUnit
0067 }
0068
0069 // sidebar content
0070 ColumnLayout {
0071 id: column
0072 spacing: 0
0073 Layout.margins: Kirigami.Units.smallSpacing
0074
0075 SidebarButton {
0076 id: monthViewButton
0077 Layout.fillWidth: true
0078 Layout.minimumHeight: Kirigami.Units.gridUnit * 2
0079 Layout.bottomMargin: Kirigami.Units.smallSpacing
0080
0081 text: i18n("Month View")
0082 icon.name: "view-calendar-month"
0083 checked: pageActive
0084 property bool pageActive: checkedSidebarItem === monthViewButton
0085
0086 onClicked: {
0087 popExtraLayers();
0088 pageStack.clear();
0089 pageStack.push(monthView);
0090
0091 checkedSidebarItem = monthViewButton;
0092 checked = Qt.binding(() => pageActive);
0093
0094 if (drawer.modal) drawer.close();
0095 }
0096 }
0097
0098 SidebarButton {
0099 id: weekViewButton
0100 Layout.fillWidth: true
0101 Layout.minimumHeight: Kirigami.Units.gridUnit * 2
0102 Layout.bottomMargin: Kirigami.Units.smallSpacing
0103
0104 text: i18n("Week View")
0105 icon.name: "view-calendar-week"
0106 checked: pageActive
0107 property bool pageActive: checkedSidebarItem === weekViewButton
0108
0109 onClicked: {
0110 popExtraLayers();
0111 pageStack.clear();
0112 pageStack.push(weekView, { startDate: Calindori.CalendarController.localSystemDateTime() } );
0113
0114 checkedSidebarItem = weekViewButton;
0115 checked = Qt.binding(() => pageActive);
0116
0117 if (drawer.modal) drawer.close();
0118 }
0119 }
0120
0121 SidebarButton {
0122 id: dayViewButton
0123 Layout.fillWidth: true
0124 Layout.minimumHeight: Kirigami.Units.gridUnit * 2
0125 Layout.bottomMargin: Kirigami.Units.smallSpacing
0126
0127 text: i18n("Day View")
0128 icon.name: "view-calendar-day"
0129 checked: pageActive
0130 property bool pageActive: checkedSidebarItem === dayViewButton
0131
0132 onClicked: {
0133 popExtraLayers();
0134 pageStack.clear();
0135 pageStack.push(dayView);
0136
0137 checkedSidebarItem = dayViewButton;
0138 checked = Qt.binding(() => pageActive);
0139
0140 if (drawer.modal) drawer.close();
0141 }
0142 }
0143
0144 SidebarButton {
0145 id: tasksListButton
0146 Layout.fillWidth: true
0147 Layout.minimumHeight: Kirigami.Units.gridUnit * 2
0148 Layout.bottomMargin: Kirigami.Units.smallSpacing
0149
0150 text: i18n("Tasks List")
0151 icon.name: "view-calendar-list"
0152 checked: pageActive
0153 property bool pageActive: checkedSidebarItem === tasksListButton
0154
0155 onClicked: {
0156 popExtraLayers();
0157 pageStack.clear();
0158 pageStack.push(incidenceView, { incidenceType: 1, filterMode: 9 });
0159
0160 checkedSidebarItem = tasksListButton;
0161 checked = Qt.binding(() => pageActive);
0162
0163 if (drawer.modal) drawer.close();
0164 }
0165 }
0166
0167 SidebarButton {
0168 id: eventsListButton
0169 Layout.fillWidth: true
0170 Layout.minimumHeight: Kirigami.Units.gridUnit * 2
0171
0172 text: i18n("Events List")
0173 icon.name: "view-calendar-agenda"
0174 checked: pageActive
0175 property bool pageActive: checkedSidebarItem === eventsListButton
0176
0177 onClicked: {
0178 popExtraLayers();
0179 pageStack.clear();
0180 pageStack.push(incidenceView, { incidenceType: 0, filterMode: 8 });
0181
0182 checkedSidebarItem = eventsListButton;
0183 checked = Qt.binding(() => pageActive);
0184
0185 if (drawer.modal) drawer.close();
0186 }
0187 }
0188
0189 Kirigami.Separator {
0190 Layout.fillWidth: true
0191 Layout.margins: Kirigami.Units.smallSpacing
0192 }
0193
0194 Kirigami.Heading {
0195 Layout.fillWidth: true
0196 Layout.margins: Kirigami.Units.smallSpacing
0197 Layout.leftMargin: Kirigami.Units.largeSpacing
0198 text: i18n("Calendars")
0199 level: 3
0200 type: Kirigami.Heading.Secondary
0201 }
0202
0203 // calendar selection
0204 Repeater {
0205 model: Calindori.CalindoriConfig && Calindori.CalindoriConfig.internalCalendars
0206 delegate: calendarButton
0207 }
0208 Repeater {
0209 model: Calindori.CalindoriConfig && Calindori.CalindoriConfig.externalCalendars
0210 delegate: calendarButton
0211 }
0212
0213 Component {
0214 id: calendarButton
0215 SidebarButton {
0216 Layout.fillWidth: true
0217 Layout.minimumHeight: Kirigami.Units.gridUnit * 2
0218 property string calendarName: modelData
0219 property bool calendarActive: Calindori.CalindoriConfig !== null ? (Calindori.CalindoriConfig.activeCalendar === calendarName) : false
0220
0221 text: calendarName
0222 icon.name: calendarActive ? "checkmark" : "view-calendar"
0223 checked: false
0224
0225 onClicked: {
0226 if (!checked) {
0227 Calindori.CalindoriConfig.activeCalendar = calendarName;
0228 popExtraLayers();
0229 showPassiveNotification(i18n("Calendar %1 has been activated", calendarName));
0230 checked = false;
0231 }
0232 }
0233 }
0234 }
0235
0236 Item { Layout.fillHeight: true }
0237 Kirigami.Separator {
0238 Layout.fillWidth: true
0239 Layout.margins: Kirigami.Units.smallSpacing
0240 }
0241
0242 SidebarButton {
0243 id: settingsButton
0244 Layout.fillWidth: true
0245 Layout.minimumHeight: Kirigami.Units.gridUnit * 2
0246
0247 text: i18n("Settings")
0248 icon.name: "settings-configure"
0249 checked: pageActive
0250 property bool pageActive: checkedSidebarItem === settingsButton
0251
0252 onClicked: {
0253 popExtraLayers();
0254 pageStack.clear();
0255 pageStack.push(settingsPage);
0256
0257 checkedSidebarItem = settingsButton;
0258 checked = Qt.binding(() => pageActive);
0259
0260 if (drawer.modal) drawer.close();
0261 }
0262 }
0263 }
0264 }
0265
0266 Component {
0267 id: dayView
0268 DayPage {
0269 wideScreen: root.wideScreen
0270 }
0271 }
0272
0273 Component {
0274 id: weekView
0275 WeekPage {
0276 wideScreen: root.wideScreen
0277 }
0278 }
0279
0280 Component {
0281 id: incidenceView
0282 IncidenceListView {
0283 calendar: root.calendar
0284 }
0285 }
0286
0287 Component {
0288 id: settingsPage
0289 SettingsPage {
0290 applicationFooter: drawer.applicationFooter
0291 }
0292 }
0293 }