fix: notification not showing when changed some protocols (#1666)

* added notification about disconnecting users after applying changes for SS and Cloak servers pages

* added notification about changing protocol data for server and some minor changes
This commit is contained in:
Mitternacht822 2025-07-02 06:11:52 +04:00 committed by GitHub
parent b0a6bcc055
commit 9dca80de18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 146 additions and 49 deletions

View file

@ -59,10 +59,13 @@ PageType {
model: CloakConfigModel model: CloakConfigModel
delegate: Item { delegate: Item {
implicitWidth: listview.width id: delegateItem
implicitHeight: col.implicitHeight
property alias trafficFromField: trafficFromField property alias trafficFromField: trafficFromField
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
implicitWidth: listview.width
implicitHeight: col.implicitHeight
ColumnLayout { ColumnLayout {
id: col id: col
@ -78,7 +81,6 @@ PageType {
BaseHeaderType { BaseHeaderType {
Layout.fillWidth: true Layout.fillWidth: true
headerText: qsTr("Cloak settings") headerText: qsTr("Cloak settings")
} }
@ -88,6 +90,8 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 32 Layout.topMargin: 32
enabled: delegateItem.isEnabled
headerText: qsTr("Disguised as traffic from") headerText: qsTr("Disguised as traffic from")
textField.text: site textField.text: site
@ -104,6 +108,8 @@ PageType {
} }
} }
} }
checkEmptyText: true
} }
TextFieldWithHeaderType { TextFieldWithHeaderType {
@ -112,6 +118,8 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 16 Layout.topMargin: 16
enabled: delegateItem.isEnabled
headerText: qsTr("Port") headerText: qsTr("Port")
textField.text: port textField.text: port
textField.maximumLength: 5 textField.maximumLength: 5
@ -122,6 +130,8 @@ PageType {
port = textField.text port = textField.text
} }
} }
checkEmptyText: true
} }
DropDownType { DropDownType {
@ -129,6 +139,8 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 16 Layout.topMargin: 16
enabled: delegateItem.isEnabled
descriptionText: qsTr("Cipher") descriptionText: qsTr("Cipher")
headerText: qsTr("Cipher") headerText: qsTr("Cipher")
@ -166,25 +178,46 @@ PageType {
} }
BasicButtonType { BasicButtonType {
id: saveRestartButton id: saveButton
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 24 Layout.topMargin: 24
Layout.bottomMargin: 24 Layout.bottomMargin: 24
enabled: trafficFromField.errorText === "" &&
portTextField.errorText === ""
text: qsTr("Save") text: qsTr("Save")
clickedFunc: function() { clickedFunc: function() {
forceActiveFocus() forceActiveFocus()
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) { var headerText = qsTr("Save settings?")
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection")) var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
return 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); var noButtonFunction = function() {
InstallController.updateContainer(CloakConfigModel.getConfig()) if (!GC.isMobile()) {
saveButton.forceActiveFocus()
}
}
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
} }
Keys.onEnterPressed: saveButton.clicked()
Keys.onReturnPressed: saveButton.clicked()
} }
} }
} }

View file

@ -58,10 +58,13 @@ PageType {
model: OpenVpnConfigModel model: OpenVpnConfigModel
delegate: Item { delegate: Item {
implicitWidth: listview.width id: delegateItem
implicitHeight: col.implicitHeight
property alias vpnAddressSubnetTextField: vpnAddressSubnetTextField property alias vpnAddressSubnetTextField: vpnAddressSubnetTextField
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
implicitWidth: listview.width
implicitHeight: col.implicitHeight
ColumnLayout { ColumnLayout {
id: col id: col
@ -77,7 +80,6 @@ PageType {
BaseHeaderType { BaseHeaderType {
Layout.fillWidth: true Layout.fillWidth: true
headerText: qsTr("OpenVPN settings") headerText: qsTr("OpenVPN settings")
} }
@ -87,6 +89,8 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 32 Layout.topMargin: 32
enabled: delegateItem.isEnabled
headerText: qsTr("VPN address subnet") headerText: qsTr("VPN address subnet")
textField.text: subnetAddress textField.text: subnetAddress
@ -97,6 +101,8 @@ PageType {
subnetAddress = textField.text subnetAddress = textField.text
} }
} }
checkEmptyText: true
} }
ParagraphTextType { ParagraphTextType {
@ -134,7 +140,7 @@ PageType {
Layout.topMargin: 40 Layout.topMargin: 40
parentFlickable: fl parentFlickable: fl
enabled: isPortEditable enabled: delegateItem.isEnabled
headerText: qsTr("Port") headerText: qsTr("Port")
textField.text: port textField.text: port
@ -146,6 +152,8 @@ PageType {
port = textField.text port = textField.text
} }
} }
checkEmptyText: true
} }
SwitcherType { SwitcherType {
@ -388,26 +396,45 @@ PageType {
} }
BasicButtonType { BasicButtonType {
id: saveRestartButton id: saveButton
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 24 Layout.topMargin: 24
Layout.bottomMargin: 24 Layout.bottomMargin: 24
enabled: vpnAddressSubnetTextField.errorText === "" &&
portTextField.errorText === ""
text: qsTr("Save") text: qsTr("Save")
parentFlickable: fl parentFlickable: fl
clickedFunc: function() { onClicked: function() {
forceActiveFocus() forceActiveFocus()
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) { var headerText = qsTr("Save settings?")
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection")) var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
return var yesButtonText = qsTr("Continue")
} var noButtonText = qsTr("Cancel")
PageController.goToPage(PageEnum.PageSetupWizardInstalling); var yesButtonFunction = function() {
InstallController.updateContainer(OpenVpnConfigModel.getConfig()) 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(OpenVpnConfigModel.getConfig())
}
var noButtonFunction = function() {
if (!GC.isMobile()) {
saveButton.forceActiveFocus()
}
}
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
} }
Keys.onEnterPressed: saveButton.clicked()
Keys.onReturnPressed: saveButton.clicked()
} }
} }
} }

View file

@ -57,15 +57,13 @@ PageType {
model: ShadowSocksConfigModel model: ShadowSocksConfigModel
delegate: Item { delegate: Item {
id: delegateItem
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
implicitWidth: listview.width implicitWidth: listview.width
implicitHeight: col.implicitHeight implicitHeight: col.implicitHeight
property var focusItemId: portTextField.enabled ?
portTextField :
cipherDropDown.enabled ?
cipherDropDown :
saveRestartButton
ColumnLayout { ColumnLayout {
id: col id: col
@ -80,7 +78,6 @@ PageType {
BaseHeaderType { BaseHeaderType {
Layout.fillWidth: true Layout.fillWidth: true
headerText: qsTr("Shadowsocks settings") headerText: qsTr("Shadowsocks settings")
} }
@ -90,7 +87,7 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 40 Layout.topMargin: 40
enabled: isPortEditable enabled: delegateItem.isEnabled
headerText: qsTr("Port") headerText: qsTr("Port")
textField.text: port textField.text: port
@ -102,6 +99,8 @@ PageType {
port = textField.text port = textField.text
} }
} }
checkEmptyText: true
} }
DropDownType { DropDownType {
@ -109,7 +108,7 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
enabled: isCipherEditable enabled: delegateItem.isEnabled
descriptionText: qsTr("Cipher") descriptionText: qsTr("Cipher")
headerText: qsTr("Cipher") headerText: qsTr("Cipher")
@ -149,27 +148,43 @@ PageType {
} }
BasicButtonType { BasicButtonType {
id: saveRestartButton id: saveButton
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 24 Layout.topMargin: 24
Layout.bottomMargin: 24 Layout.bottomMargin: 24
enabled: isPortEditable | isCipherEditable enabled: portTextField.errorText === ""
text: qsTr("Save") text: qsTr("Save")
clickedFunc: function() { clickedFunc: function() {
forceActiveFocus() forceActiveFocus()
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) { var headerText = qsTr("Save settings?")
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection")) var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
return var yesButtonText = qsTr("Continue")
} var noButtonText = qsTr("Cancel")
PageController.goToPage(PageEnum.PageSetupWizardInstalling); var yesButtonFunction = function() {
InstallController.updateContainer(ShadowSocksConfigModel.getConfig()) 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()) {
saveButton.forceActiveFocus()
}
}
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
} }
Keys.onEnterPressed: saveButton.clicked()
Keys.onReturnPressed: saveButton.clicked()
} }
} }
} }

View file

@ -152,7 +152,7 @@ PageType {
} }
var noButtonFunction = function() { var noButtonFunction = function() {
if (!GC.isMobile()) { if (!GC.isMobile()) {
saveRestartButton.forceActiveFocus() saveButton.forceActiveFocus()
} }
} }
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction) showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)

View file

@ -58,7 +58,10 @@ PageType {
model: XrayConfigModel model: XrayConfigModel
delegate: Item { delegate: Item {
id: delegateItem
property alias focusItemId: textFieldWithHeaderType.textField property alias focusItemId: textFieldWithHeaderType.textField
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
implicitWidth: listview.width implicitWidth: listview.width
implicitHeight: col.implicitHeight implicitHeight: col.implicitHeight
@ -85,6 +88,8 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 32 Layout.topMargin: 32
enabled: delegateItem.isEnabled
headerText: qsTr("Disguised as traffic from") headerText: qsTr("Disguised as traffic from")
textField.text: site textField.text: site
@ -101,6 +106,8 @@ PageType {
} }
} }
} }
checkEmptyText: true
} }
TextFieldWithHeaderType { TextFieldWithHeaderType {
@ -130,23 +137,38 @@ PageType {
Layout.topMargin: 24 Layout.topMargin: 24
Layout.bottomMargin: 24 Layout.bottomMargin: 24
enabled: portTextField.errorText === ""
text: qsTr("Save") text: qsTr("Save")
onClicked: { onClicked: function() {
forceActiveFocus() forceActiveFocus()
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) { var headerText = qsTr("Save settings?")
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection")) var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
return var yesButtonText = qsTr("Continue")
} var noButtonText = qsTr("Cancel")
PageController.goToPage(PageEnum.PageSetupWizardInstalling); var yesButtonFunction = function() {
InstallController.updateContainer(XrayConfigModel.getConfig()) if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
focusItem.forceActiveFocus() PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
return
}
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.updateContainer(XrayConfigModel.getConfig())
//focusItem.forceActiveFocus()
}
var noButtonFunction = function() {
if (!GC.isMobile()) {
saveButton.forceActiveFocus()
}
}
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
} }
Keys.onEnterPressed: basicButton.clicked() Keys.onEnterPressed: saveButton.clicked()
Keys.onReturnPressed: basicButton.clicked() Keys.onReturnPressed: saveButton.clicked()
} }
} }
} }