Implement a separate context menu for the split book list

This commit is contained in:
Kovid Goyal 2018-01-30 14:57:42 +05:30
parent c75ae1acb9
commit 6c3e68289b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 22 additions and 2 deletions

View File

@ -87,6 +87,13 @@ def create_defs():
'Similar Books', 'Tweak ePub', None, 'Remove Books',
)
defs['action-layout-context-menu-split'] = (
'Edit Metadata', 'Send To Device', 'Save To Disk',
'Connect Share', 'Copy To Library', None,
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
'Similar Books', 'Tweak ePub', None, 'Remove Books',
)
defs['action-layout-context-menu-device'] = (
'View', 'Save To Disk', None, 'Remove Books', None,
'Add To Library', 'Edit Collections', 'Match Books'

View File

@ -82,6 +82,9 @@ class LibraryViewMixin(object): # {{{
populate_menu(dm, gprefs['action-layout-context-menu-device'], self.iactions)
ec = self.iactions['Edit Collections'].qaction
self.library_view.set_context_menu(lm, ec)
sm = QMenu(self)
populate_menu(sm, gprefs['action-layout-context-menu-split'], self.iactions)
self.library_view.pin_view.set_context_menu(sm)
for v in (self.memory_view, self.card_a_view, self.card_b_view):
v.set_context_menu(dm, ec)

View File

@ -886,11 +886,14 @@ class BooksView(QTableView): # {{{
self.alternate_views.set_context_menu(menu)
self.edit_collections_action = edit_collections_action
def contextMenuEvent(self, event):
def show_context_menu(self, menu, event):
from calibre.gui2.main_window import clone_menu
m = clone_menu(self.context_menu) if islinux else self.context_menu
m = clone_menu(menu) if islinux else menu
m.popup(event.globalPos())
event.accept()
def contextMenuEvent(self, event):
self.show_context_menu(self.context_menu, event)
# }}}
@property

View File

@ -14,6 +14,12 @@ class PinTableView(QTableView):
self.books_view = books_view
self.verticalHeader().close()
def set_context_menu(self, menu):
self.context_menu = menu
def contextMenuEvent(self, event):
self.books_view.show_context_menu(self.context_menu, event)
class PinContainer(QSplitter):

View File

@ -241,6 +241,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
('menubar-device', _('The menubar when a device is connected')),
('context-menu', _('The context menu for the books in the '
'calibre library')),
('context-menu-split', _('The context menu for the split book list')),
('context-menu-device', _('The context menu for the books on '
'the device')),
('context-menu-cover-browser', _('The context menu for the Cover '