Skip to content

Commit

Permalink
Fix: Implemented global cancel shortcut that always returns prompter …
Browse files Browse the repository at this point in the history
…to edit mode. This approach fixes bug #69 and should prevent it from happening again on this standard key.
  • Loading branch information
Cuperino committed Mar 4, 2022
1 parent 0ffdb82 commit 82364e2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/kirigami_ui/+android/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ Kirigami.ApplicationWindow {
iconName: "application-exit"
shortcut: StandardKey.Quit
onTriggered: close()
},
// Global shortcuts
// On ESC pressed, return to PrompterEdit mode.
Kirigami.Action {
visible: false
onTriggered: root.pageStack.currentItem.prompter.cancel()
shortcut: StandardKey.Cancel
}
]
topContent: RowLayout {
Expand Down
7 changes: 7 additions & 0 deletions src/kirigami_ui/+windows/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ Kirigami.ApplicationWindow {
iconName: "application-exit"
shortcut: StandardKey.Quit
onTriggered: close()
},
// Global shortcuts
// On ESC pressed, return to PrompterEdit mode.
Kirigami.Action {
visible: false
onTriggered: root.pageStack.currentItem.prompter.cancel()
shortcut: StandardKey.Cancel
}
]
topContent: RowLayout {
Expand Down
4 changes: 4 additions & 0 deletions src/kirigami_ui/KeyInputButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ Button {
}

Layout.fillWidth: true
Keys.onShortcutOverride: {
if (event.key === Qt.Key_Escape)
event.accepted = true
}
Keys.onPressed: {
if (checked) {
if (isValidInput(event.key)) {
Expand Down
7 changes: 7 additions & 0 deletions src/kirigami_ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,13 @@ Kirigami.ApplicationWindow {
iconName: "application-exit"
shortcut: StandardKey.Quit
onTriggered: close()
},
// Global shortcuts
// On ESC pressed, return to PrompterEdit mode.
Kirigami.Action {
visible: false
onTriggered: root.pageStack.currentItem.prompter.cancel()
shortcut: StandardKey.Cancel
}
]
topContent: RowLayout {
Expand Down
3 changes: 3 additions & 0 deletions src/prompter/Prompter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ Flickable {
};

// Toggle prompter state
function cancel() {
state = Prompter.States.Editing
}
function toggle() {

// Switch to next corresponding prompter state, relative to current configuration
Expand Down

0 comments on commit 82364e2

Please sign in to comment.