@@ -17,6 +17,10 @@ import "../Components"
1717PageType {
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 ()
0 commit comments