branch: 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.

see r33713.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@33754 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-03-15 21:43:26 +00:00
parent f868ad6807
commit 01f95f41e6
2 changed files with 9 additions and 6 deletions

View File

@ -2391,7 +2391,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()));
@ -2556,19 +2556,19 @@ void PrefShortcuts::shortcut_okPB_pressed()
// 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_str = makeCmdString(oldBinding);
if (oldBinding.action != LFUN_UNKNOWN_ACTION && unbind == LFUN_UNKNOWN_ACTION
&& save_lfun_ != toqstr(action_str)) {
// 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_str));
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();

View File

@ -242,6 +242,9 @@ What's new
- Abbreviate long cross-references (bug 6559).
- Do not cause a shortcut conflict when only modifying the command
of a keyboard shortcut binding (bug 5735).
* DOCUMENTATION AND LOCALIZATION