diff --git a/src/calibre/customize/__init__.py b/src/calibre/customize/__init__.py index 10ae198b52..d022c295e2 100644 --- a/src/calibre/customize/__init__.py +++ b/src/calibre/customize/__init__.py @@ -726,5 +726,21 @@ class ViewerPlugin(Plugin): # {{{ ''' 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 + # }}} diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index a54b84d82e..cead396c59 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -702,6 +702,8 @@ class DocumentView(QWebView): # {{{ menu.addSeparator() 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()) def inspect(self): diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index 954df0ebe7..fb3aaaf715 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -359,6 +359,8 @@ class EbookViewer(MainWindow, Ui_EbookViewer): # continue to function even when the toolbars are hidden 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.restore_state()