diff --git a/src/gui/Pages/AccountSettings/General.qml b/src/gui/Pages/AccountSettings/General.qml index 5d875b68..793c61b4 100644 --- a/src/gui/Pages/AccountSettings/General.qml +++ b/src/gui/Pages/AccountSettings/General.qml @@ -58,6 +58,16 @@ HFlickableColumnPage { } function cancel() { + if ( + ! nameField.item.changed && + ! aliasFieldItem.changed && + ! fileDialog.selectedFile && + ! fileDialog.file + ) { + pageLoader.showPrevious() || mainUI.mainPane.toggleFocus() + return + } + nameField.item.reset() aliasFieldItem.reset() fileDialog.selectedFile = "" @@ -82,7 +92,7 @@ HFlickableColumnPage { } CancelButton { - enabled: saveButton.enabled && ! saveButton.loading + enabled: ! saveButton.loading onClicked: cancel() } } diff --git a/src/gui/Pages/AddAccount/ServerBrowser.qml b/src/gui/Pages/AddAccount/ServerBrowser.qml index 60ac3ffd..cf816b02 100644 --- a/src/gui/Pages/AddAccount/ServerBrowser.qml +++ b/src/gui/Pages/AddAccount/ServerBrowser.qml @@ -24,6 +24,9 @@ HBox { property string connectFutureId: "" property string fetchServersFutureId: "" + readonly property bool canFocusMainPane: + mainUI.mainPane.normalOrForceCollapse && mainUI.accountsPresent + signal accepted() function takeFocus() { serverField.item.field.forceActiveFocus() } @@ -162,11 +165,7 @@ HBox { visible: Layout.preferredWidth > 0 Layout.fillHeight: true - Layout.preferredWidth: - mainUI.mainPane.normalOrForceCollapse && - mainUI.accountsPresent ? - implicitWidth : - 0 + Layout.preferredWidth: box.canFocusMainPane ? implicitWidth : 0 Behavior on Layout.preferredWidth { HNumberAnimation {} } } @@ -221,6 +220,8 @@ HBox { onKeyboardAccept: if (serverField.item.apply.enabled) serverField.item.apply.clicked() + onKeyboardCancel: if (box.canFocusMainPane) mainUI.mainPane.toggleFocus() + onAccepted: window.saveState(this) Component.onDestruction: diff --git a/src/gui/Pages/AddChat/CreateRoom.qml b/src/gui/Pages/AddChat/CreateRoom.qml index b0bc88ef..ff283d21 100644 --- a/src/gui/Pages/AddChat/CreateRoom.qml +++ b/src/gui/Pages/AddChat/CreateRoom.qml @@ -47,7 +47,7 @@ HFlickableColumnPage { blockOtherServersCheckBox.reset() errorMessage.text = "" - pageLoader.showPrevious() + pageLoader.showPrevious() || mainUI.mainPane.toggleFocus() } enabled: account && account.presence !== "offline" diff --git a/src/gui/Pages/AddChat/DirectChat.qml b/src/gui/Pages/AddChat/DirectChat.qml index 9952cedc..41cc81a7 100644 --- a/src/gui/Pages/AddChat/DirectChat.qml +++ b/src/gui/Pages/AddChat/DirectChat.qml @@ -58,7 +58,7 @@ HFlickableColumnPage { userField.item.reset() errorMessage.text = "" - pageLoader.showPrevious() + pageLoader.showPrevious() || mainUI.mainPane.toggleFocus() } enabled: account && account.presence !== "offline" @@ -73,12 +73,8 @@ HFlickableColumnPage { } CancelButton { - onClicked: { - userField.item.reset() - errorMessage.text = "" - - pageLoader.showPrevious() - } + enabled: main + onClicked: page.cancel() } } diff --git a/src/gui/Pages/AddChat/JoinRoom.qml b/src/gui/Pages/AddChat/JoinRoom.qml index bdb7a381..4707bfba 100644 --- a/src/gui/Pages/AddChat/JoinRoom.qml +++ b/src/gui/Pages/AddChat/JoinRoom.qml @@ -51,7 +51,7 @@ HFlickableColumnPage { roomField.item.reset() errorMessage.text = "" - pageLoader.showPrevious() + pageLoader.showPrevious() || mainUI.mainPane.toggleFocus() } enabled: account && account.presence !== "offline"