Make menu replace pages instead of pushing

This commit is contained in:
Michael Zanetti 2020-11-29 18:35:37 +01:00
parent 3ab3f1119f
commit e6c96ff9ad
2 changed files with 21 additions and 7 deletions

View File

@ -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) {

View File

@ -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")