mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Book details window: Allow opening the edit metadata window using either the keyboard shortcut or the context menu. Fixes #1903403 [[Enhancement] Allow to open Edit metadata screen from the Book details window](https://bugs.launchpad.net/calibre/+bug/1903403)
This commit is contained in:
parent
603b082dc0
commit
a3efcce704
@ -367,10 +367,15 @@ def details_context_menu_event(view, ev, book_info, add_popup_action=False):
|
|||||||
for ac in tuple(menu.actions()):
|
for ac in tuple(menu.actions()):
|
||||||
if not ac.isEnabled():
|
if not ac.isEnabled():
|
||||||
menu.removeAction(ac)
|
menu.removeAction(ac)
|
||||||
if add_popup_action:
|
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
|
if add_popup_action:
|
||||||
ac = menu.addAction(_('Open the Book details window'))
|
ac = menu.addAction(_('Open the Book details window'))
|
||||||
ac.triggered.connect(book_info.show_book_info)
|
ac.triggered.connect(book_info.show_book_info)
|
||||||
|
else:
|
||||||
|
def open_edit_metadata():
|
||||||
|
from calibre.gui2.ui import get_gui
|
||||||
|
get_gui().iactions['Edit Metadata'].qaction.trigger()
|
||||||
|
menu.addAction(_('Open the Edit metadata window'), open_edit_metadata)
|
||||||
if len(menu.actions()) > 0:
|
if len(menu.actions()) > 0:
|
||||||
menu.exec_(ev.globalPos())
|
menu.exec_(ev.globalPos())
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -3,12 +3,11 @@
|
|||||||
|
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QBrush, QCheckBox, QCoreApplication, QDialog, QGridLayout, QHBoxLayout, QIcon,
|
QAction, QApplication, QBrush, QCheckBox, QCoreApplication, QDialog, QGridLayout,
|
||||||
QKeySequence, QLabel, QListView, QModelIndex, QPalette, QPixmap, QPushButton,
|
QHBoxLayout, QIcon, QKeySequence, QLabel, QListView, QModelIndex, QPalette,
|
||||||
QShortcut, QSize, QSplitter, Qt, QTimer, QToolButton, QVBoxLayout, QWidget,
|
QPixmap, QPushButton, QShortcut, QSize, QSplitter, Qt, QTimer, QToolButton,
|
||||||
pyqtSignal, QApplication
|
QVBoxLayout, QWidget, pyqtSignal
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import fit_image
|
from calibre import fit_image
|
||||||
@ -51,7 +50,9 @@ class Configure(Dialog):
|
|||||||
Dialog.__init__(self, _('Configure the Book details window'), 'book-details-popup-conf', parent)
|
Dialog.__init__(self, _('Configure the Book details window'), 'book-details-popup-conf', parent)
|
||||||
|
|
||||||
def setup_ui(self):
|
def setup_ui(self):
|
||||||
from calibre.gui2.preferences.look_feel import DisplayedFields, move_field_up, move_field_down
|
from calibre.gui2.preferences.look_feel import (
|
||||||
|
DisplayedFields, move_field_down, move_field_up
|
||||||
|
)
|
||||||
self.l = QVBoxLayout(self)
|
self.l = QVBoxLayout(self)
|
||||||
self.field_display_order = fdo = QListView(self)
|
self.field_display_order = fdo = QListView(self)
|
||||||
self.model = DisplayedFields(self.db, fdo, pref_name='popup_book_display_fields')
|
self.model = DisplayedFields(self.db, fdo, pref_name='popup_book_display_fields')
|
||||||
@ -200,6 +201,12 @@ class BookInfo(QDialog):
|
|||||||
self.splitter.restoreState(saved_layout[1])
|
self.splitter.restoreState(saved_layout[1])
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
from calibre.gui2.ui import get_gui
|
||||||
|
ema = get_gui().iactions['Edit Metadata'].menuless_qaction
|
||||||
|
a = self.ema = QAction('edit metadata', self)
|
||||||
|
a.setShortcut(ema.shortcut())
|
||||||
|
self.addAction(a)
|
||||||
|
a.triggered.connect(ema.trigger)
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
d = Configure(get_gui().current_db, self)
|
d = Configure(get_gui().current_db, self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user