Skip to content

Commit

Permalink
Fix multiple shortcuts for actions
Browse files Browse the repository at this point in the history
  • Loading branch information
melkorbsd committed Jan 14, 2025
1 parent acad090 commit df411a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions RedPandaIDE/settingsdialog/environmentshortcutwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ void EnvironmentShortcutModel::reload()
else
item->fullPath = QString("%1 > %2").arg(tr("action"),action->text());
item->action = action;
item->shortcut = action->shortcut().toString().trimmed();
//item->shortcut = action->shortcut().toString().trimmed();
item->shortcut = QKeySequence::listToString(action->shortcuts()).replace(';',',');
item->isAction = true;
mShortcuts.append(item);
}
Expand Down Expand Up @@ -198,7 +199,8 @@ void EnvironmentShortcutModel::loadShortCutsOfMenu(const QMenu *menu, QList<QAct
item->name = action->objectName();
item->fullPath = QString("%1 > %2").arg(menu->title(),action->text());
item->action = action;
item->shortcut = action->shortcut().toString().trimmed();
//item->shortcut = action->shortcut().toString().trimmed();
item->shortcut = QKeySequence::listToString(action->shortcuts()).replace(';',',');
item->isAction = true;
mShortcuts.append(item);
}
Expand Down
9 changes: 7 additions & 2 deletions RedPandaIDE/shortcutmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,15 @@ void ShortcutManager::applyTo(QAction *action)
{
PEnvironmentShortcut item = mShortcuts.value(action->objectName(), PEnvironmentShortcut());
if (item && item->isAction) {
action->setShortcut(QKeySequence::fromString(item->shortcut));
//action->setShortcut(QKeySequence::fromString(item->shortcut));
QStringList SL = item->shortcut.split(',');
QList<QKeySequence> KL;
for (int i=0;i<SL.size();i++) KL.append(QKeySequence::fromString(SL[i]));
action->setShortcuts(KL);
}
if (!action->shortcut().isEmpty()){
action->setToolTip(action->text()+QString("(%1)").arg(action->shortcut().toString()));
//action->setToolTip(action->text()+QString("(%1)").arg(action->shortcut().toString()));
action->setToolTip(action->text()+QString("(%1)").arg(QKeySequence::listToString(action->shortcuts()).replace(';',',')));
} else {
action->setToolTip(action->text());
}
Expand Down

0 comments on commit df411a3

Please sign in to comment.