mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add an option to the preferences drop down menu to restart calibre without third party plugins. Fixes #1944057 [[Enhancement] Additional option for Preference](https://bugs.launchpad.net/calibre/+bug/1944057)
This commit is contained in:
parent
325ced46cb
commit
8713c65f4b
@ -36,6 +36,9 @@ class PreferencesAction(InterfaceAction):
|
||||
pm.addSeparator()
|
||||
cm('restart', _('Restart in debug mode'), icon='debug.png',
|
||||
triggered=self.debug_restart, shortcut='Ctrl+Shift+R')
|
||||
pm.addSeparator()
|
||||
cm('restart_without_plugins', _('Restart ignoring third party plugins'), icon='debug.png',
|
||||
triggered=self.no_plugins_restart, shortcut='Ctrl+Alt+Shift+R')
|
||||
|
||||
self.preferences_menu = pm
|
||||
for x in (self.gui.preferences_action, self.qaction):
|
||||
@ -72,3 +75,6 @@ class PreferencesAction(InterfaceAction):
|
||||
|
||||
def debug_restart(self, *args):
|
||||
self.gui.quit(restart=True, debug_on_restart=True)
|
||||
|
||||
def no_plugins_restart(self, *args):
|
||||
self.gui.quit(restart=True, no_plugins_on_restart=True)
|
||||
|
@ -29,7 +29,7 @@ from calibre.utils.lock import SingleInstance
|
||||
from calibre.utils.monotonic import monotonic
|
||||
from polyglot.builtins import as_bytes, environ_item, range, unicode_type
|
||||
|
||||
after_quit_actions = {'debug_on_restart': False, 'restart_after_quit': False}
|
||||
after_quit_actions = {'debug_on_restart': False, 'restart_after_quit': False, 'no_plugins_on_restart': False}
|
||||
if iswindows:
|
||||
from calibre_extensions import winutil
|
||||
|
||||
@ -110,6 +110,8 @@ def find_portable_library():
|
||||
def init_qt(args):
|
||||
parser = option_parser()
|
||||
opts, args = parser.parse_args(args)
|
||||
if os.environ.pop('CALIBRE_IGNORE_PLUGINS_ON_RESTART', '') == '1':
|
||||
opts.ignore_plugins = True
|
||||
find_portable_library()
|
||||
if opts.with_library is not None:
|
||||
libpath = os.path.expanduser(opts.with_library)
|
||||
@ -421,6 +423,7 @@ def run_gui_(opts, args, app, gui_debug=None):
|
||||
if getattr(runner.main, 'restart_after_quit', False):
|
||||
after_quit_actions['restart_after_quit'] = True
|
||||
after_quit_actions['debug_on_restart'] = getattr(runner.main, 'debug_on_restart', False) or gui_debug is not None
|
||||
after_quit_actions['no_plugins_on_restart'] = getattr(runner.main, 'no_plugins_on_restart', False)
|
||||
else:
|
||||
if iswindows:
|
||||
try:
|
||||
@ -491,6 +494,8 @@ def restart_after_quit():
|
||||
if iswindows and not is_calibre_debug_exe:
|
||||
# detach the stdout/stderr/stdin handles
|
||||
winutil.prepare_for_restart()
|
||||
if after_quit_actions['no_plugins_on_restart']:
|
||||
os.environ['CALIBRE_IGNORE_PLUGINS_ON_RESTART'] = '1'
|
||||
if after_quit_actions['debug_on_restart']:
|
||||
run_in_debug_mode()
|
||||
return
|
||||
|
@ -1060,7 +1060,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
self.stack.tb_widget.save_state()
|
||||
|
||||
def quit(self, checked=True, restart=False, debug_on_restart=False,
|
||||
confirm_quit=True):
|
||||
confirm_quit=True, no_plugins_on_restart=False):
|
||||
if self.shutting_down:
|
||||
return
|
||||
if confirm_quit and not self.confirm_quit():
|
||||
@ -1072,6 +1072,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
traceback.print_exc()
|
||||
self.restart_after_quit = restart
|
||||
self.debug_on_restart = debug_on_restart
|
||||
self.no_plugins_on_restart = no_plugins_on_restart
|
||||
if self.system_tray_icon is not None and self.restart_after_quit:
|
||||
# Needed on windows to prevent multiple systray icons
|
||||
self.system_tray_icon.setVisible(False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user