From 4d061affc4dccc29934b52c4322f767770132593 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Sun, 22 Nov 2020 11:35:08 +0100 Subject: [PATCH] Don't stack pages in layers and instead replace them --- qml/main.qml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/qml/main.qml b/qml/main.qml index 7966418eb..2f61ad4b2 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -73,6 +73,14 @@ Kirigami.ApplicationWindow { } } + function pushReplaceLayer(page, args) { + if (pageStack.layers.depth === 2) { + pageStack.layers.replace(page, args); + } else { + pageStack.layers.push(page, args); + } + } + TrayIcon { id: trayIcon visible: true @@ -90,29 +98,30 @@ Kirigami.ApplicationWindow { globalDrawer: Kirigami.GlobalDrawer { isMenu: true + property bool hasLayer actions: [ Kirigami.Action { text: i18n("Explore rooms") iconName: "compass" - onTriggered: pageStack.layers.push("qrc:/imports/NeoChat/Page/JoinRoomPage.qml", {"connection": Controller.activeConnection}) + onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/JoinRoomPage.qml", {"connection": Controller.activeConnection}) enabled: pageStack.layers.currentItem.title !== i18n("Explore Rooms") }, Kirigami.Action { text: i18n("Accounts") iconName: "im-user" - onTriggered: pageStack.layers.push("qrc:/imports/NeoChat/Page/AccountsPage.qml") + onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/AccountsPage.qml") enabled: pageStack.layers.currentItem.title !== i18n("Accounts") }, Kirigami.Action { text: i18n("Settings") iconName: "settings-configure" - onTriggered: pageStack.layers.push("qrc:/imports/NeoChat/Page/SettingsPage.qml") + onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/SettingsPage.qml") enabled: pageStack.layers.currentItem.title !== i18n("Settings") }, Kirigami.Action { text: i18n("About Neochat") iconName: "help-about" - onTriggered: pageStack.layers.push(aboutPage) + onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/AboutPage.qml") enabled: pageStack.layers.currentItem.title !== i18n("About") } ]