mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix cover display on high dpi screens in the edit metadata and convert dialog
This commit is contained in:
parent
2035356c53
commit
68c1303c21
@ -97,11 +97,14 @@ class MetadataWidget(Widget, Ui_Form):
|
||||
pm = QPixmap()
|
||||
pm.loadFromData(cover)
|
||||
if not pm.isNull():
|
||||
pm.setDevicePixelRatio(getattr(self, 'devicePixelRatioF', self.devicePixelRatio)())
|
||||
self.cover.setPixmap(pm)
|
||||
self.cover_data = cover
|
||||
self.set_cover_tooltip(pm)
|
||||
else:
|
||||
self.cover.setPixmap(QPixmap(I('default_cover.png')))
|
||||
pm = QPixmap(I('default_cover.png'))
|
||||
pm.setDevicePixelRatio(getattr(self, 'devicePixelRatioF', self.devicePixelRatio)())
|
||||
self.cover.setPixmap(pm)
|
||||
self.cover.setToolTip(_('This book has no cover'))
|
||||
for x in ('author', 'series', 'publisher'):
|
||||
x = getattr(self, x)
|
||||
@ -201,6 +204,7 @@ class MetadataWidget(Widget, Ui_Form):
|
||||
if cover:
|
||||
pix = QPixmap()
|
||||
pix.loadFromData(cover)
|
||||
pix.setDevicePixelRatio(getattr(self, 'devicePixelRatioF', self.devicePixelRatio)())
|
||||
if pix.isNull():
|
||||
d = error_dialog(self.parent(), _('Error reading file'),
|
||||
_file + _(" is not a valid picture"))
|
||||
|
@ -1172,6 +1172,7 @@ class Cover(ImageView): # {{{
|
||||
pm = QPixmap(I('default_cover.png'))
|
||||
else:
|
||||
self._cdata = cdata
|
||||
pm.setDevicePixelRatio(getattr(self, 'devicePixelRatioF', self.devicePixelRatio)())
|
||||
self.setPixmap(pm)
|
||||
tt = _('This book has no cover')
|
||||
if self._cdata:
|
||||
|
@ -343,9 +343,9 @@ class ImageView(QWidget, ImageDropMixin): # {{{
|
||||
cw, ch = self.rect().width(), self.rect().height()
|
||||
scaled, nw, nh = fit_image(w, h, cw, ch)
|
||||
if scaled:
|
||||
pmap = pmap.scaled(nw, nh, Qt.IgnoreAspectRatio,
|
||||
pmap = pmap.scaled(nw*pmap.devicePixelRatio(), nh*pmap.devicePixelRatio(), Qt.IgnoreAspectRatio,
|
||||
Qt.SmoothTransformation)
|
||||
w, h = pmap.width(), pmap.height()
|
||||
w, h = pmap.width()/pmap.devicePixelRatio(), pmap.height()/pmap.devicePixelRatio()
|
||||
x = int(abs(cw - w)/2.)
|
||||
y = int(abs(ch - h)/2.)
|
||||
target = QRect(x, y, w, h)
|
||||
|
Loading…
x
Reference in New Issue
Block a user