QTreeWidgetItem * item = shortcutsTW->currentItem();
if (item->flags() & Qt::ItemIsSelectable) {
shortcut_->lfunLE->setText(item->text(0));
+ save_lfun_ = item->text(0);
shortcut_->shortcutWG->setText(item->text(1));
KeySequence seq;
seq.parse(fromqstr(item->data(1, Qt::UserRole).toString()));
}
-void PrefShortcuts::select_bind()
-{
- QString file = form_->browsebind(internalPath(bindFileED->text()));
- if (!file.isEmpty()) {
- bindFileED->setText(file);
- system_bind_ = KeyMap();
- system_bind_.read(fromqstr(file));
- updateShortcutsTW();
- }
-}
-
-
-void PrefShortcuts::on_modifyPB_pressed()
-{
- modifyShortcut();
-}
-
-
-void PrefShortcuts::on_newPB_pressed()
-{
- shortcut_->lfunLE->clear();
- shortcut_->shortcutWG->reset();
- shortcut_->exec();
-}
-
-
-void PrefShortcuts::on_removePB_pressed()
+void PrefShortcuts::removeShortcut()
{
// it seems that only one item can be selected, but I am
// removing all selected items anyway.
}
+void PrefShortcuts::select_bind()
+{
+ QString file = form_->browsebind(internalPath(bindFileED->text()));
+ if (!file.isEmpty()) {
+ bindFileED->setText(file);
+ system_bind_ = KeyMap();
+ system_bind_.read(fromqstr(file));
+ updateShortcutsTW();
+ }
+}
+
+
+void PrefShortcuts::on_modifyPB_pressed()
+{
+ modifyShortcut();
+}
+
+
+void PrefShortcuts::on_newPB_pressed()
+{
+ shortcut_->lfunLE->clear();
+ shortcut_->shortcutWG->reset();
+ save_lfun_ = QString();
+ shortcut_->exec();
+}
+
+
+void PrefShortcuts::on_removePB_pressed()
+{
+ removeShortcut();
+}
+
+
void PrefShortcuts::on_searchLE_textEdited()
{
if (searchLE->text().isEmpty()) {
void PrefShortcuts::shortcut_okPB_pressed()
{
- string lfun = fromqstr(shortcut_->lfunLE->text());
- FuncRequest func = lyxaction.lookupFunc(lfun);
+ QString const new_lfun = shortcut_->lfunLE->text();
+ FuncRequest func = lyxaction.lookupFunc(fromqstr(new_lfun));
if (func.action == LFUN_UNKNOWN_ACTION) {
Alert::error(_("Failed to create shortcut"),
return;
}
+ if (!save_lfun_.isEmpty() && new_lfun == save_lfun_)
+ // real modification of the lfun's shortcut,
+ // so remove the previous one
+ removeShortcut();
+
QTreeWidgetItem * item = insertShortcutItem(func, k, UserBind);
if (item) {
user_bind_.bind(&k, func);