mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Make it clearer when a plugin has been disabled
This commit is contained in:
parent
c0a35f9553
commit
c612c17db5
@ -447,7 +447,8 @@ def plugin_for_catalog_format(fmt):
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def device_plugins(include_disabled=False): # {{{
|
# Device plugins {{{
|
||||||
|
def device_plugins(include_disabled=False):
|
||||||
for plugin in _initialized_plugins:
|
for plugin in _initialized_plugins:
|
||||||
if isinstance(plugin, DevicePlugin):
|
if isinstance(plugin, DevicePlugin):
|
||||||
if include_disabled or not is_disabled(plugin):
|
if include_disabled or not is_disabled(plugin):
|
||||||
@ -456,6 +457,13 @@ def device_plugins(include_disabled=False): # {{{
|
|||||||
False):
|
False):
|
||||||
plugin.do_delayed_plugin_initialization()
|
plugin.do_delayed_plugin_initialization()
|
||||||
yield plugin
|
yield plugin
|
||||||
|
|
||||||
|
def disabled_device_plugins():
|
||||||
|
for plugin in _initialized_plugins:
|
||||||
|
if isinstance(plugin, DevicePlugin):
|
||||||
|
if is_disabled(plugin):
|
||||||
|
if platform in plugin.supported_platforms:
|
||||||
|
yield plugin
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# epub fixers {{{
|
# epub fixers {{{
|
||||||
|
@ -55,7 +55,8 @@ def get_connected_device():
|
|||||||
break
|
break
|
||||||
return dev
|
return dev
|
||||||
|
|
||||||
def debug(ioreg_to_tmp=False, buf=None, plugins=None):
|
def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
||||||
|
disabled_plugins=None):
|
||||||
'''
|
'''
|
||||||
If plugins is None, then this method calls startup and shutdown on the
|
If plugins is None, then this method calls startup and shutdown on the
|
||||||
device plugins. So if you are using it in a context where startup could
|
device plugins. So if you are using it in a context where startup could
|
||||||
@ -63,7 +64,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None):
|
|||||||
device plugins as the plugins parameter.
|
device plugins as the plugins parameter.
|
||||||
'''
|
'''
|
||||||
import textwrap
|
import textwrap
|
||||||
from calibre.customize.ui import device_plugins
|
from calibre.customize.ui import device_plugins, disabled_device_plugins
|
||||||
from calibre.debug import print_basic_debug_info
|
from calibre.debug import print_basic_debug_info
|
||||||
from calibre.devices.scanner import DeviceScanner, win_pnp_drives
|
from calibre.devices.scanner import DeviceScanner, win_pnp_drives
|
||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, isosx
|
||||||
@ -85,6 +86,9 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None):
|
|||||||
except:
|
except:
|
||||||
out('Startup failed for device plugin: %s'%d)
|
out('Startup failed for device plugin: %s'%d)
|
||||||
|
|
||||||
|
if disabled_plugins is None:
|
||||||
|
disabled_plugins = list(disabled_device_plugins())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print_basic_debug_info(out=buf)
|
print_basic_debug_info(out=buf)
|
||||||
s = DeviceScanner()
|
s = DeviceScanner()
|
||||||
@ -113,9 +117,10 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None):
|
|||||||
ioreg += 'Output from osx_get_usb_drives:\n'+drives+'\n\n'
|
ioreg += 'Output from osx_get_usb_drives:\n'+drives+'\n\n'
|
||||||
ioreg += Device.run_ioreg()
|
ioreg += Device.run_ioreg()
|
||||||
connected_devices = []
|
connected_devices = []
|
||||||
out('Available plugins:', textwrap.fill(' '.join([x.__class__.__name__ for x in
|
if disabled_plugins:
|
||||||
devplugins])))
|
out('\nDisabled plugins:', textwrap.fill(' '.join([x.__class__.__name__ for x in
|
||||||
out(' ')
|
disabled_plugins])))
|
||||||
|
out(' ')
|
||||||
found_dev = False
|
found_dev = False
|
||||||
for dev in devplugins:
|
for dev in devplugins:
|
||||||
if not dev.MANAGES_DEVICE_PRESENCE: continue
|
if not dev.MANAGES_DEVICE_PRESENCE: continue
|
||||||
|
@ -11,7 +11,7 @@ from PyQt4.Qt import (QMenu, QAction, QActionGroup, QIcon, SIGNAL,
|
|||||||
QDialogButtonBox)
|
QDialogButtonBox)
|
||||||
|
|
||||||
from calibre.customize.ui import (available_input_formats, available_output_formats,
|
from calibre.customize.ui import (available_input_formats, available_output_formats,
|
||||||
device_plugins)
|
device_plugins, disabled_device_plugins)
|
||||||
from calibre.devices.interface import DevicePlugin
|
from calibre.devices.interface import DevicePlugin
|
||||||
from calibre.devices.errors import (UserFeedback, OpenFeedback, OpenFailed,
|
from calibre.devices.errors import (UserFeedback, OpenFeedback, OpenFailed,
|
||||||
InitialConnectionError)
|
InitialConnectionError)
|
||||||
@ -130,6 +130,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
self.setDaemon(True)
|
self.setDaemon(True)
|
||||||
# [Device driver, Showing in GUI, Ejected]
|
# [Device driver, Showing in GUI, Ejected]
|
||||||
self.devices = list(device_plugins())
|
self.devices = list(device_plugins())
|
||||||
|
self.disabled_device_plugins = list(disabled_device_plugins())
|
||||||
self.managed_devices = [x for x in self.devices if
|
self.managed_devices = [x for x in self.devices if
|
||||||
not x.MANAGES_DEVICE_PRESENCE]
|
not x.MANAGES_DEVICE_PRESENCE]
|
||||||
self.unmanaged_devices = [x for x in self.devices if
|
self.unmanaged_devices = [x for x in self.devices if
|
||||||
@ -425,7 +426,8 @@ class DeviceManager(Thread): # {{{
|
|||||||
|
|
||||||
def _debug_detection(self):
|
def _debug_detection(self):
|
||||||
from calibre.devices import debug
|
from calibre.devices import debug
|
||||||
raw = debug(plugins=self.devices)
|
raw = debug(plugins=self.devices,
|
||||||
|
disabled_plugins=self.disabled_device_plugins)
|
||||||
return raw
|
return raw
|
||||||
|
|
||||||
def debug_detection(self, done):
|
def debug_detection(self, done):
|
||||||
|
@ -29,7 +29,7 @@ class PluginModel(QAbstractItemModel, SearchQueryParser): # {{{
|
|||||||
SearchQueryParser.__init__(self, ['all'])
|
SearchQueryParser.__init__(self, ['all'])
|
||||||
self.show_only_user_plugins = show_only_user_plugins
|
self.show_only_user_plugins = show_only_user_plugins
|
||||||
self.icon = QVariant(QIcon(I('plugins.png')))
|
self.icon = QVariant(QIcon(I('plugins.png')))
|
||||||
p = QIcon(self.icon).pixmap(32, 32, QIcon.Disabled, QIcon.On)
|
p = QIcon(self.icon).pixmap(64, 64, QIcon.Disabled, QIcon.On)
|
||||||
self.disabled_icon = QVariant(QIcon(p))
|
self.disabled_icon = QVariant(QIcon(p))
|
||||||
self._p = p
|
self._p = p
|
||||||
self.populate()
|
self.populate()
|
||||||
@ -194,17 +194,20 @@ class PluginModel(QAbstractItemModel, SearchQueryParser): # {{{
|
|||||||
dict(plugin_type=category, plugins=_('plugins')))
|
dict(plugin_type=category, plugins=_('plugins')))
|
||||||
else:
|
else:
|
||||||
plugin = self.index_to_plugin(index)
|
plugin = self.index_to_plugin(index)
|
||||||
|
disabled = is_disabled(plugin)
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
ver = '.'.join(map(str, plugin.version))
|
ver = '.'.join(map(str, plugin.version))
|
||||||
desc = '\n'.join(textwrap.wrap(plugin.description, 100))
|
desc = '\n'.join(textwrap.wrap(plugin.description, 100))
|
||||||
ans='%s (%s) %s %s\n%s'%(plugin.name, ver, _('by'), plugin.author, desc)
|
ans='%s (%s) %s %s\n%s'%(plugin.name, ver, _('by'), plugin.author, desc)
|
||||||
c = plugin_customization(plugin)
|
c = plugin_customization(plugin)
|
||||||
if c:
|
if c and not disabled:
|
||||||
ans += _('\nCustomization: ')+c
|
ans += _('\nCustomization: ')+c
|
||||||
|
if disabled:
|
||||||
|
ans += _('\n\nThis plugin has been disabled')
|
||||||
return QVariant(ans)
|
return QVariant(ans)
|
||||||
if role == Qt.DecorationRole:
|
if role == Qt.DecorationRole:
|
||||||
return self.disabled_icon if is_disabled(plugin) else self.icon
|
return self.disabled_icon if disabled else self.icon
|
||||||
if role == Qt.ForegroundRole and is_disabled(plugin):
|
if role == Qt.ForegroundRole and disabled:
|
||||||
return QVariant(QBrush(Qt.gray))
|
return QVariant(QBrush(Qt.gray))
|
||||||
if role == Qt.UserRole:
|
if role == Qt.UserRole:
|
||||||
return plugin
|
return plugin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user