Unify cancel button & escape keybind for pages
AddChat and AccountSettings: - When clicking the cancel button, if there's no previous back to go back to, focus the main pane instead of doing nothing AccountSettings: - Always enable the cancel button, not just when the form has been modified AddChat, AccountSettings, ServerBrowser: - Pressing escape will do the same thing as clicking the cancel button
This commit is contained in:
parent
01e7a1ac13
commit
20e8a19017
|
@ -58,6 +58,16 @@ HFlickableColumnPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancel() {
|
function cancel() {
|
||||||
|
if (
|
||||||
|
! nameField.item.changed &&
|
||||||
|
! aliasFieldItem.changed &&
|
||||||
|
! fileDialog.selectedFile &&
|
||||||
|
! fileDialog.file
|
||||||
|
) {
|
||||||
|
pageLoader.showPrevious() || mainUI.mainPane.toggleFocus()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
nameField.item.reset()
|
nameField.item.reset()
|
||||||
aliasFieldItem.reset()
|
aliasFieldItem.reset()
|
||||||
fileDialog.selectedFile = ""
|
fileDialog.selectedFile = ""
|
||||||
|
@ -82,7 +92,7 @@ HFlickableColumnPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
CancelButton {
|
CancelButton {
|
||||||
enabled: saveButton.enabled && ! saveButton.loading
|
enabled: ! saveButton.loading
|
||||||
onClicked: cancel()
|
onClicked: cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ HBox {
|
||||||
property string connectFutureId: ""
|
property string connectFutureId: ""
|
||||||
property string fetchServersFutureId: ""
|
property string fetchServersFutureId: ""
|
||||||
|
|
||||||
|
readonly property bool canFocusMainPane:
|
||||||
|
mainUI.mainPane.normalOrForceCollapse && mainUI.accountsPresent
|
||||||
|
|
||||||
signal accepted()
|
signal accepted()
|
||||||
|
|
||||||
function takeFocus() { serverField.item.field.forceActiveFocus() }
|
function takeFocus() { serverField.item.field.forceActiveFocus() }
|
||||||
|
@ -162,11 +165,7 @@ HBox {
|
||||||
visible: Layout.preferredWidth > 0
|
visible: Layout.preferredWidth > 0
|
||||||
|
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.preferredWidth:
|
Layout.preferredWidth: box.canFocusMainPane ? implicitWidth : 0
|
||||||
mainUI.mainPane.normalOrForceCollapse &&
|
|
||||||
mainUI.accountsPresent ?
|
|
||||||
implicitWidth :
|
|
||||||
0
|
|
||||||
|
|
||||||
Behavior on Layout.preferredWidth { HNumberAnimation {} }
|
Behavior on Layout.preferredWidth { HNumberAnimation {} }
|
||||||
}
|
}
|
||||||
|
@ -221,6 +220,8 @@ HBox {
|
||||||
onKeyboardAccept:
|
onKeyboardAccept:
|
||||||
if (serverField.item.apply.enabled) serverField.item.apply.clicked()
|
if (serverField.item.apply.enabled) serverField.item.apply.clicked()
|
||||||
|
|
||||||
|
onKeyboardCancel: if (box.canFocusMainPane) mainUI.mainPane.toggleFocus()
|
||||||
|
|
||||||
onAccepted: window.saveState(this)
|
onAccepted: window.saveState(this)
|
||||||
|
|
||||||
Component.onDestruction:
|
Component.onDestruction:
|
||||||
|
|
|
@ -47,7 +47,7 @@ HFlickableColumnPage {
|
||||||
blockOtherServersCheckBox.reset()
|
blockOtherServersCheckBox.reset()
|
||||||
errorMessage.text = ""
|
errorMessage.text = ""
|
||||||
|
|
||||||
pageLoader.showPrevious()
|
pageLoader.showPrevious() || mainUI.mainPane.toggleFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled: account && account.presence !== "offline"
|
enabled: account && account.presence !== "offline"
|
||||||
|
|
|
@ -58,7 +58,7 @@ HFlickableColumnPage {
|
||||||
userField.item.reset()
|
userField.item.reset()
|
||||||
errorMessage.text = ""
|
errorMessage.text = ""
|
||||||
|
|
||||||
pageLoader.showPrevious()
|
pageLoader.showPrevious() || mainUI.mainPane.toggleFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled: account && account.presence !== "offline"
|
enabled: account && account.presence !== "offline"
|
||||||
|
@ -73,12 +73,8 @@ HFlickableColumnPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
CancelButton {
|
CancelButton {
|
||||||
onClicked: {
|
enabled: main
|
||||||
userField.item.reset()
|
onClicked: page.cancel()
|
||||||
errorMessage.text = ""
|
|
||||||
|
|
||||||
pageLoader.showPrevious()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ HFlickableColumnPage {
|
||||||
roomField.item.reset()
|
roomField.item.reset()
|
||||||
errorMessage.text = ""
|
errorMessage.text = ""
|
||||||
|
|
||||||
pageLoader.showPrevious()
|
pageLoader.showPrevious() || mainUI.mainPane.toggleFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled: account && account.presence !== "offline"
|
enabled: account && account.presence !== "offline"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user