mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When presenting the calibre must be restarted warning after installing a new plugin, add a restart now button so that the user can conveniently restart calibre
This commit is contained in:
parent
9d90cfd756
commit
ffdbd911e0
@ -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):
|
||||
|
@ -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 <b>{0}</b> successfully installed under <b>'
|
||||
' {1} plugins</b>. 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()
|
||||
|
@ -236,6 +236,7 @@ class ConfigWidgetBase(QWidget, ConfigWidgetInterface):
|
||||
'''
|
||||
|
||||
changed_signal = pyqtSignal()
|
||||
restart_now = pyqtSignal()
|
||||
supports_restoring_to_defaults = True
|
||||
restart_critical = False
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user