mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use correct text color for selected rows in the list of matches when
downloading metadata and showing results in get books. See #1004568
This commit is contained in:
parent
76f3aaec8f
commit
d1d5e0d146
@ -17,7 +17,7 @@ from Queue import Queue, Empty
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from PyQt4.Qt import (QStyledItemDelegate, QTextDocument, QRectF, QIcon, Qt,
|
from PyQt4.Qt import (QStyledItemDelegate, QTextDocument, QRectF, QIcon, Qt,
|
||||||
QApplication, QDialog, QVBoxLayout, QLabel, QDialogButtonBox,
|
QApplication, QDialog, QVBoxLayout, QLabel, QDialogButtonBox, QStyle,
|
||||||
QStackedWidget, QWidget, QTableView, QGridLayout, QFontInfo, QPalette,
|
QStackedWidget, QWidget, QTableView, QGridLayout, QFontInfo, QPalette,
|
||||||
QTimer, pyqtSignal, QAbstractTableModel, QVariant, QSize, QListView,
|
QTimer, pyqtSignal, QAbstractTableModel, QVariant, QSize, QListView,
|
||||||
QPixmap, QAbstractListModel, QColor, QRect, QTextBrowser, QModelIndex)
|
QPixmap, QAbstractListModel, QColor, QRect, QTextBrowser, QModelIndex)
|
||||||
@ -45,13 +45,18 @@ class RichTextDelegate(QStyledItemDelegate): # {{{
|
|||||||
QStyledItemDelegate.__init__(self, parent)
|
QStyledItemDelegate.__init__(self, parent)
|
||||||
self.max_width = max_width
|
self.max_width = max_width
|
||||||
|
|
||||||
def to_doc(self, index):
|
def to_doc(self, index, option=None):
|
||||||
doc = QTextDocument()
|
doc = QTextDocument()
|
||||||
|
if option is not None and option.state & QStyle.State_Selected:
|
||||||
|
p = option.palette
|
||||||
|
c = p.color(p.Active, p.HighlightedText)
|
||||||
|
c = 'rgb(%d, %d, %d)'%c.getRgb()[:3]
|
||||||
|
doc.setDefaultStyleSheet(' * { color: %s }'%c)
|
||||||
doc.setHtml(index.data().toString())
|
doc.setHtml(index.data().toString())
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
def sizeHint(self, option, index):
|
def sizeHint(self, option, index):
|
||||||
doc = self.to_doc(index)
|
doc = self.to_doc(index, option=option)
|
||||||
ans = doc.size().toSize()
|
ans = doc.size().toSize()
|
||||||
if ans.width() > self.max_width - 10:
|
if ans.width() > self.max_width - 10:
|
||||||
ans.setWidth(self.max_width)
|
ans.setWidth(self.max_width)
|
||||||
@ -63,7 +68,7 @@ class RichTextDelegate(QStyledItemDelegate): # {{{
|
|||||||
painter.save()
|
painter.save()
|
||||||
painter.setClipRect(QRectF(option.rect))
|
painter.setClipRect(QRectF(option.rect))
|
||||||
painter.translate(option.rect.topLeft())
|
painter.translate(option.rect.topLeft())
|
||||||
self.to_doc(index).drawContents(painter)
|
self.to_doc(index, option).drawContents(painter)
|
||||||
painter.restore()
|
painter.restore()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -549,7 +554,7 @@ class CoverWorker(Thread): # {{{
|
|||||||
images = ['donate.png', 'config.png', 'column.png', 'eject.png', ]
|
images = ['donate.png', 'config.png', 'column.png', 'eject.png', ]
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
for pl, im in zip(metadata_plugins(['cover']), images):
|
for pl, im in zip(metadata_plugins(['cover']), images):
|
||||||
self.rq.put((pl, 1, 1, 'png', I(im, data=True)))
|
self.rq.put((pl.name, 1, 1, 'png', I(im, data=True)))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user