From c4f573ab283f72d981cbf2fd29550524229ae67d Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 1 Sep 2023 12:35:32 +0200 Subject: [PATCH] Add a confirmation dialog when removing hosts --- nymea-app/ui/MainMenu.qml | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/nymea-app/ui/MainMenu.qml b/nymea-app/ui/MainMenu.qml index af2715bf..e1073867 100644 --- a/nymea-app/ui/MainMenu.qml +++ b/nymea-app/ui/MainMenu.qml @@ -29,6 +29,11 @@ Drawer { onClosed: topSectionLayout.configureConnections = false; + Settings { + id: tokenSettings + category: "jsonTokens" + } + ColumnLayout { anchors.fill: parent spacing: 0 @@ -107,11 +112,6 @@ Drawer { imageSource: "/ui/images/close.svg" visible: topSectionLayout.configureConnections && (autoConnectHost.length === 0 || index > 0) longpressEnabled: false - - Settings { - id: tokenSettings - category: "jsonTokens" - } } } @@ -156,13 +156,33 @@ Drawer { height: width enabled: topSectionLayout.configureConnections onClicked: { - tokenSettings.setValue(hostDelegate.configuredHost.uuid, "") - configuredHostsModel.removeHost(index) + print("host is:", hostDelegate.configuredHost.uuid) + if (hostDelegate.configuredHost.uuid != "{00000000-0000-0000-0000-000000000000}") { + var popup = askCloseDialog.createObject(app, {uuid: hostDelegate.configuredHost.uuid, index: index}) + popup.open(); + } else { + configuredHostsModel.removeHost(index) + } } } } } + Component { + id: askCloseDialog + NymeaDialog { + property string uuid + property int index + title: qsTr("Are you sure?") + text: qsTr("Do you want to log out from %1 and remove it from your connections?").arg(configuredHostsModel.get(index).name) + standardButtons: Dialog.Yes | Dialog.No + onAccepted: { + tokenSettings.setValue(uuid, "") + configuredHostsModel.removeHost(index) + } + } + } + NymeaItemDelegate { id: fakeDragItem visible: dndArea.dragging