Skip to content

Commit

Permalink
Merge pull request #25108 from cbjeukendrup/port/4.4.3/mac_shortcuts_…
Browse files Browse the repository at this point in the history
…cmd_ctrl_fix

[4.4.3] macOS keyboard shortcuts: fix problems with Ctrl vs Cmd
  • Loading branch information
RomanPudashkin authored Oct 10, 2024
2 parents e60f693 + b0c47b3 commit 8178453
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,27 +309,24 @@ static QString keyCodeToString(UCKeyboardLayout* keyboard, UInt32 keyNativeCode)

static QString keyModifiersToString(UInt32 keyNativeModifiers)
{
static const QMap<int, QString> qtModifiers = {
static const std::map<int, QString> qtModifiers = {
{ shiftKey, "Shift" },
{ rightShiftKey, "Shift" },
{ controlKey, "Ctrl" },
{ rightControlKey, "Ctrl" },
{ controlKey, "Meta" },
{ rightControlKey, "Meta" },
{ cmdKey, "Ctrl" },
{ optionKey, "Alt" },
{ rightOptionKey, "Alt" },
{ kEventKeyModifierNumLockMask, "Num" }
};

QString result;
QMapIterator<int, QString> it(qtModifiers);
while (it.hasNext()) {
it.next();

if (keyNativeModifiers & it.key()) {
for (const auto& [key, value] : qtModifiers) {
if (keyNativeModifiers & key) {
if (!result.isEmpty()) {
result += "+";
}
result += it.value();
result += value;
}
}

Expand Down

0 comments on commit 8178453

Please sign in to comment.