def data(self, index, role): plugin = self.plugins[index.row()][0] if index.isValid(): if role == Qt.DisplayRole: return QVariant(plugin.name) if role == Qt.DecorationRole: for directory in GeneralUtilities.getPluginDirs(): picturePath = os.path.join(directory, plugin.plugin_object.name, 'logo.png') if picturePath and os.path.exists(picturePath): pixmap = QPixmap(picturePath) return QIcon( pixmap.scaled(30, 30, Qt.IgnoreAspectRatio, Qt.FastTransformation)) pixmap = QPixmap( os.path.join(GeneralUtilities.getIncludeDir(), 'generic_plugin.png')) pixmap.scaled(30, 30, Qt.IgnoreAspectRatio) return QIcon(pixmap) if role == Qt.CheckStateRole: if plugin: return Qt.Checked if plugin.name in self.checkedPlugins else Qt.Unchecked else: return QVariant()
def __init__(self, parent=None): # Load the installed plugins and read their metadata self.PluginManager = PluginManagerSingleton.get() self.PluginManager.setCategoriesFilter({'Input': InputPlugin}) self.PluginManager.setPluginPlaces(GeneralUtilities.getPluginDirs()) self.PluginManager.locatePlugins() self.PluginManager.collectPlugins() QDialog.__init__(self, parent) self.ui = Ui_PluginsConfigurationDialog() self.ui.setupUi(self)
def getConfigObj(self, config_filename=None): if config_filename is None: config_filename = self.name+".conf" configfiles = [] for dir in GeneralUtilities.getPluginDirs(): configfiles.append(expanduser(os.path.join(dir, self.name, config_filename))) logger.debug("Loading config from: "+str(configfiles)) config = MultiLevelConfigObj(infiles = configfiles) config.create_empty = False return config
def getConfigObj(self, config_filename=None): if config_filename is None: config_filename = self.name + '.conf' configfiles = [] for directory in GeneralUtilities.getPluginDirs(): configfiles.append(expanduser(os.path.join(directory, self.name, config_filename))) logger.debug('Loading config from: ' + str(configfiles)) config = MultiLevelConfigObj(infiles=configfiles) config.create_empty = False return config
def loadConfiguredPlugins(self): ''' Returns a list with the configured plugins that can be used ''' self.PluginManager = PluginManagerSingleton.get() self.PluginManager.setCategoriesFilter({'Input': InputPlugin}) self.PluginManager.setPluginPlaces(GeneralUtilities.getPluginDirs()) self.PluginManager.locatePlugins() self.PluginManager.loadPlugins() pluginList = sorted(self.PluginManager.getAllPlugins(), key=lambda x: x.name) return [[plugin, 0] for plugin in pluginList]
def loadConfiguredPlugins(self): """ Returns a list with the configured plugins that can be used for place based projects """ self.PluginManager = PluginManagerSingleton.get() self.PluginManager.setCategoriesFilter({'Input': InputPlugin}) self.PluginManager.setPluginPlaces(GeneralUtilities.getPluginDirs()) self.PluginManager.locatePlugins() self.PluginManager.loadPlugins() pluginList = sorted(self.PluginManager.getAllPlugins(), key=lambda x: x.name) return [[plugin, 0] for plugin in pluginList if plugin.plugin_object.hasLocationBasedMode is True]
def data(self, index, role): pluginListItem= self.plugins[index.row()] if index.isValid(): if role == Qt.DisplayRole: return QVariant(pluginListItem[0].name) if role == Qt.DecorationRole: for directory in GeneralUtilities.getPluginDirs(): picturePath = os.path.join(directory, pluginListItem[0].plugin_object.name, 'logo.png') if picturePath and os.path.exists(picturePath): pixmap = QPixmap(picturePath) return QIcon(pixmap) pixmap = QPixmap(':/creepy/folder') return QIcon(pixmap) else: return QVariant()
def data(self, index, role): plugin = self.plugins[index.row()][0] if index.isValid(): if role == Qt.DisplayRole: return QVariant(plugin.name) if role == Qt.DecorationRole: for dir in GeneralUtilities.getPluginDirs(): picturePath = os.path.join(dir, plugin.plugin_object.name, 'logo.png') if picturePath and os.path.exists(picturePath): pixmap = QPixmap(picturePath) return QIcon(pixmap.scaled(30, 30, Qt.IgnoreAspectRatio, Qt.FastTransformation)) pixmap = QPixmap(os.path.join(GeneralUtilities.getIncludeDir(), 'generic_plugin.png')) pixmap.scaled(30, 30, Qt.IgnoreAspectRatio) return QIcon(pixmap) if role == Qt.CheckStateRole: if plugin: return (Qt.Checked if plugin.name in self.checkedPlugins else Qt.Unchecked) else: return QVariant()