From d8bb69e74efffd9f641983e84ad40d511d33b7cf Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Thu, 11 Mar 2010 17:34:59 +0000 Subject: [PATCH] Fix bug #5735: Modifying a keyboard shortcut function entry clashes with its own shortcut key combination definition. - 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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index bc4b5b74ed..10d9cc0850 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -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(); -- 2.39.5