diff --git a/client/ui/qml/Pages2/PageProtocolCloakSettings.qml b/client/ui/qml/Pages2/PageProtocolCloakSettings.qml index 1685431cd..48b59c87d 100644 --- a/client/ui/qml/Pages2/PageProtocolCloakSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolCloakSettings.qml @@ -140,6 +140,16 @@ PageType { ListElement { name : "aes-128-gcm" } } + function updateSelectedIndex() { + cipherDropDown.text = cipher + for (var i = 0; i < cipherListView.model.count; i++) { + if (cipherListView.model.get(i).name === cipher) { + selectedIndex = i + break + } + } + } + clickedFunction: function() { cipherDropDown.text = selectedText cipher = cipherDropDown.text @@ -147,13 +157,14 @@ PageType { } Component.onCompleted: { - cipherDropDown.text = cipher + updateSelectedIndex() + } + } - for (var i = 0; i < cipherListView.model.count; i++) { - if (cipherListView.model.get(i).name === cipherDropDown.text) { - selectedIndex = i - } - } + Connections { + target: listView.model + function onDataChanged() { + cipherListView.updateSelectedIndex() } } } diff --git a/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml b/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml index 664ad76c9..a11ed09ba 100644 --- a/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml @@ -192,6 +192,16 @@ PageType { ListElement { name : qsTr("SHA1") } } + function updateSelectedIndex() { + hashDropDown.text = hash + for (var i = 0; i < hashListView.model.count; i++) { + if (hashListView.model.get(i).name === hash) { + selectedIndex = i + break + } + } + } + clickedFunction: function() { hashDropDown.text = selectedText hash = hashDropDown.text @@ -199,13 +209,14 @@ PageType { } Component.onCompleted: { - hashDropDown.text = hash + updateSelectedIndex() + } + } - for (var i = 0; i < hashListView.model.count; i++) { - if (hashListView.model.get(i).name === hashDropDown.text) { - currentIndex = i - } - } + Connections { + target: listView.model + function onDataChanged() { + hashListView.updateSelectedIndex() } } } @@ -242,6 +253,16 @@ PageType { ListElement { name : qsTr("none") } } + function updateSelectedIndex() { + cipherDropDown.text = cipher + for (var i = 0; i < cipherListView.model.count; i++) { + if (cipherListView.model.get(i).name === cipher) { + selectedIndex = i + break + } + } + } + clickedFunction: function() { cipherDropDown.text = selectedText cipher = cipherDropDown.text @@ -249,13 +270,14 @@ PageType { } Component.onCompleted: { - cipherDropDown.text = cipher + updateSelectedIndex() + } + } - for (var i = 0; i < cipherListView.model.count; i++) { - if (cipherListView.model.get(i).name === cipherDropDown.text) { - currentIndex = i - } - } + Connections { + target: listView.model + function onDataChanged() { + cipherListView.updateSelectedIndex() } } } diff --git a/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml b/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml index 392115c6e..7d20d044a 100644 --- a/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolShadowSocksSettings.qml @@ -109,6 +109,16 @@ PageType { ListElement { name : "aes-128-gcm" } } + function updateSelectedIndex() { + cipherDropDown.text = cipher + for (var i = 0; i < cipherListView.model.count; i++) { + if (cipherListView.model.get(i).name === cipher) { + selectedIndex = i + break + } + } + } + clickedFunction: function() { cipherDropDown.text = selectedText cipher = cipherDropDown.text @@ -116,13 +126,14 @@ PageType { } Component.onCompleted: { - cipherDropDown.text = cipher + updateSelectedIndex() + } + } - for (var i = 0; i < cipherListView.model.count; i++) { - if (cipherListView.model.get(i).name === cipherDropDown.text) { - currentIndex = i - } - } + Connections { + target: listView.model + function onDataChanged() { + cipherListView.updateSelectedIndex() } } }