mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
313c0bfb05
1
imgsrc/context_menu.svg
Normal file
1
imgsrc/context_menu.svg
Normal 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 |
BIN
resources/images/context_menu.png
Normal file
BIN
resources/images/context_menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 477 B |
@ -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]
|
||||
|
||||
# }}}
|
||||
|
||||
|
25
src/calibre/gui2/actions/booklist_context_menu.py
Normal file
25
src/calibre/gui2/actions/booklist_context_menu.py
Normal 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')
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user