mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-10-31 10:37:00 -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: | ||||
|         if isinstance(plugin, DevicePlugin): | ||||
|             if include_disabled or not is_disabled(plugin): | ||||
| @ -456,6 +457,13 @@ def device_plugins(include_disabled=False): # {{{ | ||||
|                             False): | ||||
|                         plugin.do_delayed_plugin_initialization() | ||||
|                     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 {{{ | ||||
|  | ||||
| @ -55,7 +55,8 @@ def get_connected_device(): | ||||
|             break | ||||
|     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 | ||||
|     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. | ||||
|     ''' | ||||
|     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.devices.scanner import DeviceScanner, win_pnp_drives | ||||
|     from calibre.constants import iswindows, isosx | ||||
| @ -85,6 +86,9 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None): | ||||
|             except: | ||||
|                 out('Startup failed for device plugin: %s'%d) | ||||
| 
 | ||||
|     if disabled_plugins is None: | ||||
|         disabled_plugins = list(disabled_device_plugins()) | ||||
| 
 | ||||
|     try: | ||||
|         print_basic_debug_info(out=buf) | ||||
|         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 += Device.run_ioreg() | ||||
|         connected_devices = [] | ||||
|         out('Available plugins:', textwrap.fill(' '.join([x.__class__.__name__ for x in | ||||
|             devplugins]))) | ||||
|         out(' ') | ||||
|         if disabled_plugins: | ||||
|             out('\nDisabled plugins:', textwrap.fill(' '.join([x.__class__.__name__ for x in | ||||
|                 disabled_plugins]))) | ||||
|             out(' ') | ||||
|         found_dev = False | ||||
|         for dev in devplugins: | ||||
|             if not dev.MANAGES_DEVICE_PRESENCE: continue | ||||
|  | ||||
| @ -11,7 +11,7 @@ from PyQt4.Qt import (QMenu, QAction, QActionGroup, QIcon, SIGNAL, | ||||
|                      QDialogButtonBox) | ||||
| 
 | ||||
| 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.errors import (UserFeedback, OpenFeedback, OpenFailed, | ||||
|                                     InitialConnectionError) | ||||
| @ -130,6 +130,7 @@ class DeviceManager(Thread): # {{{ | ||||
|         self.setDaemon(True) | ||||
|         # [Device driver, Showing in GUI, Ejected] | ||||
|         self.devices        = list(device_plugins()) | ||||
|         self.disabled_device_plugins = list(disabled_device_plugins()) | ||||
|         self.managed_devices = [x for x in self.devices if | ||||
|                 not x.MANAGES_DEVICE_PRESENCE] | ||||
|         self.unmanaged_devices = [x for x in self.devices if | ||||
| @ -425,7 +426,8 @@ class DeviceManager(Thread): # {{{ | ||||
| 
 | ||||
|     def _debug_detection(self): | ||||
|         from calibre.devices import debug | ||||
|         raw = debug(plugins=self.devices) | ||||
|         raw = debug(plugins=self.devices, | ||||
|                 disabled_plugins=self.disabled_device_plugins) | ||||
|         return raw | ||||
| 
 | ||||
|     def debug_detection(self, done): | ||||
|  | ||||
| @ -29,7 +29,7 @@ class PluginModel(QAbstractItemModel, SearchQueryParser): # {{{ | ||||
|         SearchQueryParser.__init__(self, ['all']) | ||||
|         self.show_only_user_plugins = show_only_user_plugins | ||||
|         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._p = p | ||||
|         self.populate() | ||||
| @ -194,17 +194,20 @@ class PluginModel(QAbstractItemModel, SearchQueryParser): # {{{ | ||||
|                         dict(plugin_type=category, plugins=_('plugins'))) | ||||
|         else: | ||||
|             plugin = self.index_to_plugin(index) | ||||
|             disabled = is_disabled(plugin) | ||||
|             if role == Qt.DisplayRole: | ||||
|                 ver = '.'.join(map(str, plugin.version)) | ||||
|                 desc = '\n'.join(textwrap.wrap(plugin.description, 100)) | ||||
|                 ans='%s (%s) %s %s\n%s'%(plugin.name, ver, _('by'), plugin.author, desc) | ||||
|                 c = plugin_customization(plugin) | ||||
|                 if c: | ||||
|                 if c and not disabled: | ||||
|                     ans += _('\nCustomization: ')+c | ||||
|                 if disabled: | ||||
|                     ans += _('\n\nThis plugin has been disabled') | ||||
|                 return QVariant(ans) | ||||
|             if role == Qt.DecorationRole: | ||||
|                 return self.disabled_icon if is_disabled(plugin) else self.icon | ||||
|             if role == Qt.ForegroundRole and is_disabled(plugin): | ||||
|                 return self.disabled_icon if disabled else self.icon | ||||
|             if role == Qt.ForegroundRole and disabled: | ||||
|                 return QVariant(QBrush(Qt.gray)) | ||||
|             if role == Qt.UserRole: | ||||
|                 return plugin | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user