Warning, /plasma-mobile/raven/src/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
0002 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
0003 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0004
0005 import QtQuick 2.15
0006 import QtQuick.Layouts 1.15
0007 import QtQuick.Controls 2.15 as Controls
0008
0009 import org.kde.kirigami 2.14 as Kirigami
0010 import org.kde.kitemmodels 1.0 as KItemModels
0011 import org.kde.raven 1.0
0012
0013 import "mailboxselector"
0014
0015 Kirigami.ApplicationWindow {
0016 id: root
0017
0018 title: i18n("Raven")
0019
0020 width: 1200
0021 height: 600
0022
0023 contextDrawer: Kirigami.ContextDrawer {
0024 id: contextDrawer
0025 }
0026
0027 pageStack.globalToolBar.canContainHandles: true
0028 pageStack.globalToolBar.style: Kirigami.ApplicationHeaderStyle.ToolBar
0029 pageStack.globalToolBar.showNavigationButtons: Kirigami.ApplicationHeaderStyle.ShowBackButton;
0030 pageStack.popHiddenPages: !root.isWidescreen // pop pages when not in use in mobile mode
0031
0032 property bool isWidescreen: root.width > 500
0033 onIsWidescreenChanged: changeSidebar(isWidescreen);
0034
0035 Kirigami.PagePool {
0036 id: pagePool
0037 }
0038
0039 function getPage(name) {
0040 switch (name) {
0041 case "FolderView": return pagePool.loadPage("qrc:/FolderView.qml")
0042 case "MailBoxListPage": return pagePool.loadPage("qrc:/mailboxselector/MailBoxListPage.qml")
0043 case "SettingsPage": return pagePool.loadPage("qrc:/SettingsPage.qml")
0044 case "AboutPage": return pagePool.loadPage("qrc:/AboutPage.qml")
0045 }
0046 }
0047
0048 Component.onCompleted: {
0049 // initial page and nav type
0050 changeSidebar(isWidescreen);
0051
0052 if (isWidescreen) {
0053 root.pageStack.push(getPage("FolderView"));
0054 }
0055 }
0056
0057 // switch between page and sidebar
0058 function changeSidebar(toWidescreen) {
0059 if (toWidescreen) {
0060 // unload first page (mailboxes page)
0061 let array = [];
0062 while (root.pageStack.depth > 0) {
0063 array.push(root.pageStack.pop());
0064 }
0065 for (let i = array.length - 2; i >= 0; i--) {
0066 root.pageStack.push(array[i]);
0067 }
0068
0069 // load sidebar
0070 sidebarLoader.active = true;
0071 root.globalDrawer = sidebarLoader.item;
0072
0073 // restore mail list if not there
0074 if (root.pageStack.depth === 0) {
0075 root.pageStack.push(getPage("FolderView"));
0076 }
0077 } else {
0078 // unload sidebar
0079 sidebarLoader.active = false;
0080 root.globalDrawer = null;
0081
0082 // load mailboxes page as first page, and then restore all pages
0083 let array = [];
0084 while (root.pageStack.depth > 0) {
0085 array.push(root.pageStack.pop());
0086 }
0087 root.pageStack.push(getPage("MailBoxListPage"));
0088 for (let i = array.length - 1; i >= 0; i--) {
0089 root.pageStack.push(array[i]);
0090 }
0091 }
0092 }
0093
0094 Loader {
0095 id: sidebarLoader
0096 source: "qrc:/mailboxselector/MailBoxListSidebar.qml"
0097 active: false
0098 }
0099 }