From f20ecaf34bb61452bcb2c3fea532933b75794f8f Mon Sep 17 00:00:00 2001 From: Ladislav Foldyna Date: Thu, 20 Jun 2024 15:41:43 +0200 Subject: [PATCH] Settings: Suppressed warning with the same shortcut for the same action --- models/ShortcutEditorModel.cpp | 8 +++++--- models/ShortcutEditorModel.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/models/ShortcutEditorModel.cpp b/models/ShortcutEditorModel.cpp index f28548b6..69c66a58 100644 --- a/models/ShortcutEditorModel.cpp +++ b/models/ShortcutEditorModel.cpp @@ -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; @@ -109,11 +109,13 @@ Qt::ItemFlags ShortcutEditorModel::flags(const QModelIndex &index) const } const QAction *ShortcutEditorModel::findShortcut(const QList &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; } diff --git a/models/ShortcutEditorModel.h b/models/ShortcutEditorModel.h index b5208762..ed1d67c5 100644 --- a/models/ShortcutEditorModel.h +++ b/models/ShortcutEditorModel.h @@ -32,7 +32,8 @@ class ShortcutEditorModel : public QAbstractTableModel QStringList builtInStaticActionList; const QAction *findShortcut(const QList &list, - const QString&); + const QAction *currAction, + const QString&) const; }; #endif // SHORTCUTEDITORMODEL_H