diff --git a/src/calibre/gui2/dialogs/plugin_updater.py b/src/calibre/gui2/dialogs/plugin_updater.py
index 0fd4658189..a05f49ed61 100644
--- a/src/calibre/gui2/dialogs/plugin_updater.py
+++ b/src/calibre/gui2/dialogs/plugin_updater.py
@@ -413,6 +413,25 @@ class DisplayPluginModel(QAbstractTableModel):
_('Right-click to see more options'))
+def notify_on_successful_install(parent, plugin):
+ d = info_dialog(parent, _('Success'),
+ _('Plugin {0} successfully installed under '
+ '{1}. You may have to restart calibre '
+ 'for the plugin to take effect.').format(plugin.name, plugin.type),
+ show_copy_button=False)
+ b = d.bb.addButton(_('&Restart calibre now'), QDialogButtonBox.ButtonRole.AcceptRole)
+ b.setIcon(QIcon.ic('lt.png'))
+ d.do_restart = False
+
+ def rf():
+ d.do_restart = True
+ b.clicked.connect(rf)
+ d.set_details('')
+ d.exec()
+ b.clicked.disconnect()
+ return d.do_restart
+
+
class PluginUpdaterDialog(SizePersistedDialog):
initial_extra_size = QSize(350, 100)
@@ -716,23 +735,7 @@ class PluginUpdaterDialog(SizePersistedDialog):
widget.gui = self.gui
widget.check_for_add_to_toolbars(plugin, previously_installed=plugin.name in installed_plugins)
self.gui.status_bar.showMessage(_('Plugin installed: %s') % display_plugin.name)
- d = info_dialog(self.gui, _('Success'),
- _('Plugin {0} successfully installed under '
- '{1}. You may have to restart calibre '
- 'for the plugin to take effect.').format(plugin.name, plugin.type),
- show_copy_button=False)
- b = d.bb.addButton(_('&Restart calibre now'), QDialogButtonBox.ButtonRole.AcceptRole)
- b.setIcon(QIcon.ic('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
-
+ do_restart = notify_on_successful_install(self.gui, plugin)
display_plugin.plugin = plugin
# We cannot read the 'actual' version information as the plugin will not be loaded yet
display_plugin.installed_version = display_plugin.available_version
diff --git a/src/calibre/gui2/preferences/plugins.py b/src/calibre/gui2/preferences/plugins.py
index 0fd267b929..7316c897ad 100644
--- a/src/calibre/gui2/preferences/plugins.py
+++ b/src/calibre/gui2/preferences/plugins.py
@@ -331,14 +331,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self._plugin_model.endResetModel()
self.changed_signal.emit()
self.check_for_add_to_toolbars(plugin, previously_installed=plugin.name in installed_plugins)
- info_dialog(self, _('Success'),
- _('Plugin {0} successfully installed under '
- '{1}. You may have to restart calibre '
- 'for the plugin to take effect.').format(plugin.name, plugin.type),
- show=True, show_copy_button=False)
+ from calibre.gui2.dialogs.plugin_updater import notify_on_successful_install
+ do_restart = notify_on_successful_install(self, plugin)
idx = self._plugin_model.plugin_to_index_by_properties(plugin)
if idx.isValid():
self.highlight_index(idx)
+ if do_restart:
+ self.restart_now.emit()
else:
error_dialog(self, _('No valid plugin path'),
_('%s is not a valid plugin path')%path).exec()