eric7/IconEditor/IconEditorWindow.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8881
54e42bc2437a
child 9153
506e35e424d5
diff -r 8c5296fe3056 -r 8a68afaf1ba2 eric7/IconEditor/IconEditorWindow.py
--- a/eric7/IconEditor/IconEditorWindow.py	Wed Jun 15 09:44:07 2022 +0200
+++ b/eric7/IconEditor/IconEditorWindow.py	Thu Jun 16 18:28:59 2022 +0200
@@ -9,9 +9,10 @@
 
 import os
 import contextlib
+import pathlib
 
 from PyQt6.QtCore import (
-    pyqtSignal, Qt, QSize, QSignalMapper, QFileInfo, QFile, QEvent, QIODevice
+    pyqtSignal, Qt, QSize, QSignalMapper, QFile, QEvent, QIODevice
 )
 from PyQt6.QtGui import (
     QPalette, QImage, QImageReader, QImageWriter, QKeySequence
@@ -1109,24 +1110,24 @@
         if not fileName:
             return False
         
-        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
-        if QFileInfo(fileName).exists():
+                fpath = fpath.with_suffix(ex)
+        if fpath.exists():
             res = EricMessageBox.yesNo(
                 self,
                 self.tr("Save icon file"),
                 self.tr("<p>The file <b>{0}</b> already exists."
-                        " Overwrite it?</p>").format(fileName),
+                        " Overwrite it?</p>").format(str(fpath)),
                 icon=EricMessageBox.Warning)
             if not res:
                 return False
         
-        self.__lastSavePath = os.path.dirname(fileName)
+        self.__lastSavePath = fpath.parent
         
-        return self.__saveIconFile(fileName)
+        return self.__saveIconFile(str(fpath))
     
     def __closeAll(self):
         """
@@ -1236,7 +1237,7 @@
         @param fullFileName full pathname of the given file (string)
         @return filename part (string)
         """
-        return QFileInfo(fullFileName).fileName()
+        return pathlib.Path(fullFileName).name
     
     def __maybeSave(self):
         """

eric ide

mercurial