Skip to content

Commit a9861d1

Browse files
authored
fix: wrong index on xray pages (#2669)
* test crash xray * fixed save config xray * reset file * fixed text port & reset file * fixed textFieldWithHeaderType.textField
1 parent c14138f commit a9861d1

7 files changed

Lines changed: 35 additions & 15 deletions

client/ui/qml/Pages2/PageProtocolXrayFlowSettings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ PageType {
112112
return
113113
}
114114
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
115-
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
115+
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
116116
}
117117
var noButtonFunction = function () {
118118
if (typeof GC !== "undefined" && !GC.isMobile()) {

client/ui/qml/Pages2/PageProtocolXraySecuritySettings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ PageType {
279279
return
280280
}
281281
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
282-
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
282+
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
283283
}
284284
var noButtonFunction = function () {
285285
if (typeof GC !== "undefined" && !GC.isMobile()) {

client/ui/qml/Pages2/PageProtocolXraySettings.qml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import "../Components"
1717
PageType {
1818
id: root
1919

20+
enableTimer: false
21+
22+
property bool portDirty: false
23+
2024
function formatTransport(value) {
2125
if (value === "raw") return "RAW (TCP)"
2226
if (value === "xhttp") return "XHTTP"
@@ -39,8 +43,8 @@ PageType {
3943
anchors.right: parent.right
4044
anchors.topMargin: 20 + PageController.safeAreaTopMargin
4145

42-
onFocusChanged: {
43-
if (this.activeFocus) {
46+
onActiveFocusChanged: {
47+
if (backButton.enabled && backButton.activeFocus) {
4448
listView.positionViewAtBeginning()
4549
}
4650
}
@@ -60,8 +64,6 @@ PageType {
6064
delegate: ColumnLayout {
6165
width: listView.width
6266

63-
property alias focusItemId: textFieldWithHeaderType.textField
64-
6567
spacing: 0
6668

6769
Text {
@@ -107,13 +109,32 @@ PageType {
107109
Layout.rightMargin: 16
108110
enabled: listView.enabled
109111
headerText: qsTr("Port")
110-
textField.text: port
112+
113+
Binding {
114+
target: textFieldWithHeaderType.textField
115+
property: "text"
116+
value: port
117+
when: !textFieldWithHeaderType.textField.activeFocus
118+
restoreMode: Binding.RestoreNone
119+
}
120+
111121
textField.maximumLength: 5
112122
textField.validator: IntValidator {
113123
bottom: 1; top: 65535
114124
}
125+
textField.onActiveFocusChanged: {
126+
if (textField.activeFocus && textField.text === "" && port !== "") {
127+
textField.text = port
128+
}
129+
}
130+
textField.onTextChanged: {
131+
root.portDirty = (textField.text !== port)
132+
}
115133
textField.onEditingFinished: {
116-
if (textField.text !== port) port = textField.text
134+
if (textField.text !== port) {
135+
port = textField.text
136+
}
137+
root.portDirty = false
117138
}
118139
checkEmptyText: true
119140
}
@@ -172,9 +193,8 @@ PageType {
172193
Layout.leftMargin: 16
173194
Layout.rightMargin: 16
174195
visible: listView.enabled
175-
&& (XrayConfigModel.hasUnsavedChanges
176-
|| textFieldWithHeaderType.textField.text !== port)
177-
enabled: visible && textFieldWithHeaderType.errorText === ""
196+
&& (XrayConfigModel.hasUnsavedChanges || root.portDirty)
197+
enabled: visible && textFieldWithHeaderType.textField.text !== ""
178198
text: qsTr("Save")
179199
onClicked: function() {
180200
forceActiveFocus()

client/ui/qml/Pages2/PageProtocolXrayTransportSettings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ PageType {
742742
return
743743
}
744744
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
745-
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
745+
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
746746
}
747747
var noButtonFunction = function () {
748748
if (typeof GC !== "undefined" && !GC.isMobile()) {

client/ui/qml/Pages2/PageProtocolXrayXPaddingBytesSettings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ PageType {
9595
return
9696
}
9797
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
98-
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
98+
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
9999
}
100100
var noButtonFunction = function () {
101101
if (typeof GC !== "undefined" && !GC.isMobile()) {

client/ui/qml/Pages2/PageProtocolXrayXPaddingSettings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ PageType {
211211
return
212212
}
213213
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
214-
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
214+
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
215215
}
216216
var noButtonFunction = function () {
217217
if (typeof GC !== "undefined" && !GC.isMobile()) {

client/ui/qml/Pages2/PageProtocolXrayXmuxSettings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ PageType {
208208
return
209209
}
210210
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
211-
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
211+
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
212212
}
213213
var noButtonFunction = function () {
214214
if (typeof GC !== "undefined" && !GC.isMobile()) {

0 commit comments

Comments
 (0)