From 2d7c49fa7acb59adc9d136e6eb2102aab21ff5f4 Mon Sep 17 00:00:00 2001 From: ronoaer Date: Thu, 21 Sep 2023 16:24:43 +0800 Subject: [PATCH 1/2] updated settings without 'save and restart...' --- client/ui/controllers/installController.cpp | 9 +++++++++ client/ui/controllers/installController.h | 1 + client/ui/qml/Pages2/PageProtocolCloakSettings.qml | 4 ++++ client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml | 4 ++++ client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/client/ui/controllers/installController.cpp b/client/ui/controllers/installController.cpp index 63510d1a0..50f1d589c 100644 --- a/client/ui/controllers/installController.cpp +++ b/client/ui/controllers/installController.cpp @@ -281,6 +281,15 @@ void InstallController::removeCurrentlyProcessedServer() emit removeCurrentlyProcessedServerFinished(tr("Server '") + serverName + tr("' was removed")); } +void InstallController::updateContainerOnlyMemory(QJsonObject config) +{ + const DockerContainer container = ContainerProps::containerFromString(config.value(config_key::container).toString()); + auto modelIndex = m_containersModel->index(container); + m_containersModel->setData(modelIndex, config, ContainersModel::Roles::ConfigRole); + + m_protocolModel->updateModel(config); +} + void InstallController::removeAllContainers() { int serverIndex = m_serversModel->getCurrentlyProcessedServerIndex(); diff --git a/client/ui/controllers/installController.h b/client/ui/controllers/installController.h index a5fd28753..30e8b7381 100644 --- a/client/ui/controllers/installController.h +++ b/client/ui/controllers/installController.h @@ -29,6 +29,7 @@ public slots: void scanServerForInstalledContainers(); void updateContainer(QJsonObject config); + void updateContainerOnlyMemory(QJsonObject config); void removeCurrentlyProcessedServer(); void removeAllContainers(); diff --git a/client/ui/qml/Pages2/PageProtocolCloakSettings.qml b/client/ui/qml/Pages2/PageProtocolCloakSettings.qml index 78e666a7e..e0ae348ce 100644 --- a/client/ui/qml/Pages2/PageProtocolCloakSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolCloakSettings.qml @@ -23,6 +23,10 @@ PageType { anchors.topMargin: 20 BackButtonType { + backButtonFunction: function() { + InstallController.updateContainerOnlyMemory(CloakConfigModel.getConfig()) + PageController.closePage() + } } } diff --git a/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml b/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml index 491bdf31e..c05aaf3f0 100644 --- a/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml @@ -25,6 +25,10 @@ PageType { anchors.topMargin: 20 BackButtonType { + backButtonFunction: function() { + InstallController.updateContainerOnlyMemory(OpenVpnConfigModel.getConfig()) + PageController.closePage() + } } } diff --git a/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml b/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml index 2453281fe..8d26b39ba 100644 --- a/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml @@ -23,6 +23,10 @@ PageType { anchors.topMargin: 20 BackButtonType { + backButtonFunction: function() { + InstallController.updateContainerOnlyMemory(ShadowSocksConfigModel.getConfig()) + PageController.closePage() + } } } From da711a7c8a2e86118e1b1cdc2df88219913aa58a Mon Sep 17 00:00:00 2001 From: ronoaer Date: Thu, 21 Sep 2023 17:04:44 +0800 Subject: [PATCH 2/2] forced focus-changed --- client/ui/qml/Pages2/PageProtocolCloakSettings.qml | 1 + client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml | 1 + client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml | 1 + 3 files changed, 3 insertions(+) diff --git a/client/ui/qml/Pages2/PageProtocolCloakSettings.qml b/client/ui/qml/Pages2/PageProtocolCloakSettings.qml index e0ae348ce..f7812797c 100644 --- a/client/ui/qml/Pages2/PageProtocolCloakSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolCloakSettings.qml @@ -24,6 +24,7 @@ PageType { BackButtonType { backButtonFunction: function() { + forceActiveFocus() InstallController.updateContainerOnlyMemory(CloakConfigModel.getConfig()) PageController.closePage() } diff --git a/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml b/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml index c05aaf3f0..b54da1b48 100644 --- a/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml @@ -26,6 +26,7 @@ PageType { BackButtonType { backButtonFunction: function() { + forceActiveFocus() InstallController.updateContainerOnlyMemory(OpenVpnConfigModel.getConfig()) PageController.closePage() } diff --git a/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml b/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml index 8d26b39ba..1a65cc7ec 100644 --- a/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml @@ -24,6 +24,7 @@ PageType { BackButtonType { backButtonFunction: function() { + forceActiveFocus() InstallController.updateContainerOnlyMemory(ShadowSocksConfigModel.getConfig()) PageController.closePage() }