Highlighting the current menu item in the GlobalDrawer.

This commit is contained in:
Swapnil Tripathi 2021-06-27 03:57:49 +05:30
parent 265b3109cb
commit 17e8e75993

View File

@ -25,6 +25,8 @@ Kirigami.ApplicationWindow {
property int bottomMessageSpacing: Kirigami.Settings.isMobile ? Kirigami.Units.largeSpacing * 9 + ( AudioManager.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + tabBarActive * tabBarHeight : Kirigami.Units.largeSpacing * 2 property int bottomMessageSpacing: Kirigami.Settings.isMobile ? Kirigami.Units.largeSpacing * 9 + ( AudioManager.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + tabBarActive * tabBarHeight : Kirigami.Units.largeSpacing * 2
property int tabBarActive: 0 property int tabBarActive: 0
property int originalWidth: Kirigami.Units.gridUnit * 10 property int originalWidth: Kirigami.Units.gridUnit * 10
property var lastFeed: ""
property string currentPage: ""
property bool isWidescreen: root.width >= root.height property bool isWidescreen: root.width >= root.height
onIsWidescreenChanged: { onIsWidescreenChanged: {
@ -32,10 +34,20 @@ Kirigami.ApplicationWindow {
changeNavigation(!isWidescreen); changeNavigation(!isWidescreen);
} }
} }
function getPage(page) {
Kirigami.PagePool { switch (page) {
id: mainPagePool case "QueuePage": return "qrc:/QueuePage.qml";
cachePages: false case "EpisodeSwipePage": return "qrc:/EpisodeSwipePage.qml";
case "FeedListPage": return "qrc:/FeedListPage.qml";
case "DownloadListPage": return "qrc:/DownloadListPage.qml";
case "SettingsPage": return "qrc:/SettingsPage.qml";
case "AboutPage": return "qrc:/AboutPage.qml";
}
}
function pushPage(page) {
pageStack.clear()
pageStack.push(getPage(page))
currentPage = page
} }
Component.onCompleted: { Component.onCompleted: {
@ -44,11 +56,8 @@ Kirigami.ApplicationWindow {
: SettingsManager.lastOpenedPage === "EpisodeSwipePage" ? 1 : SettingsManager.lastOpenedPage === "EpisodeSwipePage" ? 1
: SettingsManager.lastOpenedPage === "DownloadListPage" ? 0 : SettingsManager.lastOpenedPage === "DownloadListPage" ? 0
: 0 : 0
pageStack.initialPage = mainPagePool.loadPage(SettingsManager.lastOpenedPage === "FeedListPage" ? "qrc:/FeedListPage.qml" currentPage = SettingsManager.lastOpenedPage
: SettingsManager.lastOpenedPage === "QueuePage" ? "qrc:/QueuePage.qml" pageStack.initialPage = getPage(SettingsManager.lastOpenedPage)
: SettingsManager.lastOpenedPage === "EpisodeSwipePage" ? "qrc:/EpisodeSwipePage.qml"
: SettingsManager.lastOpenedPage === "DownloadListPage" ? "qrc:/DownloadListPage.qml"
: "qrc:/FeedListPage.qml")
if (SettingsManager.refreshOnStartup) Fetcher.fetchAll(); if (SettingsManager.refreshOnStartup) Fetcher.fetchAll();
} }
@ -72,57 +81,61 @@ Kirigami.ApplicationWindow {
handleVisible: Kirigami.Settings.isMobile ? !AudioManager.entry || footerLoader.item.contentY === 0 : false handleVisible: Kirigami.Settings.isMobile ? !AudioManager.entry || footerLoader.item.contentY === 0 : false
showHeaderWhenCollapsed: true showHeaderWhenCollapsed: true
actions: [ actions: [
Kirigami.PagePoolAction { Kirigami.Action {
text: i18n("Queue") text: i18n("Queue")
iconName: "source-playlist" iconName: "source-playlist"
pagePool: mainPagePool checked: currentPage == "QueuePage"
page: "qrc:/QueuePage.qml"
onTriggered: { onTriggered: {
pushPage("QueuePage")
SettingsManager.lastOpenedPage = "QueuePage" // for persistency SettingsManager.lastOpenedPage = "QueuePage" // for persistency
tabBarActive = 0 tabBarActive = 0
} }
}, },
Kirigami.PagePoolAction { Kirigami.Action {
text: i18n("Episodes") text: i18n("Episodes")
iconName: "rss" iconName: "rss"
pagePool: mainPagePool checked: currentPage == "EpisodeSwipePage"
page: "qrc:/EpisodeSwipePage.qml"
onTriggered: { onTriggered: {
pushPage("EpisodeSwipePage")
SettingsManager.lastOpenedPage = "EpisodeSwipePage" // for persistency SettingsManager.lastOpenedPage = "EpisodeSwipePage" // for persistency
tabBarActive = 1 tabBarActive = 1
} }
}, },
Kirigami.PagePoolAction { Kirigami.Action {
text: i18n("Subscriptions") text: i18n("Subscriptions")
iconName: "document-open-folder" iconName: "document-open-folder"
pagePool: mainPagePool checked: currentPage == "FeedListPage"
page: "qrc:/FeedListPage.qml"
onTriggered: { onTriggered: {
pushPage("FeedListPage")
SettingsManager.lastOpenedPage = "FeedListPage" // for persistency SettingsManager.lastOpenedPage = "FeedListPage" // for persistency
tabBarActive = 0 tabBarActive = 0
} }
}, },
Kirigami.PagePoolAction { Kirigami.Action {
text: i18n("Downloads") text: i18n("Downloads")
iconName: "download" iconName: "download"
pagePool: mainPagePool checked: currentPage == "DownloadListPage"
page: "qrc:/DownloadListPage.qml"
onTriggered: { onTriggered: {
pushPage("DownloadListPage")
SettingsManager.lastOpenedPage = "DownloadListPage" // for persistency SettingsManager.lastOpenedPage = "DownloadListPage" // for persistency
tabBarActive = 0 tabBarActive = 0
} }
}, },
Kirigami.PagePoolAction { Kirigami.Action {
text: i18n("Settings") text: i18n("Settings")
iconName: "settings-configure" iconName: "settings-configure"
pagePool: mainPagePool checked: currentPage == "SettingsPage"
page: "qrc:/SettingsPage.qml" onTriggered: {
pushPage("SettingsPage")
}
}, },
Kirigami.PagePoolAction { Kirigami.Action {
text: i18n("About") text: i18n("About")
iconName: "help-about-symbolic" iconName: "help-about-symbolic"
pagePool: mainPagePool checked: currentPage == "AboutPage"
page: "qrc:/AboutPage.qml" onTriggered: {
pushPage("AboutPage")
}
} }
] ]
} }