From b2333c17733708852205df6c2772c630af59127e Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Mon, 13 Jul 2015 13:10:09 +0200 Subject: [PATCH] Tags editor: restore the focus to the last box typed in. --- src/calibre/gui2/dialogs/tag_editor.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/tag_editor.py b/src/calibre/gui2/dialogs/tag_editor.py index f5ea385f73..6bc4e97c45 100644 --- a/src/calibre/gui2/dialogs/tag_editor.py +++ b/src/calibre/gui2/dialogs/tag_editor.py @@ -73,7 +73,11 @@ class TagEditor(QDialog, Ui_TagEditor): self.available_filter_input.textChanged.connect(self.filter_tags) self.applied_filter_input.textChanged.connect(partial(self.filter_tags, which='applied_tags')) - self.available_filter_input.setFocus() + # Restore the focus to the last input box used (typed into) + self.add_tag_input.textChanged.connect(partial(self.edit_box_changed, which="add_tag_input")) + self.available_filter_input.textChanged.connect(partial(self.edit_box_changed, which="available_filter_input")) + self.applied_filter_input.textChanged.connect(partial(self.edit_box_changed, which="applied_filter_input")) + getattr(self, gprefs.get('tag_editor_last_filter', 'add_tag_input')).setFocus() if islinux: self.available_tags.itemDoubleClicked.connect(self.apply_tags) @@ -85,6 +89,10 @@ class TagEditor(QDialog, Ui_TagEditor): if geom is not None: self.restoreGeometry(geom) + def edit_box_changed(self, which): + gprefs['tag_editor_last_filter'] = which + + def delete_tags(self, item=None): confirms, deletes = [], [] items = self.available_tags.selectedItems() if item is None else [item]