From 051a2a3ef2bf0447765fb3829cf99c4bacbb829d Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 27 Jan 2023 10:25:14 +0300 Subject: [PATCH] Added popup to confirm actions "Clear server from Amnesia software" and "Forget this server" --- client/containers/containers_defs.cpp | 2 +- client/resources.qrc | 1 + client/ui/qml/Controls/PopupWithQuestion.qml | 55 ++++++++++++++++++++ client/ui/qml/Pages/PageServerSettings.qml | 31 +++++++++-- 4 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 client/ui/qml/Controls/PopupWithQuestion.qml diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index 3313a772..c9ee2959 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -70,7 +70,7 @@ QList ContainerProps::allContainers() QMap ContainerProps::containerHumanNames() { return { - {DockerContainer::None, "Unknown (Old version)"}, + {DockerContainer::None, "Not installed"}, {DockerContainer::OpenVpn, "OpenVPN"}, {DockerContainer::ShadowSocks, "OpenVpn over ShadowSocks"}, {DockerContainer::Cloak, "OpenVpn over Cloak"}, diff --git a/client/resources.qrc b/client/resources.qrc index 105c06b8..4651f91e 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -163,5 +163,6 @@ images/svg/control_point_black_24dp.svg images/svg/settings_suggest_black_24dp.svg server_scripts/website_tor/Dockerfile + ui/qml/Controls/PopupWithQuestion.qml diff --git a/client/ui/qml/Controls/PopupWithQuestion.qml b/client/ui/qml/Controls/PopupWithQuestion.qml new file mode 100644 index 00000000..a5ea4611 --- /dev/null +++ b/client/ui/qml/Controls/PopupWithQuestion.qml @@ -0,0 +1,55 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +Popup { + id: root + + property string questionText + property string yesText: "yes" + property string noText: "no" + property var yesFunc + property var noFunc + + anchors.centerIn: Overlay.overlay + modal: true + closePolicy: Popup.NoAutoClose + + width: parent.width - 20 + + ColumnLayout { + width: parent.width + Text { + horizontalAlignment: Text.AlignHCenter + Layout.fillWidth: true + wrapMode: Text.WordWrap + font.pixelSize: 16 + text: questionText + } + + RowLayout { + BlueButtonType { + id: yesButton + Layout.fillWidth: true + text: yesText + onClicked: { + root.enabled = false + if (yesFunc && typeof yesFunc === "function") { + yesFunc() + } + root.enabled = true + } + } + BlueButtonType { + id: noButton + Layout.fillWidth: true + text: noText + onClicked: { + if (noFunc && typeof noFunc === "function") { + noFunc() + } + } + } + } + } +} diff --git a/client/ui/qml/Pages/PageServerSettings.qml b/client/ui/qml/Pages/PageServerSettings.qml index 921cc8d9..1c7f2248 100644 --- a/client/ui/qml/Pages/PageServerSettings.qml +++ b/client/ui/qml/Pages/PageServerSettings.qml @@ -93,24 +93,49 @@ PageBase { ServerSettingsLogic.onPushButtonClearClientCacheClicked() } } + BlueButtonType { Layout.fillWidth: true Layout.topMargin: 10 text: ServerSettingsLogic.pushButtonClearText visible: ServerSettingsLogic.pushButtonClearVisible - onClicked: { - ServerSettingsLogic.onPushButtonClearServer() + onClicked: { + popupClearServer.open() } } + + PopupWithQuestion { + id: popupClearServer + questionText: "Attention! All containers will be deleted on the server. This means that configuration files, keys and certificates will be deleted. Continue?" + yesFunc: function() { + ServerSettingsLogic.onPushButtonClearServer() + close() + } + noFunc: function() { + close() + } + } + BlueButtonType { Layout.fillWidth: true Layout.topMargin: 10 text: qsTr("Forget this server") onClicked: { - ServerSettingsLogic.onPushButtonForgetServer() + popupForgetServer.open() } } + PopupWithQuestion { + id: popupForgetServer + questionText: "Attention! Something will happen. Continue?" + yesFunc: function() { + ServerSettingsLogic.onPushButtonForgetServer() + close() + } + noFunc: function() { + close() + } + } } }