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 ( |
603 splash.showMessage(self.tr("Initializing Tools...")) |
603 splash.showMessage(self.tr("Initializing Tools...")) |
604 self.toolGroups, self.currentToolGroup = Preferences.readToolGroups() |
604 self.toolGroups, self.currentToolGroup = Preferences.readToolGroups() |
605 self.toolProcs = [] |
605 self.toolProcs = [] |
606 self.__initExternalToolsActions() |
606 self.__initExternalToolsActions() |
607 |
607 |
608 # redirect handling of http and https URLs to ourselves |
608 # redirect handling of http, https and file URLs to ourselves |
609 QDesktopServices.setUrlHandler("file", self.handleUrl) |
609 QDesktopServices.setUrlHandler("file", self.handleUrl) |
610 QDesktopServices.setUrlHandler("http", self.handleUrl) |
610 QDesktopServices.setUrlHandler("http", self.handleUrl) |
611 QDesktopServices.setUrlHandler("https", self.handleUrl) |
611 QDesktopServices.setUrlHandler("https", self.handleUrl) |
612 |
612 |
613 # register all relevant objects |
613 # register all relevant objects |
4041 ).format(sip_version_str) |
4041 ).format(sip_version_str) |
4042 |
4042 |
4043 # webengine (chromium) version |
4043 # webengine (chromium) version |
4044 with contextlib.suppress(ImportError): |
4044 with contextlib.suppress(ImportError): |
4045 from WebBrowser.Tools import WebBrowserTools |
4045 from WebBrowser.Tools import WebBrowserTools |
4046 chromeVersion = WebBrowserTools.getWebEngineVersions()[0] |
4046 chromiumVersion, chromiumSecurityVersion = ( |
|
4047 WebBrowserTools.getWebEngineVersions()[0:2] |
|
4048 ) |
4047 versionText += ( |
4049 versionText += ( |
4048 """<tr><td><b>WebEngine</b></td><td>{0}</td></tr>""" |
4050 """<tr><td><b>WebEngine</b></td><td>{0}</td></tr>""" |
4049 ).format(chromeVersion) |
4051 .format(chromiumVersion) |
|
4052 ) |
|
4053 if chromiumSecurityVersion: |
|
4054 versionText += self.tr( |
|
4055 """<tr><td><b>WebEngine (Security)</b></td>""" |
|
4056 """<td>{0}</td></tr>""" |
|
4057 ).format(chromiumSecurityVersion) |
4050 |
4058 |
4051 # eric7 version |
4059 # eric7 version |
4052 versionText += ("""<tr><td><b>{0}</b></td><td>{1}</td></tr>""" |
4060 versionText += ("""<tr><td><b>{0}</b></td><td>{1}</td></tr>""" |
4053 ).format(Program, Version) |
4061 ).format(Program, Version) |
4054 |
4062 |
6758 EricFileDialog.DontConfirmOverwrite) |
6766 EricFileDialog.DontConfirmOverwrite) |
6759 |
6767 |
6760 if not fn: |
6768 if not fn: |
6761 return |
6769 return |
6762 |
6770 |
6763 ext = QFileInfo(fn).suffix() |
6771 fpath = pathlib.Path(fn) |
6764 if not ext: |
6772 if not fpath.suffix: |
6765 ex = selectedFilter.split("(*")[1].split(")")[0] |
6773 ex = selectedFilter.split("(*")[1].split(")")[0] |
6766 if ex: |
6774 if ex: |
6767 fn += ex |
6775 fpath = fpath.with_suffix(ex) |
6768 |
6776 |
6769 ok = ( |
6777 ok = ( |
6770 EricMessageBox.yesNo( |
6778 EricMessageBox.yesNo( |
6771 self, |
6779 self, |
6772 self.tr("Export Keyboard Shortcuts"), |
6780 self.tr("Export Keyboard Shortcuts"), |
6773 self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists""" |
6781 self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists""" |
6774 """ already. Overwrite it?</p>""").format(fn)) |
6782 """ already. Overwrite it?</p>""").format(fpath)) |
6775 if os.path.exists(fn) else |
6783 if fpath.exists() else |
6776 True |
6784 True |
6777 ) |
6785 ) |
6778 |
6786 |
6779 if ok: |
6787 if ok: |
6780 from Preferences import Shortcuts |
6788 from Preferences import Shortcuts |
6781 Shortcuts.exportShortcuts(fn) |
6789 Shortcuts.exportShortcuts(str(fpath)) |
6782 |
6790 |
6783 def __importShortcuts(self): |
6791 def __importShortcuts(self): |
6784 """ |
6792 """ |
6785 Private slot to import the keyboard shortcuts. |
6793 Private slot to import the keyboard shortcuts. |
6786 """ |
6794 """ |
7061 "") |
7069 "") |
7062 |
7070 |
7063 if not sessionFile: |
7071 if not sessionFile: |
7064 return |
7072 return |
7065 |
7073 |
7066 ext = QFileInfo(sessionFile).suffix() |
7074 fpath = pathlib.Path(sessionFile) |
7067 if not ext: |
7075 if not fpath.suffix: |
7068 ex = selectedFilter.split("(*")[1].split(")")[0] |
7076 ex = selectedFilter.split("(*")[1].split(")")[0] |
7069 if ex: |
7077 if ex: |
7070 sessionFile += ex |
7078 fpath = fpath.with_suffix(ex) |
7071 |
7079 |
7072 self.__writeSession(filename=sessionFile) |
7080 self.__writeSession(filename=str(fpath)) |
7073 |
7081 |
7074 def __loadSessionFromFile(self): |
7082 def __loadSessionFromFile(self): |
7075 """ |
7083 """ |
7076 Private slot to load a session from disk. |
7084 Private slot to load a session from disk. |
7077 """ |
7085 """ |
7475 if event.mimeData().hasUrls(): |
7483 if event.mimeData().hasUrls(): |
7476 event.acceptProposedAction() |
7484 event.acceptProposedAction() |
7477 for url in event.mimeData().urls(): |
7485 for url in event.mimeData().urls(): |
7478 fname = url.toLocalFile() |
7486 fname = url.toLocalFile() |
7479 if fname: |
7487 if fname: |
7480 if QFileInfo(fname).isFile(): |
7488 if pathlib.Path(fname).is_file(): |
7481 self.viewmanager.openSourceFile(fname) |
7489 self.viewmanager.openSourceFile(fname) |
7482 else: |
7490 else: |
7483 EricMessageBox.information( |
7491 EricMessageBox.information( |
7484 self, |
7492 self, |
7485 self.tr("Drop Error"), |
7493 self.tr("Drop Error"), |
7533 if not self.multiProject.closeMultiProject(): |
7541 if not self.multiProject.closeMultiProject(): |
7534 return False |
7542 return False |
7535 |
7543 |
7536 if not self.viewmanager.closeViewManager(): |
7544 if not self.viewmanager.closeViewManager(): |
7537 return False |
7545 return False |
|
7546 |
|
7547 QDesktopServices.unsetUrlHandler("file") |
|
7548 QDesktopServices.unsetUrlHandler("http") |
|
7549 QDesktopServices.unsetUrlHandler("https") |
7538 |
7550 |
7539 if sessionCreated and not self.__disableCrashSession: |
7551 if sessionCreated and not self.__disableCrashSession: |
7540 self.__deleteCrashSession() |
7552 self.__deleteCrashSession() |
7541 |
7553 |
7542 if self.codeDocumentationViewer is not None: |
7554 if self.codeDocumentationViewer is not None: |