eric7/Snapshot/SnapWidget.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8881
54e42bc2437a
child 9162
8b75b1668583
--- a/eric7/Snapshot/SnapWidget.py	Wed Jun 15 09:44:07 2022 +0200
+++ b/eric7/Snapshot/SnapWidget.py	Thu Jun 16 18:28:59 2022 +0200
@@ -12,12 +12,13 @@
 #
 
 import os
+import pathlib
 import re
 import contextlib
 
 from PyQt6.QtCore import (
-    pyqtSlot, Qt, QFile, QFileInfo, QTimer, QPoint, QMimeData, QLocale,
-    QStandardPaths, QIODevice
+    pyqtSlot, Qt, QFile, QTimer, QPoint, QMimeData, QLocale, QStandardPaths,
+    QIODevice
 )
 from PyQt6.QtGui import QImageWriter, QPixmap, QDrag, QKeySequence, QShortcut
 from PyQt6.QtWidgets import QWidget, QApplication
@@ -210,15 +211,15 @@
             if not fileName:
                 return
             
-            ext = QFileInfo(fileName).suffix()
-            if not ext:
+            fpath = pathlib.Path(fileName)
+            if not fpath.suffix:
                 ex = selectedFilter.split("(*")[1].split(")")[0]
                 if ex:
-                    fileName += ex
+                    fpath = fpath.with_suffix(ex)
             
-            if self.__saveImage(fileName):
+            if self.__saveImage(str(fpath)):
                 self.__modified = False
-                self.__filename = fileName
+                self.__filename = str(fpath)
                 self.__autoIncFilename()
                 self.__updateCaption()
     
@@ -229,7 +230,7 @@
         @param fileName name of the file to save to (string)
         @return flag indicating success (boolean)
         """
-        if QFileInfo(fileName).exists():
+        if pathlib.Path(fileName).exists():
             res = EricMessageBox.yesNo(
                 self,
                 self.tr("Save Snapshot"),

eric ide

mercurial