mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit metadata dialog: Allow holding ctrl and clicking the item editor buttons to instead open the manage dialog. Fixes #1934043 [[Enhancement] Right click on item in the Manage items window to open the window to manage it](https://bugs.launchpad.net/calibre/+bug/1934043)
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
6ab3534103
@ -56,6 +56,7 @@ class Base(object):
|
|||||||
|
|
||||||
def __init__(self, db, col_id, parent=None):
|
def __init__(self, db, col_id, parent=None):
|
||||||
self.db, self.col_id = db, col_id
|
self.db, self.col_id = db, col_id
|
||||||
|
self.book_id = None
|
||||||
self.col_metadata = db.custom_column_num_map[col_id]
|
self.col_metadata = db.custom_column_num_map[col_id]
|
||||||
self.initial_val = self.widgets = None
|
self.initial_val = self.widgets = None
|
||||||
self.signals_to_disconnect = []
|
self.signals_to_disconnect = []
|
||||||
@ -86,6 +87,7 @@ class Base(object):
|
|||||||
l.addWidget(self.clear_button)
|
l.addWidget(self.clear_button)
|
||||||
|
|
||||||
def initialize(self, book_id):
|
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.db.get_custom(book_id, num=self.col_id, index_is_id=True)
|
||||||
val = self.normalize_db_val(val)
|
val = self.normalize_db_val(val)
|
||||||
self.setter(val)
|
self.setter(val)
|
||||||
@ -437,7 +439,7 @@ class MultipleWidget(QWidget):
|
|||||||
self.tags_box = EditWithComplete(parent)
|
self.tags_box = EditWithComplete(parent)
|
||||||
layout.addWidget(self.tags_box, stretch=1000)
|
layout.addWidget(self.tags_box, stretch=1000)
|
||||||
self.editor_button = QToolButton(self)
|
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')))
|
self.editor_button.setIcon(QIcon(I('chapters.png')))
|
||||||
layout.addWidget(self.editor_button)
|
layout.addWidget(self.editor_button)
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
@ -547,6 +549,8 @@ class Text(Base):
|
|||||||
return val
|
return val
|
||||||
|
|
||||||
def edit(self):
|
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)):
|
if (self.getter() != self.initial_val and (self.getter() or self.initial_val)):
|
||||||
d = _save_dialog(self.parent, _('Values changed'),
|
d = _save_dialog(self.parent, _('Values changed'),
|
||||||
_('You have changed the values. In order to use this '
|
_('You have changed the values. In order to use this '
|
||||||
@ -560,9 +564,14 @@ class Text(Base):
|
|||||||
self.initial_val = self.current_val
|
self.initial_val = self.current_val
|
||||||
else:
|
else:
|
||||||
self.setter(self.initial_val)
|
self.setter(self.initial_val)
|
||||||
d = TagEditor(self.parent, self.db, self.book_id, self.key)
|
if ctrl_or_shift_pressed:
|
||||||
if d.exec_() == QDialog.DialogCode.Accepted:
|
from calibre.gui2.ui import get_gui
|
||||||
self.setter(d.tags)
|
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):
|
def connect_data_changed(self, slot):
|
||||||
if self.col_metadata['is_multiple']:
|
if self.col_metadata['is_multiple']:
|
||||||
|
@ -1404,12 +1404,15 @@ class TagsEdit(EditWithComplete, ToMetadataMixin): # {{{
|
|||||||
self.current_val = tags
|
self.current_val = tags
|
||||||
self.update_items_cache(db.new_api.all_field_names('tags'))
|
self.update_items_cache(db.new_api.all_field_names('tags'))
|
||||||
self.original_val = self.current_val
|
self.original_val = self.current_val
|
||||||
|
self.db = db
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def changed(self):
|
def changed(self):
|
||||||
return self.current_val != self.original_val
|
return self.current_val != self.original_val
|
||||||
|
|
||||||
def edit(self, db, id_):
|
def edit(self, db, id_):
|
||||||
|
ctrl_or_shift_pressed = (QApplication.keyboardModifiers() &
|
||||||
|
(Qt.KeyboardModifier.ControlModifier + Qt.KeyboardModifier.ShiftModifier))
|
||||||
if self.changed:
|
if self.changed:
|
||||||
d = save_dialog(self, _('Tags changed'),
|
d = save_dialog(self, _('Tags changed'),
|
||||||
_('You have changed the tags. In order to use the tags'
|
_('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
|
self.original_val = self.current_val
|
||||||
else:
|
else:
|
||||||
self.current_val = self.original_val
|
self.current_val = self.original_val
|
||||||
d = TagEditor(self, db, id_)
|
if ctrl_or_shift_pressed:
|
||||||
if d.exec_() == QDialog.DialogCode.Accepted:
|
from calibre.gui2.ui import get_gui
|
||||||
self.current_val = d.tags
|
get_gui().do_tags_list_edit(None, 'tags')
|
||||||
self.update_items_cache(db.new_api.all_field_names('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_):
|
def commit(self, db, id_):
|
||||||
self.books_to_refresh |= db.set_tags(
|
self.books_to_refresh |= db.set_tags(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user