Skip to content

Commit

Permalink
Add key input for setting 10 velocity
Browse files Browse the repository at this point in the history
This way 0 can be set to 10 and an alternative character be used
for 0 velocity.
  • Loading branch information
Cuperino committed Sep 27, 2024
1 parent c90cff6 commit 6e82a5c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/kirigami_ui/InputsOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Kirigami.OverlaySheet {
keyInputSetVelocity7.setSource("KeyInputButton.qml", { "text": qmlutil.keyToString(prompter.keys.setVelocity7, prompter.keys.setVelocity7Modifiers) });
keyInputSetVelocity8.setSource("KeyInputButton.qml", { "text": qmlutil.keyToString(prompter.keys.setVelocity8, prompter.keys.setVelocity8Modifiers) });
keyInputSetVelocity9.setSource("KeyInputButton.qml", { "text": qmlutil.keyToString(prompter.keys.setVelocity9, prompter.keys.setVelocity9Modifiers) });
keyInputSetVelocity10.setSource("KeyInputButton.qml", { "text": qmlutil.keyToString(prompter.keys.setVelocity10, prompter.keys.setVelocity10Modifiers) });
}
Connections {
target: keyInputTogglePrompter.item
Expand Down Expand Up @@ -249,6 +250,14 @@ Kirigami.OverlaySheet {
prompter.keys.setVelocity9Modifiers = modifiers;
}
}
Connections {
target: keyInputSetVelocity10.item
function onToggleButtonsOff() { buttonGrid.toggleButtonsOff(); }
function onSetKey(key, modifiers) {
prompter.keys.setVelocity10 = key;
prompter.keys.setVelocity10Modifiers = modifiers;
}
}

Label {
text: i18n("Toggle Prompter State")
Expand Down Expand Up @@ -465,6 +474,14 @@ Kirigami.OverlaySheet {
asynchronous: true
Layout.fillWidth: true
}
Label {
text: i18nc("Hotkey that sets velocity to a fixed value.", "Set velocity to 10")
}
Loader {
id: keyInputSetVelocity10
asynchronous: true
Layout.fillWidth: true
}


QmlUtil {
Expand Down
13 changes: 12 additions & 1 deletion src/prompter/Prompter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Flickable {
property int markerToggleModifiers: Qt.ControlModifier
property int namedMarkerToggle: Qt.Key_M
property int namedMarkerToggleModifiers: Qt.ControlModifier | Qt.ShiftModifier
property int setVelocity0: Qt.Key_0
property int setVelocity0: 16781904 // Key: `
property int setVelocity0Modifiers: Qt.NoModifier
property int setVelocity1: Qt.Key_1
property int setVelocity1Modifiers: Qt.NoModifier
Expand All @@ -234,6 +234,8 @@ Flickable {
property int setVelocity8Modifiers: Qt.NoModifier
property int setVelocity9: Qt.Key_9
property int setVelocity9Modifiers: Qt.NoModifier
property int setVelocity10: Qt.Key_0
property int setVelocity10Modifiers: Qt.NoModifier
property int setVelocityModifier: Qt.AltModifier
}
Settings {
Expand Down Expand Up @@ -1150,6 +1152,7 @@ Flickable {
case keys.setVelocity7:
case keys.setVelocity8:
case keys.setVelocity9:
case keys.setVelocity10:
case keys.toggle:
// If in edit while prompting mode, ensure arrow keys and space bar don't float up to prompter so editor can make proper use of them.
if ((Qt.Key_Left <= event.key && event.key <= Qt.Key_Down) || (Qt.Key_Space <= event.key && event.key <= Qt.Key_Dead_Longsolidusoverlay)) {
Expand Down Expand Up @@ -1643,6 +1646,14 @@ Flickable {
setVelocity(-9, event);
return;
}
else if (event.key===keys.setVelocity10 && event.modifiers===keys.setVelocity10Modifiers) {
setVelocity(10, event);
return;
}
else if (event.key===keys.setVelocity10 && event.modifiers===(keys.setVelocity10Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-10, event);
return;
}
else if (event.key===keys.reverse && event.modifiers===keys.reverseModifiers) {
// Reverse
__i = -__i;
Expand Down

0 comments on commit 6e82a5c

Please sign in to comment.