9 |
9 |
10 import os |
10 import os |
11 import shutil |
11 import shutil |
12 import functools |
12 import functools |
13 import contextlib |
13 import contextlib |
|
14 import pathlib |
14 |
15 |
15 from PyQt6.QtCore import ( |
16 from PyQt6.QtCore import ( |
16 pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, QUrl, QProcess, |
17 pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, QUrl, QProcess, |
17 QEvent, QFileInfo |
18 QEvent |
18 ) |
19 ) |
19 from PyQt6.QtGui import ( |
20 from PyQt6.QtGui import ( |
20 QDesktopServices, QKeySequence, QAction, QFont, QFontMetrics |
21 QDesktopServices, QKeySequence, QAction, QFont, QFontMetrics |
21 ) |
22 ) |
22 from PyQt6.QtWidgets import ( |
23 from PyQt6.QtWidgets import ( |
5046 EricFileDialog.DontConfirmOverwrite) |
5047 EricFileDialog.DontConfirmOverwrite) |
5047 |
5048 |
5048 if not fn: |
5049 if not fn: |
5049 return |
5050 return |
5050 |
5051 |
5051 ext = QFileInfo(fn).suffix() |
5052 fpath = pathlib.Path(fn) |
5052 if not ext: |
5053 if not fpath.suffix: |
5053 ex = selectedFilter.split("(*")[1].split(")")[0] |
5054 ex = selectedFilter.split("(*")[1].split(")")[0] |
5054 if ex: |
5055 if ex: |
5055 fn += ex |
5056 fpath = fpath.with_suffix(ex) |
5056 |
5057 |
5057 ok = ( |
5058 ok = ( |
5058 EricMessageBox.yesNo( |
5059 EricMessageBox.yesNo( |
5059 self, |
5060 self, |
5060 self.tr("Export Keyboard Shortcuts"), |
5061 self.tr("Export Keyboard Shortcuts"), |
5061 self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists""" |
5062 self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists""" |
5062 """ already. Overwrite it?</p>""").format(fn)) |
5063 """ already. Overwrite it?</p>""").format(fpath)) |
5063 if os.path.exists(fn) else |
5064 if fpath.exists() else |
5064 True |
5065 True |
5065 ) |
5066 ) |
5066 |
5067 |
5067 if ok: |
5068 if ok: |
5068 from Preferences import Shortcuts |
5069 from Preferences import Shortcuts |