This commit is contained in:
Kovid Goyal 2022-10-02 09:17:18 +05:30
commit 313c0bfb05
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 44 additions and 1 deletions

1
imgsrc/context_menu.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" ?><svg fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M4 6H20M4 12H20M4 18H20" stroke="#4A5568" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/></svg>

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

View File

@ -1070,6 +1070,13 @@ class ActionManageCategories(InterfaceActionBase):
description = _('Manage tag browser categories')
class ActionBooklistContextMenu(InterfaceActionBase):
name = 'Booklist context menu'
author = 'Charles Haley'
actual_plugin = 'calibre.gui2.actions.booklist_context_menu:BooklistContextMenuAction'
description = _('Open the context menu for the column')
class ActionVirtualLibrary(InterfaceActionBase):
name = 'Virtual Library'
actual_plugin = 'calibre.gui2.actions.virtual_library:VirtualLibraryAction'
@ -1111,7 +1118,7 @@ plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
ActionPluginUpdater, ActionPickRandom, ActionEditToC, ActionSortBy,
ActionMarkBooks, ActionEmbed, ActionTemplateTester, ActionTagMapper, ActionAuthorMapper,
ActionVirtualLibrary, ActionBrowseAnnotations, ActionTemplateFunctions, ActionAutoscrollBooks,
ActionFullTextSearch, ActionManageCategories]
ActionFullTextSearch, ActionManageCategories, ActionBooklistContextMenu]
# }}}

View File

@ -0,0 +1,25 @@
#!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Charles Haley
#
from qt.core import QPoint
from calibre.gui2.actions import InterfaceAction
class BooklistContextMenuAction(InterfaceAction):
name = 'Booklist context menu'
action_spec = (_('Book list context menu'), 'context_menu.png',
_('Show the book list context menu'), '')
action_type = 'current'
action_add_menu = False
dont_add_to = frozenset(['context-menu-device', 'menubar-device'])
def genesis(self):
self.qaction.triggered.connect(self.show_context_menu)
def show_context_menu(self):
self.gui.library_view.show_column_header_context_menu_from_action()
def location_selected(self, loc):
self.qaction.setEnabled(loc == 'library')

View File

@ -541,6 +541,16 @@ class BooksView(QTableView): # {{{
gprefs['row_numbers_in_book_list'] = show
self.set_row_header_visibility()
def show_column_header_context_menu_from_action(self):
if self.is_library_view:
if self.hasFocus():
p = QPoint(self.column_header.sectionViewportPosition(self.currentIndex().column()), 10)
self.show_column_header_context_menu(p, view=self)
elif self.pin_view.hasFocus():
p = QPoint(self.pin_view.horizontalHeader().sectionViewportPosition(self.pin_view.currentIndex().column()), 10)
self.show_column_header_context_menu(p, view=self.pin_view)
# else some other widget has the focus, such as the tag browser or quickview
def show_column_header_context_menu(self, pos, view=None):
view = view or self
idx = view.column_header.logicalIndexAt(pos)