From 8f6453faa8399ce0caea2cbcbfdba07b40450e63 Mon Sep 17 00:00:00 2001 From: Mitternacht822 Date: Thu, 19 Jun 2025 23:10:59 +0400 Subject: [PATCH] added notification about disconnecting users after applying changes for SS and Cloak servers pages --- .../qml/Pages2/PageProtocolCloakSettings.qml | 41 ++++++++++++++++--- .../PageProtocolShadowSocksSettings.qml | 25 ++++++++--- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/client/ui/qml/Pages2/PageProtocolCloakSettings.qml b/client/ui/qml/Pages2/PageProtocolCloakSettings.qml index 7a0fafbd..f5873718 100644 --- a/client/ui/qml/Pages2/PageProtocolCloakSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolCloakSettings.qml @@ -62,6 +62,14 @@ PageType { implicitWidth: listview.width implicitHeight: col.implicitHeight + property var focusItemId: trafficFromField.neabled ? + trafficFromField : + portTextField.enabled ? + portTextField : + cipherDropDown.enabled ? + cipherDropDown : + saveRestartButton + property alias trafficFromField: trafficFromField ColumnLayout { @@ -88,6 +96,8 @@ PageType { Layout.fillWidth: true Layout.topMargin: 32 + enabled: isTrafficEditable + headerText: qsTr("Disguised as traffic from") textField.text: site @@ -112,6 +122,8 @@ PageType { Layout.fillWidth: true Layout.topMargin: 16 + enabled: isPortEditable + headerText: qsTr("Port") textField.text: port textField.maximumLength: 5 @@ -129,6 +141,8 @@ PageType { Layout.fillWidth: true Layout.topMargin: 16 + enabled: isCipherEditable + descriptionText: qsTr("Cipher") headerText: qsTr("Cipher") @@ -172,18 +186,35 @@ PageType { Layout.topMargin: 24 Layout.bottomMargin: 24 + enabled: isPortEditable | isTrafficEditable |isCipherEditable + text: qsTr("Save") clickedFunc: function() { forceActiveFocus() - if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) { - PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection")) - return + var headerText = qsTr("Save settings?") + var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.") + var yesButtonText = qsTr("Continue") + var noButtonText = qsTr("Cancel") + + var yesButtonFunction = function() { + if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) { + PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection")) + return + } + + PageController.goToPage(PageEnum.PageSetupWizardInstalling) + InstallController.updateContainer(CloakConfigModel.getConfig()) } - PageController.goToPage(PageEnum.PageSetupWizardInstalling); - InstallController.updateContainer(CloakConfigModel.getConfig()) + var noButtonFunction = function() { + if (!GC.isMobile()) { + saveButton.forceActiveFocus() + } + } + + showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction) } } } diff --git a/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml b/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml index 63e60dcb..25f35e3e 100644 --- a/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml @@ -162,13 +162,26 @@ PageType { clickedFunc: function() { forceActiveFocus() - if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) { - PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection")) - return - } + var headerText = qsTr("Save settings?") + var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.") + var yesButtonText = qsTr("Continue") + var noButtonText = qsTr("Cancel") - PageController.goToPage(PageEnum.PageSetupWizardInstalling); - InstallController.updateContainer(ShadowSocksConfigModel.getConfig()) + var yesButtonFunction = function() { + if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) { + PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection")) + return + } + + PageController.goToPage(PageEnum.PageSetupWizardInstalling); + InstallController.updateContainer(ShadowSocksConfigModel.getConfig()) + } + var noButtonFunction = function() { + if (!GC.isMobile()) { + saveRestartButton.forceActiveFocus() + } + } + showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction) } } }