Skip to content

Commit 9db473a

Browse files
qml, component: correct ProxySettings behaviour
Making the option switches work to enable and disable the IP Address and Port fields (Proxy and Tor - ValueInput) accordingly to the user's intentions.
1 parent be965bf commit 9db473a

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/qml/components/ProxySettings.qml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,18 @@ ColumnLayout {
2020
}
2121
Separator { Layout.fillWidth: true }
2222
Setting {
23+
id: defaultProxyEnable
2324
Layout.fillWidth: true
2425
header: qsTr("Enable")
25-
actionItem: OptionSwitch {}
26+
actionItem: OptionSwitch {
27+
onCheckedChanged: {
28+
if (checked == false) {
29+
defaultProxy.state = "DISABLED"
30+
} else {
31+
defaultProxy.state = "ACTIVE"
32+
}
33+
}
34+
}
2635
onClicked: {
2736
loadedItem.toggle()
2837
loadedItem.toggled()
@@ -33,6 +42,8 @@ ColumnLayout {
3342
id: defaultProxy
3443
Layout.fillWidth: true
3544
header: qsTr("IP and Port")
45+
errorText: qsTr("Invalid IP address or port format. Please use the format '255.255.255.255:65535'.")
46+
state: !defaultProxyEnable.loadedItem.checked ? "DISABLED" : "ACTIVE"
3647
actionItem: ValueInput {
3748
parentState: defaultProxy.state
3849
description: "127.0.0.1:9050"
@@ -55,9 +66,18 @@ ColumnLayout {
5566
}
5667
Separator { Layout.fillWidth: true }
5768
Setting {
69+
id: torProxyEnable
5870
Layout.fillWidth: true
5971
header: qsTr("Enable")
60-
actionItem: OptionSwitch {}
72+
actionItem: OptionSwitch {
73+
onCheckedChanged: {
74+
if (checked == false) {
75+
torProxy.state = "DISABLED"
76+
} else {
77+
torProxy.state = "ACTIVE"
78+
}
79+
}
80+
}
6181
description: qsTr("When disabled, Tor connections will use the default proxy (if enabled).")
6282
onClicked: {
6383
loadedItem.toggle()
@@ -69,6 +89,8 @@ ColumnLayout {
6989
id: torProxy
7090
Layout.fillWidth: true
7191
header: qsTr("IP and Port")
92+
errorText: qsTr("Invalid IP address or port format. Please use the format '255.255.255.255:65535'.")
93+
state: !torProxyEnable.loadedItem.checked ? "DISABLED" : "ACTIVE"
7294
actionItem: ValueInput {
7395
parentState: torProxy.state
7496
description: "127.0.0.1:9050"

0 commit comments

Comments
 (0)