mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Fix bug preventing the re-enabling of disabled plugins
This commit is contained in:
parent
94e3c666d8
commit
f2fae35eb2
@ -6,7 +6,7 @@ from binascii import hexlify, unhexlify
|
|||||||
from PyQt4.Qt import QDialog, QMessageBox, QListWidgetItem, QIcon, \
|
from PyQt4.Qt import QDialog, QMessageBox, QListWidgetItem, QIcon, \
|
||||||
QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit, \
|
QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit, \
|
||||||
QStringListModel, QAbstractItemModel, QFont, \
|
QStringListModel, QAbstractItemModel, QFont, \
|
||||||
SIGNAL, QTimer, Qt, QSize, QVariant, QUrl, \
|
SIGNAL, QTimer, Qt, QSize, QVariant, QUrl, QBrush, \
|
||||||
QModelIndex, QInputDialog, QAbstractTableModel
|
QModelIndex, QInputDialog, QAbstractTableModel
|
||||||
|
|
||||||
from calibre.constants import islinux, iswindows
|
from calibre.constants import islinux, iswindows
|
||||||
@ -30,6 +30,9 @@ class PluginModel(QAbstractItemModel):
|
|||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
QAbstractItemModel.__init__(self, *args)
|
QAbstractItemModel.__init__(self, *args)
|
||||||
self.icon = QVariant(QIcon(':/images/plugins.svg'))
|
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()
|
self.populate()
|
||||||
|
|
||||||
def populate(self):
|
def populate(self):
|
||||||
@ -89,9 +92,7 @@ class PluginModel(QAbstractItemModel):
|
|||||||
return 0
|
return 0
|
||||||
if index.internalId() == -1:
|
if index.internalId() == -1:
|
||||||
return Qt.ItemIsEnabled
|
return Qt.ItemIsEnabled
|
||||||
flags = Qt.ItemIsSelectable
|
flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled
|
||||||
if not is_disabled(self.data(index, Qt.UserRole)):
|
|
||||||
flags |= Qt.ItemIsEnabled
|
|
||||||
return flags
|
return flags
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
@ -112,7 +113,9 @@ class PluginModel(QAbstractItemModel):
|
|||||||
ans += '\nCustomization: '+c
|
ans += '\nCustomization: '+c
|
||||||
return QVariant(ans)
|
return QVariant(ans)
|
||||||
if role == Qt.DecorationRole:
|
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:
|
if role == Qt.UserRole:
|
||||||
return plugin
|
return plugin
|
||||||
return NONE
|
return NONE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user