mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow viewer plugins to customize the viewer's UI
This commit is contained in:
parent
87255226c0
commit
43770ce0f2
@ -726,5 +726,21 @@ class ViewerPlugin(Plugin): # {{{
|
|||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def customize_ui(self, ui):
|
||||||
|
'''
|
||||||
|
This method is called once when the viewer is created. Use it to make
|
||||||
|
any customizations you want to the viewer's user interface. For
|
||||||
|
example, you can modify the toolbars via ui.tool_bar and ui.tool_bar2.
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
def customize_context_menu(self, menu, event, hit_test_result):
|
||||||
|
'''
|
||||||
|
This method is called every time the context (right-click) menu is
|
||||||
|
shown. You can use it to customize the context menu. event is the
|
||||||
|
context menu event and hit_test_result is the QWebHitTestResult for this
|
||||||
|
event in the currently loaded document.
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -702,6 +702,8 @@ class DocumentView(QWebView): # {{{
|
|||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
menu.addAction(self.manager.action_quit)
|
menu.addAction(self.manager.action_quit)
|
||||||
|
|
||||||
|
for plugin in self.document.all_viewer_plugins:
|
||||||
|
plugin.customize_context_menu(menu, ev, r)
|
||||||
menu.exec_(ev.globalPos())
|
menu.exec_(ev.globalPos())
|
||||||
|
|
||||||
def inspect(self):
|
def inspect(self):
|
||||||
|
@ -359,6 +359,8 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
|||||||
# continue to function even when the toolbars are hidden
|
# continue to function even when the toolbars are hidden
|
||||||
self.addAction(action)
|
self.addAction(action)
|
||||||
|
|
||||||
|
for plugin in self.view.document.all_viewer_plugins:
|
||||||
|
plugin.customize_ui(self)
|
||||||
self.view.document.settings_changed.connect(self.settings_changed)
|
self.view.document.settings_changed.connect(self.settings_changed)
|
||||||
|
|
||||||
self.restore_state()
|
self.restore_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user