From e6c96ff9addd8fea520c1343309c05f36096c7ff Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 29 Nov 2020 18:35:37 +0100 Subject: [PATCH] Make menu replace pages instead of pushing --- libnymea-app/jsonrpc/jsonrpcclient.cpp | 2 +- nymea-app/ui/RootItem.qml | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/libnymea-app/jsonrpc/jsonrpcclient.cpp b/libnymea-app/jsonrpc/jsonrpcclient.cpp index 4426977a..796c43e3 100644 --- a/libnymea-app/jsonrpc/jsonrpcclient.cpp +++ b/libnymea-app/jsonrpc/jsonrpcclient.cpp @@ -175,7 +175,7 @@ void JsonRpcClient::setNotificationsEnabledResponse(int /*commandId*/, const QVa void JsonRpcClient::notificationReceived(const QVariantMap &data) { - qDebug() << "Notification received:" << data; +// qDebug() << "Notification received:" << data; if (data.value("notification").toString() == "JSONRPC.PushButtonAuthFinished") { qDebug() << "Push button auth finished."; if (data.value("params").toMap().value("transactionId").toInt() != m_pendingPushButtonTransaction) { diff --git a/nymea-app/ui/RootItem.qml b/nymea-app/ui/RootItem.qml index fc23ed6c..4c99d049 100644 --- a/nymea-app/ui/RootItem.qml +++ b/nymea-app/ui/RootItem.qml @@ -46,23 +46,37 @@ Item { return swipeView.currentItem.handleAndroidBackButton() } + QtObject { + id: d + // We want only one of them pushed at a time + property var currentSettingsPage: null + + function pushSettingsPage(page) { + if (d.currentSettingsPage != null) { + d.currentSettingsPage = swipeView.currentItem.pageStack.replace(d.currentSettingsPage, page); + } else { + d.currentSettingsPage = swipeView.currentItem.pageStack.push(page) + } + } + } + function openThingSettings() { - swipeView.currentItem.pageStack.push("thingconfiguration/EditThingsPage.qml") + d.pushSettingsPage("thingconfiguration/EditThingsPage.qml") } function openMagicSettings() { - swipeView.currentItem.pageStack.push("MagicPage.qml") + d.pushSettingsPage("MagicPage.qml") } function openAppSettings() { - swipeView.currentItem.pageStack.push("appsettings/AppSettingsPage.qml") + d.pushSettingsPage("appsettings/AppSettingsPage.qml") } function openSystemSettings() { - swipeView.currentItem.pageStack.push("SettingsPage.qml") + d.pushSettingsPage("SettingsPage.qml") } function startManualConnection() { - swipeView.currentItem.pageStack.push("connection/ManualConnectPage.qml") + d.pushSettingsPage("connection/ManualConnectPage.qml") } function startWirelessSetup() { - swipeView.currentItem.pageStack.push("connection/wifisetup/BluetoothDiscoveryPage.qml"); + d.pushSettingsPage("connection/wifisetup/BluetoothDiscoveryPage.qml"); } function startDemoMode() { var host = discovery.nymeaHosts.createWanHost("Demo server", "nymea://nymea.nymea.io:2222")