fix: wrong index on xray pages (#2669)

* test crash xray

* fixed save config xray

* reset file

* fixed text port & reset file

* fixed textFieldWithHeaderType.textField
This commit is contained in:
yp
2026-06-01 07:22:54 +03:00
committed by GitHub
parent c14138f031
commit a9861d18b7
7 changed files with 35 additions and 15 deletions
@@ -112,7 +112,7 @@ PageType {
return return
} }
PageController.goToPage(PageEnum.PageSetupWizardInstalling) PageController.goToPage(PageEnum.PageSetupWizardInstalling)
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray) InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
} }
var noButtonFunction = function () { var noButtonFunction = function () {
if (typeof GC !== "undefined" && !GC.isMobile()) { if (typeof GC !== "undefined" && !GC.isMobile()) {
@@ -279,7 +279,7 @@ PageType {
return return
} }
PageController.goToPage(PageEnum.PageSetupWizardInstalling) PageController.goToPage(PageEnum.PageSetupWizardInstalling)
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray) InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
} }
var noButtonFunction = function () { var noButtonFunction = function () {
if (typeof GC !== "undefined" && !GC.isMobile()) { if (typeof GC !== "undefined" && !GC.isMobile()) {
@@ -17,6 +17,10 @@ import "../Components"
PageType { PageType {
id: root id: root
enableTimer: false
property bool portDirty: false
function formatTransport(value) { function formatTransport(value) {
if (value === "raw") return "RAW (TCP)" if (value === "raw") return "RAW (TCP)"
if (value === "xhttp") return "XHTTP" if (value === "xhttp") return "XHTTP"
@@ -39,8 +43,8 @@ PageType {
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: 20 + PageController.safeAreaTopMargin anchors.topMargin: 20 + PageController.safeAreaTopMargin
onFocusChanged: { onActiveFocusChanged: {
if (this.activeFocus) { if (backButton.enabled && backButton.activeFocus) {
listView.positionViewAtBeginning() listView.positionViewAtBeginning()
} }
} }
@@ -60,8 +64,6 @@ PageType {
delegate: ColumnLayout { delegate: ColumnLayout {
width: listView.width width: listView.width
property alias focusItemId: textFieldWithHeaderType.textField
spacing: 0 spacing: 0
Text { Text {
@@ -107,13 +109,32 @@ PageType {
Layout.rightMargin: 16 Layout.rightMargin: 16
enabled: listView.enabled enabled: listView.enabled
headerText: qsTr("Port") headerText: qsTr("Port")
textField.text: port
Binding {
target: textFieldWithHeaderType.textField
property: "text"
value: port
when: !textFieldWithHeaderType.textField.activeFocus
restoreMode: Binding.RestoreNone
}
textField.maximumLength: 5 textField.maximumLength: 5
textField.validator: IntValidator { textField.validator: IntValidator {
bottom: 1; top: 65535 bottom: 1; top: 65535
} }
textField.onActiveFocusChanged: {
if (textField.activeFocus && textField.text === "" && port !== "") {
textField.text = port
}
}
textField.onTextChanged: {
root.portDirty = (textField.text !== port)
}
textField.onEditingFinished: { textField.onEditingFinished: {
if (textField.text !== port) port = textField.text if (textField.text !== port) {
port = textField.text
}
root.portDirty = false
} }
checkEmptyText: true checkEmptyText: true
} }
@@ -172,9 +193,8 @@ PageType {
Layout.leftMargin: 16 Layout.leftMargin: 16
Layout.rightMargin: 16 Layout.rightMargin: 16
visible: listView.enabled visible: listView.enabled
&& (XrayConfigModel.hasUnsavedChanges && (XrayConfigModel.hasUnsavedChanges || root.portDirty)
|| textFieldWithHeaderType.textField.text !== port) enabled: visible && textFieldWithHeaderType.textField.text !== ""
enabled: visible && textFieldWithHeaderType.errorText === ""
text: qsTr("Save") text: qsTr("Save")
onClicked: function() { onClicked: function() {
forceActiveFocus() forceActiveFocus()
@@ -742,7 +742,7 @@ PageType {
return return
} }
PageController.goToPage(PageEnum.PageSetupWizardInstalling) PageController.goToPage(PageEnum.PageSetupWizardInstalling)
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray) InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
} }
var noButtonFunction = function () { var noButtonFunction = function () {
if (typeof GC !== "undefined" && !GC.isMobile()) { if (typeof GC !== "undefined" && !GC.isMobile()) {
@@ -95,7 +95,7 @@ PageType {
return return
} }
PageController.goToPage(PageEnum.PageSetupWizardInstalling) PageController.goToPage(PageEnum.PageSetupWizardInstalling)
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray) InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
} }
var noButtonFunction = function () { var noButtonFunction = function () {
if (typeof GC !== "undefined" && !GC.isMobile()) { if (typeof GC !== "undefined" && !GC.isMobile()) {
@@ -211,7 +211,7 @@ PageType {
return return
} }
PageController.goToPage(PageEnum.PageSetupWizardInstalling) PageController.goToPage(PageEnum.PageSetupWizardInstalling)
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray) InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
} }
var noButtonFunction = function () { var noButtonFunction = function () {
if (typeof GC !== "undefined" && !GC.isMobile()) { if (typeof GC !== "undefined" && !GC.isMobile()) {
@@ -208,7 +208,7 @@ PageType {
return return
} }
PageController.goToPage(PageEnum.PageSetupWizardInstalling) PageController.goToPage(PageEnum.PageSetupWizardInstalling)
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray) InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
} }
var noButtonFunction = function () { var noButtonFunction = function () {
if (typeof GC !== "undefined" && !GC.isMobile()) { if (typeof GC !== "undefined" && !GC.isMobile()) {