moved some functionality from method 'export' to new method (#390)

* moved some functionality from method 'export' to new method
'getSupportedFormats' making it accessible from outside
This commit is contained in:
Karl Georg Bedrich 2020-06-01 20:05:39 +02:00 committed by GitHub
parent 245d89033e
commit 68b8dbac1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,14 +45,19 @@ class ImageExporter(Exporter):
def parameters(self):
return self.params
def export(self, fileName=None, toBytes=False, copy=False):
if fileName is None and not toBytes and not copy:
@staticmethod
def getSupportedImageFormats():
filter = ["*."+f.data().decode('utf-8') for f in QtGui.QImageWriter.supportedImageFormats()]
preferred = ['*.png', '*.tif', '*.jpg']
for p in preferred[::-1]:
if p in filter:
filter.remove(p)
filter.insert(0, p)
return filter
def export(self, fileName=None, toBytes=False, copy=False):
if fileName is None and not toBytes and not copy:
filter = self.getSupportedImageFormats()
self.fileSaveDialog(filter=filter)
return