Skip to content

Commit

Permalink
Ignore Ctrl+Alt on a few key
Browse files Browse the repository at this point in the history
esp. those ones on a German T1 keyboard that require AltGR
  • Loading branch information
Jojo-Schmitz committed Nov 8, 2024
1 parent adca477 commit 3646ec4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions mscore/shortcutcapturedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ void ShortcutCaptureDialog::keyPress(QKeyEvent* e)
qDebug() << k;
}

// remove Ctrl+Alt modifiers from a few keys
if ((k & (Qt::ControlModifier | Qt::AltModifier)) && !isCtrlAltNeeded(e->key(), e->text())) { // Qt::KeyAltGr, right Alt
qDebug() << k;
k &= ~(Qt::ControlModifier | Qt::AltModifier);
qDebug() << k;
}

switch(key.count()) {
case 0: key = QKeySequence(k); break;
case 1: key = QKeySequence(key[0], k); break;
Expand Down Expand Up @@ -255,6 +262,32 @@ bool ShortcutCaptureDialog::isShiftAllowed(int key, const QString& keyStr)
}
}

bool ShortcutCaptureDialog::isCtrlAltNeeded(int key, const QString& keyStr) {
// (letter) keys that need AltGR (here esp. for German keyboards), but should not in shortuts
if (keyStr.size() == 1 && ( keyStr.at(0) == QChar(u'') // upper case ẞ !
|| keyStr.at(0) == QChar(u'')))
return false;

// (non-letter) keys that need AltGR (here esp. for German keyboards), but should not in shortuts
switch (key) {
case Qt::Key_twosuperior: // default action: voice 2
case Qt::Key_threesuperior: // default action: voice 3
case Qt::Key_BraceLeft: // default action: reduce strech
case Qt::Key_BracketLeft:
case Qt::Key_BracketRight:
case Qt::Key_BraceRight: // default action: increase stretch
//case Qt::Key_ssharp: // doesn't work here, but see above
case Qt::Key_Backslash:
case Qt::Key_At:
//case Qt::Key_Euro: // doesn't exist, but see above
case Qt::Key_AsciiTilde:
case Qt::Key_Bar:
return false;
default:
return true;
}
}

//---------------------------------------------------------
// clearClicked
//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion mscore/shortcutcapturedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ShortcutCaptureDialog : public QDialog, public Ui::ShortcutCaptureDialogBa
Shortcut* s;
void keyPress(QKeyEvent* e);
bool isShiftAllowed(int key, const QString& keyStr);
bool isCtrlAltNeeded(int key);
bool isCtrlAltNeeded(int key, const QString& keyStr);
virtual bool eventFilter(QObject* o, QEvent* e);
QKeySequence key;
QMap<QString, Shortcut*> localShortcuts;
Expand Down

0 comments on commit 3646ec4

Please sign in to comment.