]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #5735: Modifying a keyboard shortcut function entry clashes with its own...
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 11 Mar 2010 17:34:59 +0000 (17:34 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Thu, 11 Mar 2010 17:34:59 +0000 (17:34 +0000)
- Trim the saved lfun because there is a space added in the textfield,
- check whether the action has changed before signaling that the shortcut already exists.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33713 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiPrefs.cpp

index bc4b5b74ed8fa74ba7fea20c1ddcb03218ac5d97..10d9cc085066466a5b6ae785d4ae162031f05499 100644 (file)
@@ -2645,7 +2645,7 @@ void PrefShortcuts::modifyShortcut()
        QTreeWidgetItem * item = shortcutsTW->currentItem();
        if (item->flags() & Qt::ItemIsSelectable) {
                shortcut_->lfunLE->setText(item->text(0));
-               save_lfun_ = item->text(0);
+               save_lfun_ = item->text(0).trimmed();
                shortcut_->shortcutWG->setText(item->text(1));
                KeySequence seq;
                seq.parse(fromqstr(item->data(1, Qt::UserRole).toString()));
@@ -2810,19 +2810,19 @@ void PrefShortcuts::shortcutOkPressed()
        
        // make sure this key isn't already bound---and, if so, not unbound
        FuncCode const unbind = user_unbind_.getBinding(k).action;
-       if (oldBinding.action != LFUN_UNKNOWN_ACTION && unbind == LFUN_UNKNOWN_ACTION)
-       {
+       docstring const action_string = makeCmdString(oldBinding);
+       if (oldBinding.action != LFUN_UNKNOWN_ACTION && unbind == LFUN_UNKNOWN_ACTION
+                 && save_lfun_ != toqstr(action_string)) {
                // FIXME Perhaps we should offer to over-write the old shortcut?
                // If so, we'll need to remove it from our list, etc.
-               docstring const actionStr = makeCmdString(oldBinding);
                Alert::error(_("Failed to create shortcut"),
                        bformat(_("Shortcut `%1$s' is already bound to:\n%2$s\n"
                          "You need to remove that binding before creating a new one."), 
-                       k.print(KeySequence::ForGui), actionStr));
+                       k.print(KeySequence::ForGui), action_string));
                return;
        }
 
-       if (!save_lfun_.isEmpty() && new_lfun == save_lfun_)
+       if (!save_lfun_.isEmpty())
                // real modification of the lfun's shortcut,
                // so remove the previous one
                removeShortcut();