Skip to content

Commit

Permalink
Map numbers to various pre-fixed velocities
Browse files Browse the repository at this point in the history
Fixes #135
  • Loading branch information
Cuperino committed Sep 23, 2024
1 parent 9655d54 commit c90cff6
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
43 changes: 42 additions & 1 deletion src/kirigami_ui/InputsOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Kirigami.OverlaySheet {
// Toggle all buttons off
function toggleButtonsOff() {
for (let i=1; i<children.length; i+=2)
children[i].item.checked = false;
if (typeof children[i].item !== "undefined")
children[i].item.checked = false;
}

Component.onCompleted: {
Expand Down Expand Up @@ -345,6 +346,45 @@ Kirigami.OverlaySheet {
asynchronous: true
Layout.fillWidth: true
}
Label {
text: i18nc("Hotkey that shifts velocoty to its negative value.", "Set velocity modifier key")
}
ComboBox {
id: keyInputSetVelocityModifier
model: [
i18nc("Control key", "Ctrl"),
i18nc("Alt key", "Alt")
]
z: 1
onActivated: {
switch(currentIndex) {
case 1:
prompter.keys.setVelocityModifier = Qt.ControlModifier; break;
case 2:
prompter.keys.setVelocityModifier = Qt.ShiftModifier; break;
case 3:
prompter.keys.setVelocityModifier = Qt.MetaModifier; break;
case 0:
prompter.keys.setVelocityModifier = Qt.AltModifier; break;
}
console.log(prompter.keys.setVelocityModifier)
}
Layout.fillWidth: true
Material.theme: Material.Dark
Component.onCompleted: {
switch(prompter.keys.setVelocityModifier) {
case Qt.ControlModifier:
currentIndex = 1; break;
case Qt.ShiftModifier:
currentIndex = 2; break;
case Qt.MetaModifier:
currentIndex = 3; break;
case Qt.AltModifier:
default:
currentIndex = 0; break;
}
}
}
Label {
text: i18nc("Hotkey that sets velocity to a fixed value.", "Set velocity to 0")
}
Expand Down Expand Up @@ -426,6 +466,7 @@ Kirigami.OverlaySheet {
Layout.fillWidth: true
}


QmlUtil {
id: qmlutil
}
Expand Down
42 changes: 40 additions & 2 deletions src/prompter/Prompter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ Flickable {
property int setVelocity8Modifiers: Qt.NoModifier
property int setVelocity9: Qt.Key_9
property int setVelocity9Modifiers: Qt.NoModifier
property int setVelocityModifier: Qt.AltModifier
}
Settings {
category: "atEnd"
Expand Down Expand Up @@ -1565,46 +1566,83 @@ Flickable {
}
return
}
else if (event.key===keys.setVelocity0 && event.modifiers===keys.setVelocity0Modifiers) {
else if (event.key===keys.setVelocity0 && (event.modifiers===keys.setVelocity0Modifiers ||
event.modifiers===(keys.setVelocity0Modifiers ^ keys.setVelocityModifier))) {
setVelocity(0, event);
return;
}
else if (event.key===keys.setVelocity1 && event.modifiers===keys.setVelocity1Modifiers) {
setVelocity(1, event);
return;
}
else if (event.key===keys.setVelocity1 && event.modifiers===(keys.setVelocity1Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-1, event);
return;
}
else if (event.key===keys.setVelocity2 && event.modifiers===keys.setVelocity2Modifiers) {
setVelocity(2, event);
return;
}
else if (event.key===keys.setVelocity3 && event.modifiers===keys.setVelocity3Modifiers) {
else if (event.key===keys.setVelocity2 && event.modifiers===(keys.setVelocity2Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-2, event);
return;
}
else if (event.key===keys.setVelocity3 && event.modifiers===(keys.setVelocity3Modifiers)) {
setVelocity(3, event);
return;
}
else if (event.key===keys.setVelocity3 && event.modifiers===(keys.setVelocity3Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-3, event);
return;
}
else if (event.key===keys.setVelocity4 && event.modifiers===keys.setVelocity4Modifiers) {
setVelocity(4, event);
return;
}
else if (event.key===keys.setVelocity4 && event.modifiers===(keys.setVelocity4Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-4, event);
return;
}
else if (event.key===keys.setVelocity5 && event.modifiers===keys.setVelocity5Modifiers) {
setVelocity(5, event);
return;
}
else if (event.key===keys.setVelocity5 && event.modifiers===(keys.setVelocity5Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-5, event);
return;
}
else if (event.key===keys.setVelocity6 && event.modifiers===keys.setVelocity6Modifiers) {
setVelocity(6, event);
return;
}
else if (event.key===keys.setVelocity6 && event.modifiers===(keys.setVelocity6Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-6, event);
return;
}
else if (event.key===keys.setVelocity7 && event.modifiers===keys.setVelocity7Modifiers) {
setVelocity(7, event);
return;
}
else if (event.key===keys.setVelocity7 && event.modifiers===(keys.setVelocity7Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-7, event);
return;
}
else if (event.key===keys.setVelocity8 && event.modifiers===keys.setVelocity8Modifiers) {
setVelocity(8, event);
return;
}
else if (event.key===keys.setVelocity8 && event.modifiers===(keys.setVelocity8Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-8, event);
return;
}
else if (event.key===keys.setVelocity9 && event.modifiers===keys.setVelocity9Modifiers) {
setVelocity(9, event);
return;
}
else if (event.key===keys.setVelocity9 && event.modifiers===(keys.setVelocity9Modifiers ^ keys.setVelocityModifier)) {
setVelocity(-9, event);
return;
}
else if (event.key===keys.reverse && event.modifiers===keys.reverseModifiers) {
// Reverse
__i = -__i;
Expand Down

0 comments on commit c90cff6

Please sign in to comment.