eric7/Tools/UIPreviewer.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8881
54e42bc2437a
child 9153
506e35e424d5
--- a/eric7/Tools/UIPreviewer.py	Wed Jun 15 09:44:07 2022 +0200
+++ b/eric7/Tools/UIPreviewer.py	Thu Jun 16 18:28:59 2022 +0200
@@ -8,8 +8,9 @@
 """
 
 import contextlib
+import pathlib
 
-from PyQt6.QtCore import QDir, QFileInfo, QEvent, QSize, Qt
+from PyQt6.QtCore import QDir, QEvent, QSize, Qt
 from PyQt6.QtGui import QAction, QKeySequence, QImageWriter, QPainter
 from PyQt6.QtWidgets import (
     QSizePolicy, QSpacerItem, QWidget, QHBoxLayout, QWhatsThis, QDialog,
@@ -469,21 +470,22 @@
             fileFilter)
         if not fname:
             return
-            
-        ext = QFileInfo(fname).suffix().upper()
+        
+        fpath = pathlib.Path(fname)
+        ext = fpath.suffix.upper().replace(".", "")
         if not ext:
             ext = defaultExt
-            fname.append(".{0}".format(defaultExt.lower()))
+            fpath = fpath.with_suffix(".{0}".format(defaultExt.lower()))
         
         pix = self.mainWidget.grab()
         self.__updateChildren(self.lastStyle)
-        if not pix.save(fname, str(ext)):
+        if not pix.save(str(fpath), str(ext)):
             EricMessageBox.critical(
                 self,
                 self.tr("Save Image"),
                 self.tr(
                     """<p>The file <b>{0}</b> could not be saved.</p>""")
-                .format(fname))
+                .format(str(fpath)))
 
     def __copyImageToClipboard(self):
         """

eric ide

mercurial