]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/GuiPrefs.cpp
Allow to unbind without specifying the lfun
[lyx.git] / src / frontends / qt / GuiPrefs.cpp
index 2b6b9cd1cb667952e7ad80352418fcbc812b9ead..31da12936fd1a3577a2ac200aaf3855591ae0fee 100644 (file)
@@ -3087,10 +3087,10 @@ QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
        QTreeWidgetItem * newItem = nullptr;
        // for unbind items, try to find an existing item in the system bind list
        if (tag == KeyMap::UserUnbind) {
-               QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(lfun_name,
-                       Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
+               QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(shortcut,
+                       Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 1);
                for (auto const & item : items) {
-                       if (item->text(1) == shortcut) {
+                       if (item->text(0) == lfun_name || lfun == FuncRequest::unknown) {
                                newItem = item;
                                break;
                        }
@@ -3125,10 +3125,10 @@ QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
                        // this should not happen
                        newItem = new QTreeWidgetItem(shortcutsTW);
                }
+               newItem->setText(0, lfun_name);
+               newItem->setText(1, shortcut);
        }
 
-       newItem->setText(0, lfun_name);
-       newItem->setText(1, shortcut);
        // record BindFile representation to recover KeySequence when needed.
        newItem->setData(1, Qt::UserRole, toqstr(seq.print(KeySequence::BindFile)));
        setItemType(newItem, tag);