src/eric7/Preferences/Shortcuts.py

branch
eric7
changeset 9482
a2bc06a54d9d
parent 9473
3f23dbf37dbe
child 9653
e67609152c5e
equal deleted inserted replaced
9481:0b936ff1bbb9 9482:a2bc06a54d9d
12 from PyQt6.QtCore import QCoreApplication, QFile, QIODevice 12 from PyQt6.QtCore import QCoreApplication, QFile, QIODevice
13 from PyQt6.QtGui import QKeySequence 13 from PyQt6.QtGui import QKeySequence
14 14
15 from eric7.EricWidgets import EricMessageBox 15 from eric7.EricWidgets import EricMessageBox
16 from eric7.EricWidgets.EricApplication import ericApp 16 from eric7.EricWidgets.EricApplication import ericApp
17 from eric7.EricXML.ShortcutsReader import ShortcutsReader
17 from eric7.Preferences import Prefs, syncPreferences 18 from eric7.Preferences import Prefs, syncPreferences
19
20 from .ShortcutsFile import ShortcutsFile
18 21
19 22
20 def __readShortcut(act, category, prefClass): 23 def __readShortcut(act, category, prefClass):
21 """ 24 """
22 Private function to read a single keyboard shortcut from the settings. 25 Private function to read a single keyboard shortcut from the settings.
207 """ 210 """
208 # let the plugin manager create on demand plugin objects 211 # let the plugin manager create on demand plugin objects
209 pm = ericApp().getObject("PluginManager") 212 pm = ericApp().getObject("PluginManager")
210 pm.initOnDemandPlugins() 213 pm.initOnDemandPlugins()
211 214
212 from .ShortcutsFile import ShortcutsFile
213
214 shortcutsFile = ShortcutsFile() 215 shortcutsFile = ShortcutsFile()
215 shortcutsFile.writeFile(fn, helpViewer) 216 shortcutsFile.writeFile(fn, helpViewer)
216 217
217 218
218 def importShortcuts(fn, helpViewer=None): 219 def importShortcuts(fn, helpViewer=None):
228 pm = ericApp().getObject("PluginManager") 229 pm = ericApp().getObject("PluginManager")
229 pm.initOnDemandPlugins() 230 pm.initOnDemandPlugins()
230 231
231 if fn.endswith(".ekj"): 232 if fn.endswith(".ekj"):
232 # new JSON based file 233 # new JSON based file
233 from .ShortcutsFile import ShortcutsFile
234
235 shortcutsFile = ShortcutsFile() 234 shortcutsFile = ShortcutsFile()
236 shortcuts = shortcutsFile.readFile(fn) 235 shortcuts = shortcutsFile.readFile(fn)
237 if shortcuts: 236 if shortcuts:
238 setActions(shortcuts, helpViewer=helpViewer) 237 setActions(shortcuts, helpViewer=helpViewer)
239 saveShortcuts() 238 saveShortcuts()
240 syncPreferences() 239 syncPreferences()
241 else: 240 else:
242 # old XML based file 241 # old XML based file
243 f = QFile(fn) 242 f = QFile(fn)
244 if f.open(QIODevice.OpenModeFlag.ReadOnly): 243 if f.open(QIODevice.OpenModeFlag.ReadOnly):
245 from eric7.EricXML.ShortcutsReader import ShortcutsReader
246
247 reader = ShortcutsReader(f) 244 reader = ShortcutsReader(f)
248 reader.readXML() 245 reader.readXML()
249 f.close() 246 f.close()
250 if not reader.hasError(): 247 if not reader.hasError():
251 shortcuts = reader.getShortcuts() 248 shortcuts = reader.getShortcuts()

eric ide

mercurial