mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Book details popup window: Show the cover size in the bottom right corner if the option to show cover size in the Book details panel is set. Fixes #1716520 [Would like to see the same cover info that is shown on the details panel to also show in the details list when using the menu to look.](https://bugs.launchpad.net/calibre/+bug/1716520)
This commit is contained in:
parent
110b022a86
commit
545443190e
@ -46,7 +46,7 @@ class BookInfo(QDialog):
|
||||
self.setLayout(l)
|
||||
l.addWidget(self.splitter)
|
||||
|
||||
self.cover = CoverView(self)
|
||||
self.cover = CoverView(self, show_size=gprefs['bd_overlay_cover_size'])
|
||||
self.cover.resizeEvent = self.cover_view_resized
|
||||
self.cover.cover_changed.connect(self.cover_changed)
|
||||
self.cover_pixmap = None
|
||||
@ -188,6 +188,7 @@ class BookInfo(QDialog):
|
||||
sz = self.cover_pixmap.size()
|
||||
tt += _('Cover size: %(width)d x %(height)d pixels')%dict(width=sz.width(), height=sz.height())
|
||||
self.cover.setToolTip(tt)
|
||||
self.cover.pixmap_size = sz.width(), sz.height()
|
||||
|
||||
def refresh(self, row, mi=None):
|
||||
if isinstance(row, QModelIndex):
|
||||
|
@ -295,7 +295,22 @@ class ImageDropMixin(object): # {{{
|
||||
# }}}
|
||||
|
||||
|
||||
class ImageView(QWidget, ImageDropMixin): # {{{
|
||||
# ImageView {{{
|
||||
|
||||
def draw_size(p, rect, w, h):
|
||||
rect = rect.adjusted(0, 0, 0, -4)
|
||||
f = p.font()
|
||||
f.setBold(True)
|
||||
p.setFont(f)
|
||||
sz = u'\u00a0%d x %d\u00a0'%(w, h)
|
||||
flags = Qt.AlignBottom|Qt.AlignRight|Qt.TextSingleLine
|
||||
szrect = p.boundingRect(rect, flags, sz)
|
||||
p.fillRect(szrect.adjusted(0, 0, 0, 4), QColor(0, 0, 0, 200))
|
||||
p.setPen(QPen(QColor(255,255,255)))
|
||||
p.drawText(rect, flags, sz)
|
||||
|
||||
|
||||
class ImageView(QWidget, ImageDropMixin):
|
||||
|
||||
BORDER_WIDTH = 1
|
||||
cover_changed = pyqtSignal(object)
|
||||
@ -364,16 +379,7 @@ class ImageView(QWidget, ImageDropMixin): # {{{
|
||||
p.setPen(pen)
|
||||
p.drawRect(target)
|
||||
if self.show_size:
|
||||
sztgt = target.adjusted(0, 0, 0, -4)
|
||||
f = p.font()
|
||||
f.setBold(True)
|
||||
p.setFont(f)
|
||||
sz = u'\u00a0%d x %d\u00a0'%(ow, oh)
|
||||
flags = Qt.AlignBottom|Qt.AlignRight|Qt.TextSingleLine
|
||||
szrect = p.boundingRect(sztgt, flags, sz)
|
||||
p.fillRect(szrect.adjusted(0, 0, 0, 4), QColor(0, 0, 0, 200))
|
||||
p.setPen(QPen(QColor(255,255,255)))
|
||||
p.drawText(sztgt, flags, sz)
|
||||
draw_size(p, target, ow, oh)
|
||||
p.end()
|
||||
# }}}
|
||||
|
||||
@ -383,8 +389,12 @@ class CoverView(QGraphicsView, ImageDropMixin): # {{{
|
||||
cover_changed = pyqtSignal(object)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.show_size = kwargs.pop('show_size', False)
|
||||
QGraphicsView.__init__(self, *args, **kwargs)
|
||||
ImageDropMixin.__init__(self)
|
||||
self.pixmap_size = 0, 0
|
||||
if self.show_size:
|
||||
self.setViewportUpdateMode(self.FullViewportUpdate)
|
||||
|
||||
def get_pixmap(self):
|
||||
for item in self.scene.items():
|
||||
@ -396,6 +406,13 @@ class CoverView(QGraphicsView, ImageDropMixin): # {{{
|
||||
self.scene.addPixmap(pmap)
|
||||
self.setScene(self.scene)
|
||||
|
||||
def paintEvent(self, ev):
|
||||
QGraphicsView.paintEvent(self, ev)
|
||||
if self.show_size:
|
||||
v = self.viewport()
|
||||
p = QPainter(v)
|
||||
draw_size(p, v.rect(), *self.pixmap_size)
|
||||
|
||||
# }}}
|
||||
|
||||
# BasicList {{{
|
||||
|
Loading…
x
Reference in New Issue
Block a user