Warning, /utilities/kongress/src/contents/ui/GlobalDrawer.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2020 David Barchiesi <david@barchie.si>
0003  * SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net>
0004  *
0005  * SPDX-License-Identifier: GPL-3.0-or-later
0006  */
0007 
0008 import QtQuick 2.1
0009 import QtQml.Models 2.14
0010 import QtQuick.Layouts 1.2
0011 import org.kde.kirigami 2.6 as Kirigami
0012 import org.kde.kongress 0.1 as Kongress
0013 
0014 Kirigami.GlobalDrawer {
0015     id: drawer
0016 
0017     property var activeConference
0018     property var pageStack
0019 
0020     /**
0021      * Starting from the last page in the stack, remove every page of the stack
0022      */
0023     function popAll()
0024     {
0025         while (pageStack.depth > 0) {
0026             pageStack.pop();
0027         }
0028     }
0029 
0030     header: Kirigami.AbstractApplicationHeader {
0031         topPadding: Kirigami.Units.smallSpacing
0032         bottomPadding: Kirigami.Units.largeSpacing
0033         leftPadding: Kirigami.Units.largeSpacing
0034         rightPadding: Kirigami.Units.smallSpacing
0035         implicitHeight: Kirigami.Units.gridUnit * 2
0036         Kirigami.Heading {
0037             level: 1
0038             text: activeConference ? activeConference.name : i18n("Conference")
0039             Layout.fillWidth: true
0040         }
0041     }
0042 
0043     actions: [
0044         Kirigami.Action {
0045             text: i18n("Check for updates")
0046             visible: activeConference
0047             icon.name: "update-none"
0048 
0049             onTriggered: {
0050                 onlineCalendar.loadOnlineCalendar();
0051             }
0052         },
0053 
0054         Kirigami.Action {
0055             id: dayActions
0056 
0057             text: i18n("Daily Schedule")
0058             icon.name: "view-calendar-day"
0059             expandible: true
0060         },
0061 
0062         Kirigami.Action {
0063             text: i18n("Full Schedule")
0064             icon.name: "view-calendar-agenda"
0065             visible: activeConference
0066 
0067             onTriggered: {
0068                 popAll();
0069                 pageStack.push(scheduleView, {title: i18n("Schedule"), eventStartDt: ""});
0070             }
0071         },
0072 
0073         Kirigami.Action {
0074             id: categoryActions
0075 
0076             text: i18n("Categories")
0077             icon.name: "category"
0078             visible: activeConference && children.length > 0
0079         },
0080 
0081         Kirigami.Action {
0082             text: i18n("Map")
0083             icon.name: "find-location"
0084             visible: activeConference && (activeConference.venueOsmUrl !== "" || (activeConference.venueLatitude !== "" && activeConference.venueLongitude !== ""))
0085 
0086             onTriggered: {
0087                 popAll();
0088                 pageStack.push(mapView);
0089             }
0090         },
0091 
0092         Kirigami.Action {
0093             text: i18n("Favorites")
0094             icon.name: "favorite"
0095             visible: activeConference
0096 
0097             onTriggered: {
0098                 popAll();
0099                 pageStack.push(favoritesView, {title: i18n("Favorites"), eventStartDt: ""});
0100             }
0101         },
0102 
0103         Kirigami.Action {
0104             text: i18n("Configure")
0105             icon.name: "settings-configure"
0106             expandible: true
0107 
0108             Kirigami.Action {
0109                 text: activeConference ? i18n("Change conference") : i18n("Select conference")
0110                 icon.name: activeConference ? 'exchange-positions' : 'edit-select'
0111 
0112                 onTriggered: {
0113                     Kongress.ConferenceController.clearActiveConference();
0114                 }
0115             }
0116 
0117             Kirigami.Action {
0118                 text: i18n("Settings")
0119                 icon.name: "settings-configure"
0120                 onTriggered: {
0121                     popAll();
0122                     pageStack.push(settingsView);
0123                 }
0124             }
0125         },
0126 
0127         Kirigami.Action {
0128             id: aboutAction
0129 
0130             icon.name: "help-about-symbolic"
0131             text: i18n("About")
0132 
0133             onTriggered: {
0134                 popAll();
0135                 pageStack.push(aboutInfoPage);
0136             }
0137         }
0138     ]
0139 
0140     Component {
0141         id: settingsView
0142 
0143         SettingsView {}
0144     }
0145 
0146     Instantiator { 
0147         id: daysInstantiator
0148 
0149         model: activeConference && (activeConference.days !== null) ? activeConference.days: []
0150 
0151         delegate: Kirigami.Action {
0152             property date conferenceDay: new Date(modelData)
0153 
0154             text: conferenceDay.toLocaleDateString(Qt.locale(), "dddd")
0155 
0156             onTriggered: {
0157                 popAll();
0158                 pageStack.push(scheduleView, {title: conferenceDay.toLocaleDateString(Qt.locale(), "dddd"), eventStartDt: conferenceDay });
0159             }
0160         }
0161 
0162         onObjectAdded: (index, object) => {
0163             if(!isNaN(object.conferenceDay)) {
0164                 dayActions.children.push(object)
0165             }
0166         }
0167         onObjectRemoved: {
0168             if(dayActions.children) {
0169                 dayActions.children = [];
0170             }
0171         }
0172     }
0173 
0174     Instantiator {
0175         model: (onlineCalendar && onlineCalendar.categories) ? onlineCalendar.categories : []
0176 
0177         delegate: Kirigami.Action {
0178             text: modelData
0179 
0180             onTriggered: {
0181                 popAll();
0182                 pageStack.push(scheduleView, {title: text, eventStartDt: "", category: text, showCategories: false});
0183             }
0184         }
0185 
0186         onObjectAdded: {
0187             if(object.text !== "") {
0188                 categoryActions.children.push(object)
0189             }
0190         }
0191 
0192         onObjectRemoved: {
0193             if(categoryActions.children) {
0194                 categoryActions.children = [];
0195             }
0196         }
0197     }
0198 
0199     Component {
0200         id: aboutInfoPage
0201 
0202         Kirigami.AboutPage {
0203             aboutData: _about
0204         }
0205     }
0206 }