Fix sidebar/bottombar button state

BUG: 488563
This commit is contained in:
Bart De Vries 2025-01-06 16:08:16 +01:00
parent 1cb8aea181
commit b8d04153c9
No known key found for this signature in database
GPG Key ID: 7285665DA6E2D42B
3 changed files with 28 additions and 22 deletions

View File

@ -20,6 +20,10 @@ Kirigami.OverlayDrawer {
readonly property real widescreenBigWidth: Kirigami.Units.gridUnit * 10
readonly property int buttonDisplayMode: kastsMainWindow.isWidescreen ? Kirigami.NavigationTabButton.TextBesideIcon : Kirigami.NavigationTabButton.IconOnly
// Keep track of the settings page being opened on the layer stack for mobile
readonly property bool settingsOpened: kastsMainWindow.isMobile && pageStack.layers.depth >= 2 && pageStack.layers.currentItem.title === "Settings"
width: showGlobalDrawer ? (kastsMainWindow.isWidescreen ? widescreenBigWidth : pinnedWidth) : 0
Kirigami.Theme.colorSet: Kirigami.Theme.Window
@ -68,7 +72,7 @@ Kirigami.OverlayDrawer {
display: root.buttonDisplayMode
text: i18nc("@title of page showing the list queued items; this is the noun 'the queue', not the verb", "Queue")
icon.name: "source-playlist"
checked: currentPage == "QueuePage"
checked: currentPage == "QueuePage" && !settingsOpened
onClicked: {
pushPage("QueuePage")
}
@ -78,7 +82,7 @@ Kirigami.OverlayDrawer {
display: root.buttonDisplayMode
text: i18nc("@title of page allowing to search for new podcasts online", "Discover")
icon.name: "search"
checked: currentPage == "DiscoverPage"
checked: currentPage == "DiscoverPage" && !settingsOpened
onClicked: {
pushPage("DiscoverPage")
}
@ -88,7 +92,7 @@ Kirigami.OverlayDrawer {
display: root.buttonDisplayMode
text: i18nc("@title of page with list of podcast subscriptions", "Subscriptions")
icon.name: "bookmarks"
checked: currentPage == "FeedListPage"
checked: currentPage == "FeedListPage" && !settingsOpened
onClicked: {
pushPage("FeedListPage")
}
@ -98,7 +102,7 @@ Kirigami.OverlayDrawer {
display: root.buttonDisplayMode
text: i18nc("@title of page with list of podcast episodes", "Episodes")
icon.name: "rss"
checked: currentPage == "EpisodeListPage"
checked: currentPage == "EpisodeListPage" && !settingsOpened
onClicked: {
pushPage("EpisodeListPage")
}
@ -108,7 +112,7 @@ Kirigami.OverlayDrawer {
display: root.buttonDisplayMode
text: i18nc("@title of page with list of downloaded episodes", "Downloads")
icon.name: "download"
checked: currentPage == "DownloadListPage"
checked: currentPage == "DownloadListPage" && !settingsOpened
onClicked: {
pushPage("DownloadListPage")
}
@ -125,13 +129,12 @@ Kirigami.OverlayDrawer {
Kirigami.NavigationTabButton {
Layout.fillWidth: true
display: root.buttonDisplayMode
text: i18nc("@title of dialog with app settings", "Settings")
icon.name: "settings-configure"
checked: currentPage == "SettingsView"
checked: settingsOpened
onClicked: {
checked = false;
pushPage("SettingsView")
if (!kastsMainWindow.isMobile) checked = false;
pushPage("SettingsView");
}
}
}

View File

@ -27,8 +27,8 @@ Kirigami.ApplicationWindow {
property bool isMobile: Kirigami.Settings.isMobile
width: isMobile ? Kirigami.Units.gridUnit * 20 : Kirigami.Units.gridUnit * 45
height: isMobile ? Kirigami.Units.gridUnit * 37 : Kirigami.Units.gridUnit * 34
width: kastsMainWindow.isMobile ? Kirigami.Units.gridUnit * 20 : Kirigami.Units.gridUnit * 45
height: kastsMainWindow.isMobile ? Kirigami.Units.gridUnit * 37 : Kirigami.Units.gridUnit * 34
pageStack.clip: true
pageStack.popHiddenPages: true
@ -43,7 +43,7 @@ Kirigami.ApplicationWindow {
property var miniplayerSize: Kirigami.Units.gridUnit * 3 + Kirigami.Units.gridUnit / 6
property int bottomMessageSpacing: {
if (isMobile) {
if (kastsMainWindow.isMobile) {
return Kirigami.Units.largeSpacing + ( AudioManager.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 )
} else {
return Kirigami.Units.largeSpacing;
@ -57,7 +57,7 @@ Kirigami.ApplicationWindow {
function pushPage(page) {
if (page === "SettingsView") {
settingsView.open()
settingsView.open();
} else {
var pageObject = Qt.createComponent("org.kde.kasts", page);
if (!pageObject) {
@ -107,7 +107,7 @@ Kirigami.ApplicationWindow {
}
}
property bool showGlobalDrawer: !isMobile || kastsMainWindow.isWidescreen
property bool showGlobalDrawer: !kastsMainWindow.isMobile || kastsMainWindow.isWidescreen
globalDrawer: globalDrawerLoader.item
@ -136,7 +136,7 @@ Kirigami.ApplicationWindow {
header: Loader {
id: headerLoader
active: !isMobile
active: !kastsMainWindow.isMobile
visible: active
sourceComponent: HeaderBar { focus: true }
@ -144,13 +144,13 @@ Kirigami.ApplicationWindow {
// create space at the bottom to show miniplayer without it hiding stuff
// underneath
pageStack.anchors.bottomMargin: (AudioManager.entry && isMobile) ? miniplayerSize + 1 : 0
pageStack.anchors.bottomMargin: (AudioManager.entry && kastsMainWindow.isMobile) ? miniplayerSize + 1 : 0
Loader {
id: footerLoader
anchors.fill: parent
active: AudioManager.entry && isMobile
active: AudioManager.entry && kastsMainWindow.isMobile
visible: active
z: (!item || item.contentY === 0) ? -1 : 999
sourceComponent: FooterBar {
@ -178,7 +178,7 @@ Kirigami.ApplicationWindow {
id: bottomToolbarLoader
visible: active
height: visible ? implicitHeight : 0
active: isMobile && !kastsMainWindow.isWidescreen
active: kastsMainWindow.isMobile && !kastsMainWindow.isWidescreen
sourceComponent: BottomToolbar {
opacity: (!footerLoader.item || footerLoader.item.contentY === 0) ? 1 : 0
Behavior on opacity {

View File

@ -17,11 +17,14 @@ Kirigami.NavigationTabBar {
property alias toolbarHeight: navBar.implicitHeight
// Keep track of the settings page being opened on the layer stack for mobile
readonly property bool settingsOpened: kastsMainWindow.isMobile && pageStack.layers.depth >= 2 && pageStack.layers.currentItem.title === "Settings"
actions: [
Kirigami.Action {
icon.name: "view-media-playlist"
text: i18nc("@title of page showing the list queued items; this is the noun 'the queue', not the verb", "Queue")
checked: "QueuePage" === kastsMainWindow.currentPage
checked: "QueuePage" === kastsMainWindow.currentPage && !settingsOpened
onTriggered: {
pushPage("QueuePage");
}
@ -29,7 +32,7 @@ Kirigami.NavigationTabBar {
Kirigami.Action {
icon.name: "bookmarks"
text: i18nc("@title of page with list of podcast subscriptions", "Subscriptions")
checked: "FeedListPage" === kastsMainWindow.currentPage
checked: "FeedListPage" === kastsMainWindow.currentPage && !settingsOpened
onTriggered: {
pushPage("FeedListPage");
}
@ -37,7 +40,7 @@ Kirigami.NavigationTabBar {
Kirigami.Action {
icon.name: "rss"
text: i18nc("@title of page with list of podcast episodes", "Episodes")
checked: "EpisodeListPage" === kastsMainWindow.currentPage
checked: "EpisodeListPage" === kastsMainWindow.currentPage && !settingsOpened
onTriggered: {
pushPage("EpisodeListPage")
}
@ -45,7 +48,7 @@ Kirigami.NavigationTabBar {
Kirigami.Action {
icon.name: "settings-configure"
text: i18nc("@title of dialog with app settings", "Settings")
checked: "SettingsView" === kastsMainWindow.currentPage
checked: settingsOpened
onTriggered: {
pushPage("SettingsView");
}