mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Allow right clicking on the toolbar buttons to popup the optional menus, useful when using the viewer on a touch screen. Fixes #1380359 [Feature Request: right-click menus missing in ebook viewer](https://bugs.launchpad.net/calibre/+bug/1380359)
This commit is contained in:
parent
a10c7f9a35
commit
33d2d0e5ea
@ -178,6 +178,19 @@ def test_history():
|
||||
assert h == [0, 9]
|
||||
# }}}
|
||||
|
||||
class ToolBar(QToolBar): # {{{
|
||||
|
||||
def contextMenuEvent(self, ev):
|
||||
ac = self.actionAt(ev.pos())
|
||||
if ac is None:
|
||||
return
|
||||
ch = self.widgetForAction(ac)
|
||||
sm = getattr(ch, 'showMenu', None)
|
||||
if callable(sm):
|
||||
ev.accept()
|
||||
sm()
|
||||
# }}}
|
||||
|
||||
class Main(MainWindow):
|
||||
|
||||
def __init__(self, debug_javascript):
|
||||
@ -209,14 +222,14 @@ class Main(MainWindow):
|
||||
hs.setOrientation(Qt.Vertical), hs.setObjectName("horizontal_scrollbar")
|
||||
cl.addWidget(hs, 1, 0, 1, 1)
|
||||
|
||||
self.tool_bar = tb = QToolBar(self)
|
||||
self.tool_bar = tb = ToolBar(self)
|
||||
tb.setObjectName('tool_bar'), tb.setIconSize(QSize(32, 32))
|
||||
self.addToolBar(Qt.LeftToolBarArea, tb)
|
||||
|
||||
self.tool_bar2 = tb2 = QToolBar(self)
|
||||
tb2.setObjectName('tool_bar2')
|
||||
self.addToolBar(Qt.TopToolBarArea, tb2)
|
||||
self.tool_bar.setContextMenuPolicy(Qt.PreventContextMenu)
|
||||
self.tool_bar.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||
self.tool_bar2.setContextMenuPolicy(Qt.PreventContextMenu)
|
||||
|
||||
self.pos = DoubleSpinBox()
|
||||
|
Loading…
x
Reference in New Issue
Block a user