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.
This commit is contained in:
Charles Haley 2021-06-30 13:39:05 +01:00
parent ac0969b9e9
commit d4187664af
2 changed files with 26 additions and 8 deletions

View File

@ -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']:

View File

@ -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(