Only show single page at any time, and pop pages that aren't visible

This commit is contained in:
Devin Lin 2022-08-17 12:04:36 -04:00 committed by Bart De Vries
parent fdeb4c501a
commit 9860c8b9e5
1 changed files with 27 additions and 7 deletions

View File

@ -20,11 +20,16 @@ Kirigami.ApplicationWindow {
id: root id: root
title: "Kasts" title: "Kasts"
pageStack.clip: true
width: Kirigami.Settings.isMobile ? 360 : 800 width: Kirigami.Settings.isMobile ? 360 : 800
height: Kirigami.Settings.isMobile ? 660 : 600 height: Kirigami.Settings.isMobile ? 660 : 600
pageStack.clip: true
pageStack.globalToolBar.style: Kirigami.ApplicationHeaderStyle.ToolBar;
pageStack.globalToolBar.showNavigationButtons: Kirigami.ApplicationHeaderStyle.ShowBackButton;
// only have a single page visible at any time
pageStack.columnView.columnResizeMode: Kirigami.ColumnView.SingleColumn
minimumWidth: Kirigami.Units.gridUnit * 17 minimumWidth: Kirigami.Units.gridUnit * 17
minimumHeight: Kirigami.Units.gridUnit * 12 minimumHeight: Kirigami.Units.gridUnit * 12
@ -91,6 +96,26 @@ Kirigami.ApplicationWindow {
} }
} }
// pop pages when not in use
Connections {
target: applicationWindow().pageStack
function onCurrentIndexChanged() {
// wait for animation to finish before popping pages
timer.restart();
}
}
Timer {
id: timer
interval: 300
onTriggered: {
let currentIndex = applicationWindow().pageStack.currentIndex;
while (applicationWindow().pageStack.depth > (currentIndex + 1) && currentIndex >= 0) {
applicationWindow().pageStack.pop();
}
}
}
Component.onDestruction: { Component.onDestruction: {
saveWindowLayout(); saveWindowLayout();
} }
@ -100,11 +125,6 @@ Kirigami.ApplicationWindow {
currentPage = SettingsManager.lastOpenedPage; currentPage = SettingsManager.lastOpenedPage;
pageStack.initialPage = getPage(SettingsManager.lastOpenedPage); pageStack.initialPage = getPage(SettingsManager.lastOpenedPage);
if (Kirigami.Settings.isMobile) {
pageStack.globalToolBar.style = Kirigami.ApplicationHeaderStyle.ToolBar;
pageStack.globalToolBar.showNavigationButtons = Kirigami.ApplicationHeaderStyle.ShowBackButton;
}
// Delete played enclosures if set in settings // Delete played enclosures if set in settings
if (SettingsManager.autoDeleteOnPlayed == 2) { if (SettingsManager.autoDeleteOnPlayed == 2) {
DataManager.deletePlayedEnclosures(); DataManager.deletePlayedEnclosures();