From d4187664af10c8a24af8c064caee90323acd258e Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Wed, 30 Jun 2021 13:39:05 +0100 Subject: [PATCH] Enhancement #1934043: Right click on item in the Manage items window to open the window to manage it. One can now bring up the Manage ??? dialog by holding the SHIFT or CTRL key when clicking the button. If you want a particular item then copy the text to the clipboard before opening the editor then pasting it into the search or filter box. --- src/calibre/gui2/custom_column_widgets.py | 17 +++++++++++++---- src/calibre/gui2/metadata/basic_widgets.py | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/calibre/gui2/custom_column_widgets.py b/src/calibre/gui2/custom_column_widgets.py index 374e0fabdd..df16bb8eb2 100644 --- a/src/calibre/gui2/custom_column_widgets.py +++ b/src/calibre/gui2/custom_column_widgets.py @@ -56,6 +56,7 @@ class Base(object): def __init__(self, db, col_id, parent=None): self.db, self.col_id = db, col_id + self.book_id = None self.col_metadata = db.custom_column_num_map[col_id] self.initial_val = self.widgets = None self.signals_to_disconnect = [] @@ -86,6 +87,7 @@ class Base(object): l.addWidget(self.clear_button) def initialize(self, book_id): + self.book_id = book_id val = self.db.get_custom(book_id, num=self.col_id, index_is_id=True) val = self.normalize_db_val(val) self.setter(val) @@ -437,7 +439,7 @@ class MultipleWidget(QWidget): self.tags_box = EditWithComplete(parent) layout.addWidget(self.tags_box, stretch=1000) self.editor_button = QToolButton(self) - self.editor_button.setToolTip(_('Open item editor')) + self.editor_button.setToolTip(_('Open item editor. If CTRL or SHIFT is pressed, open manage items')) self.editor_button.setIcon(QIcon(I('chapters.png'))) layout.addWidget(self.editor_button) self.setLayout(layout) @@ -547,6 +549,8 @@ class Text(Base): return val def edit(self): + ctrl_or_shift_pressed = (QApplication.keyboardModifiers() & + (Qt.KeyboardModifier.ControlModifier + Qt.KeyboardModifier.ShiftModifier)) if (self.getter() != self.initial_val and (self.getter() or self.initial_val)): d = _save_dialog(self.parent, _('Values changed'), _('You have changed the values. In order to use this ' @@ -560,9 +564,14 @@ class Text(Base): self.initial_val = self.current_val else: self.setter(self.initial_val) - d = TagEditor(self.parent, self.db, self.book_id, self.key) - if d.exec_() == QDialog.DialogCode.Accepted: - self.setter(d.tags) + if ctrl_or_shift_pressed: + from calibre.gui2.ui import get_gui + get_gui().do_tags_list_edit(None, self.key) + self.initialize(self.book_id) + else: + d = TagEditor(self.parent, self.db, self.book_id, self.key) + if d.exec_() == QDialog.DialogCode.Accepted: + self.setter(d.tags) def connect_data_changed(self, slot): if self.col_metadata['is_multiple']: diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index 71a7b2c352..32a2dc6a1d 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -1404,12 +1404,15 @@ class TagsEdit(EditWithComplete, ToMetadataMixin): # {{{ self.current_val = tags self.update_items_cache(db.new_api.all_field_names('tags')) self.original_val = self.current_val + self.db = db @property def changed(self): return self.current_val != self.original_val def edit(self, db, id_): + ctrl_or_shift_pressed = (QApplication.keyboardModifiers() & + (Qt.KeyboardModifier.ControlModifier + Qt.KeyboardModifier.ShiftModifier)) if self.changed: d = save_dialog(self, _('Tags changed'), _('You have changed the tags. In order to use the tags' @@ -1423,10 +1426,16 @@ class TagsEdit(EditWithComplete, ToMetadataMixin): # {{{ self.original_val = self.current_val else: self.current_val = self.original_val - d = TagEditor(self, db, id_) - if d.exec_() == QDialog.DialogCode.Accepted: - self.current_val = d.tags - self.update_items_cache(db.new_api.all_field_names('tags')) + if ctrl_or_shift_pressed: + from calibre.gui2.ui import get_gui + get_gui().do_tags_list_edit(None, 'tags') + self.update_items_cache(self.db.new_api.all_field_names('tags')) + self.initialize(self.db, id_) + else: + d = TagEditor(self, db, id_) + if d.exec_() == QDialog.DialogCode.Accepted: + self.current_val = d.tags + self.update_items_cache(db.new_api.all_field_names('tags')) def commit(self, db, id_): self.books_to_refresh |= db.set_tags(