diff --git a/src/calibre/gui2/actions/preferences.py b/src/calibre/gui2/actions/preferences.py
index cd9de36fce..bbb86b573e 100644
--- a/src/calibre/gui2/actions/preferences.py
+++ b/src/calibre/gui2/actions/preferences.py
@@ -45,6 +45,8 @@ class PreferencesAction(InterfaceAction):
d = PluginUpdaterDialog(self.gui,
initial_filter=FILTER_NOT_INSTALLED)
d.exec_()
+ if d.do_restart:
+ self.gui.quit(restart=True)
def do_config(self, checked=False, initial_plugin=None,
close_after_initial=False):
diff --git a/src/calibre/gui2/dialogs/plugin_updater.py b/src/calibre/gui2/dialogs/plugin_updater.py
index 2a90f63995..4e56db9016 100644
--- a/src/calibre/gui2/dialogs/plugin_updater.py
+++ b/src/calibre/gui2/dialogs/plugin_updater.py
@@ -456,6 +456,7 @@ class PluginUpdaterDialog(SizePersistedDialog):
self.gui = gui
self.forum_link = None
self.model = None
+ self.do_restart = False
self._initialize_controls()
self._create_context_menu()
@@ -720,6 +721,7 @@ class PluginUpdaterDialog(SizePersistedDialog):
prints('Installing plugin: ', zip_path)
self.gui.status_bar.showMessage(_('Installing plugin: %s') % zip_path)
+ do_restart = False
try:
try:
plugin = add_plugin(zip_path)
@@ -731,11 +733,21 @@ class PluginUpdaterDialog(SizePersistedDialog):
widget.gui = self.gui
widget.check_for_add_to_toolbars(plugin)
self.gui.status_bar.showMessage(_('Plugin installed: %s') % display_plugin.name)
- info_dialog(self.gui, _('Success'),
+ d = info_dialog(self.gui, _('Success'),
_('Plugin {0} successfully installed under '
' {1} plugins. You may have to restart calibre '
'for the plugin to take effect.').format(plugin.name, plugin.type),
- show=True, show_copy_button=False)
+ show_copy_button=False)
+ b = d.bb.addButton(_('Restart calibre now'), d.bb.AcceptRole)
+ b.setIcon(QIcon(I('lt.png')))
+ d.do_restart = False
+ def rf():
+ d.do_restart = True
+ b.clicked.connect(rf)
+ d.set_details('')
+ d.exec_()
+ b.clicked.disconnect()
+ do_restart = d.do_restart
display_plugin.plugin = plugin
# We cannot read the 'actual' version information as the plugin will not be loaded yet
@@ -762,6 +774,9 @@ class PluginUpdaterDialog(SizePersistedDialog):
else:
self.model.refresh_plugin(display_plugin)
self._select_and_focus_view(change_selection=False)
+ if do_restart:
+ self.do_restart = True
+ self.accept()
def _history_clicked(self):
display_plugin = self._selected_display_plugin()
diff --git a/src/calibre/gui2/preferences/__init__.py b/src/calibre/gui2/preferences/__init__.py
index d724e49b46..733d5b2255 100644
--- a/src/calibre/gui2/preferences/__init__.py
+++ b/src/calibre/gui2/preferences/__init__.py
@@ -236,6 +236,7 @@ class ConfigWidgetBase(QWidget, ConfigWidgetInterface):
'''
changed_signal = pyqtSignal()
+ restart_now = pyqtSignal()
supports_restoring_to_defaults = True
restart_critical = False
diff --git a/src/calibre/gui2/preferences/main.py b/src/calibre/gui2/preferences/main.py
index 98b5f168b3..4c879c7883 100644
--- a/src/calibre/gui2/preferences/main.py
+++ b/src/calibre/gui2/preferences/main.py
@@ -290,6 +290,7 @@ class Preferences(QMainWindow):
self.apply_action.setEnabled(False)
self.showing_widget.changed_signal.connect(lambda :
self.apply_action.setEnabled(True))
+ self.showing_widget.restart_now.connect(self.restart_now)
self.restore_action.setEnabled(self.showing_widget.supports_restoring_to_defaults)
tt = self.showing_widget.restore_defaults_desc
if not self.restore_action.isEnabled():
@@ -319,6 +320,15 @@ class Preferences(QMainWindow):
elif self.stack.currentIndex() == 0:
self.close()
+ def restart_now(self):
+ try:
+ self.showing_widget.commit()
+ except AbortCommit:
+ return
+ self.hide_plugin()
+ self.close()
+ self.gui.quit(restart=True)
+
def commit(self, *args):
try:
must_restart = self.showing_widget.commit()
diff --git a/src/calibre/gui2/preferences/plugins.py b/src/calibre/gui2/preferences/plugins.py
index 2d89b187bf..1a6e58d6bd 100644
--- a/src/calibre/gui2/preferences/plugins.py
+++ b/src/calibre/gui2/preferences/plugins.py
@@ -384,6 +384,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self._plugin_model.populate()
self._plugin_model.reset()
self.changed_signal.emit()
+ if d.do_restart:
+ self.restart_now.emit()
def reload_store_plugins(self):
self.gui.load_store_plugins()