Skip to content

Commit

Permalink
Fix images/documents preview not visible on windws
Browse files Browse the repository at this point in the history
This seemms the case with some QGIS version (maybe something to do with
Qt version)
  • Loading branch information
domi4484 committed Dec 2, 2024
1 parent 11d4c4b commit 9c42104
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions document_management_system/core/preview_image_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,20 @@

class PreviewImageProvider(QQuickImageProvider):

mime_database = QMimeDatabase()

def __init__(self):
super().__init__(QQuickImageProvider.Image)

# use an image reader to ensure image orientation and transforms are correctly handled
self._imageReader = QImageReader()
self._imageReader.setAutoTransform(True)

print("supportedMimeTypes {}".format(self._imageReader.supportedMimeTypes()))

def requestImage(self, id, size):
self._imageReader.setFileName(id)
image = self._imageReader.read()
return image, image.size()

@staticmethod
def isMimeTypeSupported(filePath):
mime_type_name = str()
for mime_type in PreviewImageProvider.mime_database.mimeTypesForFileName(filePath):
if mime_type:
mime_type_name = mime_type.name()
break

return mime_type_name in QImageReader().supportedMimeTypes()
imageReader = QImageReader()
imageReader.setFileName(filePath)
return imageReader.canRead()

0 comments on commit 9c42104

Please sign in to comment.