mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Don't use Qt to process metadata covers as it causes image corruption in some windows installs
This commit is contained in:
parent
4bcc6cfbff
commit
c226e38062
@ -88,6 +88,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
pix = QPixmap(':/images/book.svg')
|
pix = QPixmap(':/images/book.svg')
|
||||||
self.cover.setPixmap(pix)
|
self.cover.setPixmap(pix)
|
||||||
self.cover_changed = True
|
self.cover_changed = True
|
||||||
|
self.cover_data = None
|
||||||
|
|
||||||
def select_cover(self, checked):
|
def select_cover(self, checked):
|
||||||
files = choose_images(self, 'change cover dialog',
|
files = choose_images(self, 'change cover dialog',
|
||||||
@ -121,6 +122,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
self.cover.setPixmap(pix)
|
self.cover.setPixmap(pix)
|
||||||
self.cover_changed = True
|
self.cover_changed = True
|
||||||
self.cpixmap = pix
|
self.cpixmap = pix
|
||||||
|
self.cover_data = cover
|
||||||
|
|
||||||
|
|
||||||
def add_format(self, x):
|
def add_format(self, x):
|
||||||
@ -191,6 +193,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
self.cover.setPixmap(pix)
|
self.cover.setPixmap(pix)
|
||||||
self.cover_changed = True
|
self.cover_changed = True
|
||||||
self.cpixmap = pix
|
self.cpixmap = pix
|
||||||
|
self.cover_data = cdata
|
||||||
|
|
||||||
def sync_formats(self):
|
def sync_formats(self):
|
||||||
old_extensions, new_extensions, paths = set(), set(), {}
|
old_extensions, new_extensions, paths = set(), set(), {}
|
||||||
@ -300,6 +303,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
pm.loadFromData(cover)
|
pm.loadFromData(cover)
|
||||||
if not pm.isNull():
|
if not pm.isNull():
|
||||||
self.cover.setPixmap(pm)
|
self.cover.setPixmap(pm)
|
||||||
|
self.cover_data = cover
|
||||||
|
|
||||||
def show_format(self, item, *args):
|
def show_format(self, item, *args):
|
||||||
fmt = item.ext
|
fmt = item.ext
|
||||||
@ -319,6 +323,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
|
|
||||||
def cover_dropped(self):
|
def cover_dropped(self):
|
||||||
self.cover_changed = True
|
self.cover_changed = True
|
||||||
|
self.cover_data = self.cover.cover_data
|
||||||
|
|
||||||
def initialize_combos(self):
|
def initialize_combos(self):
|
||||||
self.initalize_authors()
|
self.initalize_authors()
|
||||||
@ -430,6 +435,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
self.cover.setPixmap(pix)
|
self.cover.setPixmap(pix)
|
||||||
self.cover_changed = True
|
self.cover_changed = True
|
||||||
self.cpixmap = pix
|
self.cpixmap = pix
|
||||||
|
self.cover_data = self.cover_fetcher.cover_data
|
||||||
finally:
|
finally:
|
||||||
self.fetch_cover_button.setEnabled(True)
|
self.fetch_cover_button.setEnabled(True)
|
||||||
self.unsetCursor()
|
self.unsetCursor()
|
||||||
@ -511,8 +517,8 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
d = self.pubdate.date()
|
d = self.pubdate.date()
|
||||||
self.db.set_pubdate(self.id, datetime(d.year(), d.month(), d.day()))
|
self.db.set_pubdate(self.id, datetime(d.year(), d.month(), d.day()))
|
||||||
|
|
||||||
if self.cover_changed:
|
if self.cover_changed and self.cover_data is not None:
|
||||||
self.db.set_cover(self.id, self.cover.pixmap())
|
self.db.set_cover(self.id, self.cover_data)
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
if callable(self.accepted_callback):
|
if callable(self.accepted_callback):
|
||||||
self.accepted_callback(self.id)
|
self.accepted_callback(self.id)
|
||||||
|
@ -141,6 +141,7 @@ class ImageView(QLabel):
|
|||||||
if not pmap.isNull():
|
if not pmap.isNull():
|
||||||
self.setPixmap(pmap)
|
self.setPixmap(pmap)
|
||||||
event.accept()
|
event.accept()
|
||||||
|
self.cover_data = open(path, 'rb').read()
|
||||||
self.emit(SIGNAL('cover_changed()'), paths, Qt.QueuedConnection)
|
self.emit(SIGNAL('cover_changed()'), paths, Qt.QueuedConnection)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user