Skip to content

Commit

Permalink
Settings: Suppressed warning with the same shortcut for the same action
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed Jun 20, 2024
1 parent f243acc commit f20ecaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions models/ShortcutEditorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool ShortcutEditorModel::setData(const QModelIndex &index, const QVariant &valu
return false;
}

if ( findShortcut(actionList, newShortcutString) )
if ( findShortcut(actionList, action, newShortcutString) )
{
emit conflictDetected(tr("Conflict with a user-defined shortcut"));
return false;
Expand All @@ -109,11 +109,13 @@ Qt::ItemFlags ShortcutEditorModel::flags(const QModelIndex &index) const
}

const QAction *ShortcutEditorModel::findShortcut(const QList<QAction *> &list,
const QString &shortcut)
const QAction *currAction,
const QString &shortcut) const
{
for ( const QAction* action : list )
{
if ( action->shortcut().toString(QKeySequence::NativeText) == shortcut )
if ( action->shortcut().toString(QKeySequence::NativeText) == shortcut
&& action != currAction )
return action;
}

Expand Down
3 changes: 2 additions & 1 deletion models/ShortcutEditorModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class ShortcutEditorModel : public QAbstractTableModel
QStringList builtInStaticActionList;

const QAction *findShortcut(const QList<QAction *> &list,
const QString&);
const QAction *currAction,
const QString&) const;
};

#endif // SHORTCUTEDITORMODEL_H

0 comments on commit f20ecaf

Please sign in to comment.