eric7/Preferences/Shortcuts.py

branch
eric7
changeset 8351
7d13e08ddb3f
parent 8318
962bce857696
child 8356
68ec9c3d4de5
equal deleted inserted replaced
8350:74a3b2a6a944 8351:7d13e08ddb3f
206 """ 206 """
207 # let the plugin manager create on demand plugin objects 207 # let the plugin manager create on demand plugin objects
208 pm = e5App().getObject("PluginManager") 208 pm = e5App().getObject("PluginManager")
209 pm.initOnDemandPlugins() 209 pm.initOnDemandPlugins()
210 210
211 if fn.endswith(".ekj"): 211 from .ShortcutsFile import ShortcutsFile
212 # new JSON based file 212 shortcutsFile = ShortcutsFile()
213 from .ShortcutsFile import ShortcutsFile 213 shortcutsFile.writeFile(fn, helpViewer)
214 shortcutsFile = ShortcutsFile()
215 shortcutsFile.writeFile(fn, helpViewer)
216 else:
217 # old XML based file
218 f = QFile(fn)
219 if f.open(QIODevice.OpenModeFlag.WriteOnly):
220 from E5XML.ShortcutsWriter import ShortcutsWriter
221 ShortcutsWriter(f).writeXML(helpViewer=helpViewer)
222 f.close()
223 else:
224 E5MessageBox.critical(
225 None,
226 QCoreApplication.translate(
227 "Shortcuts", "Export Keyboard Shortcuts"),
228 QCoreApplication.translate(
229 "Shortcuts",
230 "<p>The keyboard shortcuts file <b>{0}</b> could not"
231 " be written.</p>")
232 .format(fn))
233 214
234 215
235 def importShortcuts(fn, helpViewer=None): 216 def importShortcuts(fn, helpViewer=None):
236 """ 217 """
237 Module function to import the keyboard shortcuts for the defined actions. 218 Module function to import the keyboard shortcuts for the defined actions.
256 syncPreferences() 237 syncPreferences()
257 else: 238 else:
258 # old XML based file 239 # old XML based file
259 f = QFile(fn) 240 f = QFile(fn)
260 if f.open(QIODevice.OpenModeFlag.ReadOnly): 241 if f.open(QIODevice.OpenModeFlag.ReadOnly):
261 from E5XML.ShortcutsReader import ShortcutsReader 242 from EricXML.ShortcutsReader import ShortcutsReader
262 reader = ShortcutsReader(f) 243 reader = ShortcutsReader(f)
263 reader.readXML() 244 reader.readXML()
264 f.close() 245 f.close()
265 if not reader.hasError(): 246 if not reader.hasError():
266 shortcuts = reader.getShortcuts() 247 shortcuts = reader.getShortcuts()

eric ide

mercurial