From f2fae35eb2c35c811eec9d45a3f4bff6fda0a1ff Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 29 May 2009 11:06:48 -0700 Subject: [PATCH] Fix bug preventing the re-enabling of disabled plugins --- src/calibre/gui2/dialogs/config.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/dialogs/config.py b/src/calibre/gui2/dialogs/config.py index 831d44251e..225a3b3ed7 100644 --- a/src/calibre/gui2/dialogs/config.py +++ b/src/calibre/gui2/dialogs/config.py @@ -6,7 +6,7 @@ from binascii import hexlify, unhexlify from PyQt4.Qt import QDialog, QMessageBox, QListWidgetItem, QIcon, \ QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit, \ QStringListModel, QAbstractItemModel, QFont, \ - SIGNAL, QTimer, Qt, QSize, QVariant, QUrl, \ + SIGNAL, QTimer, Qt, QSize, QVariant, QUrl, QBrush, \ QModelIndex, QInputDialog, QAbstractTableModel from calibre.constants import islinux, iswindows @@ -30,6 +30,9 @@ class PluginModel(QAbstractItemModel): def __init__(self, *args): QAbstractItemModel.__init__(self, *args) self.icon = QVariant(QIcon(':/images/plugins.svg')) + p = QIcon(self.icon).pixmap(32, 32, QIcon.Disabled, QIcon.On) + self.disabled_icon = QVariant(QIcon(p)) + self._p = p self.populate() def populate(self): @@ -89,9 +92,7 @@ class PluginModel(QAbstractItemModel): return 0 if index.internalId() == -1: return Qt.ItemIsEnabled - flags = Qt.ItemIsSelectable - if not is_disabled(self.data(index, Qt.UserRole)): - flags |= Qt.ItemIsEnabled + flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled return flags def data(self, index, role): @@ -112,7 +113,9 @@ class PluginModel(QAbstractItemModel): ans += '\nCustomization: '+c return QVariant(ans) if role == Qt.DecorationRole: - return self.icon + return self.disabled_icon if is_disabled(plugin) else self.icon + if role == Qt.ForegroundRole and is_disabled(plugin): + return QVariant(QBrush(Qt.gray)) if role == Qt.UserRole: return plugin return NONE