eric7/UI/UserInterface.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 9116
698660ef7350
child 9153
506e35e424d5
--- a/eric7/UI/UserInterface.py	Wed Jun 15 09:44:07 2022 +0200
+++ b/eric7/UI/UserInterface.py	Thu Jun 16 18:28:59 2022 +0200
@@ -16,11 +16,11 @@
 import getpass
 import functools
 import contextlib
+import pathlib
 
 from PyQt6.QtCore import (
-    pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate,
-    QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread,
-    QUrlQuery
+    pyqtSlot, QTimer, QFile, pyqtSignal, PYQT_VERSION_STR, QDate, QIODevice,
+    qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread, QUrlQuery
 )
 from PyQt6.QtGui import (
     QAction, QKeySequence, QDesktopServices, QSessionManager
@@ -6760,25 +6760,25 @@
         if not fn:
             return
         
-        ext = QFileInfo(fn).suffix()
-        if not ext:
+        fpath = pathlib.Path(fn)
+        if not fpath.suffix:
             ex = selectedFilter.split("(*")[1].split(")")[0]
             if ex:
-                fn += ex
+                fpath = fpath.with_suffix(ex)
         
         ok = (
             EricMessageBox.yesNo(
                 self,
                 self.tr("Export Keyboard Shortcuts"),
                 self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists"""
-                        """ already. Overwrite it?</p>""").format(fn))
-            if os.path.exists(fn) else
+                        """ already. Overwrite it?</p>""").format(str(fpath)))
+            if fpath.exists() else
             True
         )
         
         if ok:
             from Preferences import Shortcuts
-            Shortcuts.exportShortcuts(fn)
+            Shortcuts.exportShortcuts(str(fpath))
 
     def __importShortcuts(self):
         """
@@ -7063,13 +7063,13 @@
         if not sessionFile:
             return
         
-        ext = QFileInfo(sessionFile).suffix()
-        if not ext:
+        fpath = pathlib.Path(sessionFile)
+        if not fpath.suffix:
             ex = selectedFilter.split("(*")[1].split(")")[0]
             if ex:
-                sessionFile += ex
-        
-        self.__writeSession(filename=sessionFile)
+                fpath = fpath.with_suffix(ex)
+        
+        self.__writeSession(filename=str(fpath))
     
     def __loadSessionFromFile(self):
         """
@@ -7477,7 +7477,7 @@
             for url in event.mimeData().urls():
                 fname = url.toLocalFile()
                 if fname:
-                    if QFileInfo(fname).isFile():
+                    if pathlib.Path(fname).is_file():
                         self.viewmanager.openSourceFile(fname)
                     else:
                         EricMessageBox.information(

eric ide

mercurial