eric7/UI/UserInterface.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 9116
698660ef7350
child 9153
506e35e424d5
equal deleted inserted replaced
9151:8c5296fe3056 9152:8a68afaf1ba2
14 import json 14 import json
15 import datetime 15 import datetime
16 import getpass 16 import getpass
17 import functools 17 import functools
18 import contextlib 18 import contextlib
19 import pathlib
19 20
20 from PyQt6.QtCore import ( 21 from PyQt6.QtCore import (
21 pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, 22 pyqtSlot, QTimer, QFile, pyqtSignal, PYQT_VERSION_STR, QDate, QIODevice,
22 QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread, 23 qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread, QUrlQuery
23 QUrlQuery
24 ) 24 )
25 from PyQt6.QtGui import ( 25 from PyQt6.QtGui import (
26 QAction, QKeySequence, QDesktopServices, QSessionManager 26 QAction, QKeySequence, QDesktopServices, QSessionManager
27 ) 27 )
28 from PyQt6.QtWidgets import ( 28 from PyQt6.QtWidgets import (
6758 EricFileDialog.DontConfirmOverwrite) 6758 EricFileDialog.DontConfirmOverwrite)
6759 6759
6760 if not fn: 6760 if not fn:
6761 return 6761 return
6762 6762
6763 ext = QFileInfo(fn).suffix() 6763 fpath = pathlib.Path(fn)
6764 if not ext: 6764 if not fpath.suffix:
6765 ex = selectedFilter.split("(*")[1].split(")")[0] 6765 ex = selectedFilter.split("(*")[1].split(")")[0]
6766 if ex: 6766 if ex:
6767 fn += ex 6767 fpath = fpath.with_suffix(ex)
6768 6768
6769 ok = ( 6769 ok = (
6770 EricMessageBox.yesNo( 6770 EricMessageBox.yesNo(
6771 self, 6771 self,
6772 self.tr("Export Keyboard Shortcuts"), 6772 self.tr("Export Keyboard Shortcuts"),
6773 self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists""" 6773 self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists"""
6774 """ already. Overwrite it?</p>""").format(fn)) 6774 """ already. Overwrite it?</p>""").format(str(fpath)))
6775 if os.path.exists(fn) else 6775 if fpath.exists() else
6776 True 6776 True
6777 ) 6777 )
6778 6778
6779 if ok: 6779 if ok:
6780 from Preferences import Shortcuts 6780 from Preferences import Shortcuts
6781 Shortcuts.exportShortcuts(fn) 6781 Shortcuts.exportShortcuts(str(fpath))
6782 6782
6783 def __importShortcuts(self): 6783 def __importShortcuts(self):
6784 """ 6784 """
6785 Private slot to import the keyboard shortcuts. 6785 Private slot to import the keyboard shortcuts.
6786 """ 6786 """
7061 "") 7061 "")
7062 7062
7063 if not sessionFile: 7063 if not sessionFile:
7064 return 7064 return
7065 7065
7066 ext = QFileInfo(sessionFile).suffix() 7066 fpath = pathlib.Path(sessionFile)
7067 if not ext: 7067 if not fpath.suffix:
7068 ex = selectedFilter.split("(*")[1].split(")")[0] 7068 ex = selectedFilter.split("(*")[1].split(")")[0]
7069 if ex: 7069 if ex:
7070 sessionFile += ex 7070 fpath = fpath.with_suffix(ex)
7071 7071
7072 self.__writeSession(filename=sessionFile) 7072 self.__writeSession(filename=str(fpath))
7073 7073
7074 def __loadSessionFromFile(self): 7074 def __loadSessionFromFile(self):
7075 """ 7075 """
7076 Private slot to load a session from disk. 7076 Private slot to load a session from disk.
7077 """ 7077 """
7475 if event.mimeData().hasUrls(): 7475 if event.mimeData().hasUrls():
7476 event.acceptProposedAction() 7476 event.acceptProposedAction()
7477 for url in event.mimeData().urls(): 7477 for url in event.mimeData().urls():
7478 fname = url.toLocalFile() 7478 fname = url.toLocalFile()
7479 if fname: 7479 if fname:
7480 if QFileInfo(fname).isFile(): 7480 if pathlib.Path(fname).is_file():
7481 self.viewmanager.openSourceFile(fname) 7481 self.viewmanager.openSourceFile(fname)
7482 else: 7482 else:
7483 EricMessageBox.information( 7483 EricMessageBox.information(
7484 self, 7484 self,
7485 self.tr("Drop Error"), 7485 self.tr("Drop Error"),

eric ide

mercurial