From afc0332e742c2f0bc24151d39c7a0b2d21694088 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 16 May 2019 01:40:21 +0200 Subject: [PATCH] Add some question popups before doing upgrading --- libnymea-app-core/jsonrpc/jsonrpcclient.cpp | 2 +- nymea-app/ui/SettingsPage.qml | 1 + nymea-app/ui/system/SystemUpdatePage.qml | 29 +++++++++++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/libnymea-app-core/jsonrpc/jsonrpcclient.cpp b/libnymea-app-core/jsonrpc/jsonrpcclient.cpp index 64d67b29..7f911646 100644 --- a/libnymea-app-core/jsonrpc/jsonrpcclient.cpp +++ b/libnymea-app-core/jsonrpc/jsonrpcclient.cpp @@ -304,7 +304,7 @@ void JsonRpcClient::sendRequest(const QVariantMap &request) { QVariantMap newRequest = request; newRequest.insert("token", m_token); -// qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson()); + qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson()); m_connection->sendData(QJsonDocument::fromVariant(newRequest).toJson(QJsonDocument::Compact) + "\n"); } diff --git a/nymea-app/ui/SettingsPage.qml b/nymea-app/ui/SettingsPage.qml index 5d150bb7..5a393bc8 100644 --- a/nymea-app/ui/SettingsPage.qml +++ b/nymea-app/ui/SettingsPage.qml @@ -158,6 +158,7 @@ Page { Pane { Layout.fillWidth: true Material.elevation: layout.isGrid ? 1 : 0 + visible: engine.jsonRpcClient.ensureServerVersion("2.1") padding: 0 MeaListItemDelegate { diff --git a/nymea-app/ui/system/SystemUpdatePage.qml b/nymea-app/ui/system/SystemUpdatePage.qml index 791cb18e..37b5715e 100644 --- a/nymea-app/ui/system/SystemUpdatePage.qml +++ b/nymea-app/ui/system/SystemUpdatePage.qml @@ -52,7 +52,15 @@ Page { text: qsTr("Update system") visible: engine.systemController.updateAvailable onClicked: { - engine.systemController.startUpdate() + var dialog = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml")); + var text = settings.showHiddenOptions + ? qsTr("Developer options are now enabled. If you have found this by accident, it is most likely not of any use for you. It will just enable some nerdy developer gibberish in the app. Tap the icon another 10 times to disable it again.") + : qsTr("Developer options are now disabled.") + var popup = dialog.createObject(app, {headerIcon: "../images/dialog-warning-symbolic.svg", title: qsTr("Howdy cowboy!"), text: text}) + popup.open(); + popup.accepted.connect(function() { + engine.systemController.startUpdate() + }) } } @@ -75,7 +83,23 @@ Page { model: engine.systemController.availableChannels currentIndex: model.indexOf(engine.systemController.currentChannel) onActivated: { - engine.systemController.selectChannel(model[index]) + var dialog = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml")); + var text = qsTr("Changing the update channel allows to install unreleased software. This can potentially harm your system and lead to problems. Please only use this if you are sure you want this and consider reporting the issues you find when testing unreleased channels. Thank you.") + var popup = dialog.createObject(app, + { + headerIcon: "../images/dialog-warning-symbolic.svg", + title: qsTr("Switch update channel"), + text: text, + standardButtons: Dialog.Ok | Dialog.Cancel + }); + popup.open(); + popup.accepted.connect(function() { + engine.systemController.selectChannel(model[index]) + }) + popup.rejected.connect(function() { + currentIndex = model.indexOf(engine.systemController.currentChannel) + }) + } } } @@ -84,4 +108,5 @@ Page { BusyOverlay { visible: engine.systemController.updateInProgress } + }