mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a checkbox to preferences->plugins to show only user installed plugins
This commit is contained in:
parent
c1737d8f19
commit
77a73b84f2
@ -24,18 +24,27 @@ from calibre.constants import iswindows
|
||||
|
||||
class PluginModel(QAbstractItemModel, SearchQueryParser): # {{{
|
||||
|
||||
def __init__(self, *args):
|
||||
QAbstractItemModel.__init__(self, *args)
|
||||
def __init__(self, show_only_user_plugins=False):
|
||||
QAbstractItemModel.__init__(self)
|
||||
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)
|
||||
self.disabled_icon = QVariant(QIcon(p))
|
||||
self._p = p
|
||||
self.populate()
|
||||
|
||||
def toggle_shown_plugins(self, show_only_user_plugins):
|
||||
self.show_only_user_plugins = show_only_user_plugins
|
||||
self.populate()
|
||||
self.reset()
|
||||
|
||||
def populate(self):
|
||||
self._data = {}
|
||||
for plugin in initialized_plugins():
|
||||
if (getattr(plugin, 'plugin_path', None) is None
|
||||
and self.show_only_user_plugins):
|
||||
continue
|
||||
if plugin.type not in self._data:
|
||||
self._data[plugin.type] = [plugin]
|
||||
else:
|
||||
@ -64,6 +73,7 @@ class PluginModel(QAbstractItemModel, SearchQueryParser): # {{{
|
||||
if p < 0:
|
||||
if query in lower(self.categories[c]):
|
||||
ans.add((c, p))
|
||||
continue
|
||||
else:
|
||||
try:
|
||||
plugin = self._data[self.categories[c]][p]
|
||||
@ -209,7 +219,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
|
||||
def genesis(self, gui):
|
||||
self.gui = gui
|
||||
self._plugin_model = PluginModel()
|
||||
self._plugin_model = PluginModel(self.user_installed_plugins.isChecked())
|
||||
self.plugin_view.setModel(self._plugin_model)
|
||||
self.plugin_view.setStyleSheet(
|
||||
"QTreeView::item { padding-bottom: 10px;}")
|
||||
@ -226,6 +236,10 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
self.next_button.clicked.connect(self.find_next)
|
||||
self.previous_button.clicked.connect(self.find_previous)
|
||||
self.changed_signal.connect(self.reload_store_plugins)
|
||||
self.user_installed_plugins.stateChanged.connect(self.show_user_installed_plugins)
|
||||
|
||||
def show_user_installed_plugins(self, state):
|
||||
self._plugin_model.toggle_shown_plugins(self.user_installed_plugins.isChecked())
|
||||
|
||||
def find(self, query):
|
||||
idx = self._plugin_model.find(query)
|
||||
|
@ -65,6 +65,16 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="user_installed_plugins">
|
||||
<property name="toolTip">
|
||||
<string>Show only those plugins that have been installed by you</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show only &user installed plugins</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="plugin_view">
|
||||
<property name="alternatingRowColors">
|
||||
|
Loading…
x
Reference in New Issue
Block a user