Skip to content

Commit

Permalink
Merge pull request #38 from opengisch/fixNoPreviewOnWindows
Browse files Browse the repository at this point in the history
Fix images/documents preview not visible on windws
  • Loading branch information
domi4484 authored Dec 2, 2024
2 parents 9020bb7 + 9c42104 commit 6cc3479
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 6cc3479

Please sign in to comment.