269 QApplication.translate("Shortcuts", "Import Keyboard Shortcuts"), |
269 QApplication.translate("Shortcuts", "Import Keyboard Shortcuts"), |
270 QApplication.translate("Shortcuts", |
270 QApplication.translate("Shortcuts", |
271 """Compressed keyboard shortcut files""" |
271 """Compressed keyboard shortcut files""" |
272 """ not supported. The compression library is missing.""")) |
272 """ not supported. The compression library is missing.""")) |
273 return False |
273 return False |
274 f = gzip.open(fn, "rb") |
274 f = gzip.open(fn, "r") |
275 else: |
275 else: |
276 f = open(fn, "rb") |
276 f = open(fn, "r") |
277 try: |
277 try: |
278 try: |
278 try: |
279 parser.parse(f) |
279 parser.parse(f) |
280 except UnicodeEncodeError: |
280 except UnicodeEncodeError: |
281 f.seek(0) |
281 f.seek(0) |
282 buf = cStringIO.StringIO(f.read()) |
282 buf = io.StringIO(f.read()) |
283 parser.parse(buf) |
283 parser.parse(buf) |
284 finally: |
284 finally: |
285 f.close() |
285 f.close() |
286 except IOError: |
286 except IOError: |
287 QMessageBox.critical(None, |
287 QMessageBox.critical(None, |
332 Module function to set actions based on new format shortcuts file. |
332 Module function to set actions based on new format shortcuts file. |
333 |
333 |
334 @param shortcuts dictionary containing the accelerator information |
334 @param shortcuts dictionary containing the accelerator information |
335 read from a XML file |
335 read from a XML file |
336 """ |
336 """ |
337 if shortcuts.has_key("Project"): |
337 if "Project" in shortcuts: |
338 __setAction(e4App().getObject("Project").getActions(), |
338 __setAction(e4App().getObject("Project").getActions(), |
339 shortcuts["Project"]) |
339 shortcuts["Project"]) |
340 |
340 |
341 if shortcuts.has_key("General"): |
341 if "General" in shortcuts: |
342 __setAction(e4App().getObject("UserInterface").getActions('ui'), |
342 __setAction(e4App().getObject("UserInterface").getActions('ui'), |
343 shortcuts["General"]) |
343 shortcuts["General"]) |
344 |
344 |
345 if shortcuts.has_key("Wizards"): |
345 if "Wizards" in shortcuts: |
346 __setAction(e4App().getObject("UserInterface").getActions('wizards'), |
346 __setAction(e4App().getObject("UserInterface").getActions('wizards'), |
347 shortcuts["Wizards"]) |
347 shortcuts["Wizards"]) |
348 |
348 |
349 if shortcuts.has_key("Debug"): |
349 if "Debug" in shortcuts: |
350 __setAction(e4App().getObject("DebugUI").getActions(), |
350 __setAction(e4App().getObject("DebugUI").getActions(), |
351 shortcuts["Debug"]) |
351 shortcuts["Debug"]) |
352 |
352 |
353 if shortcuts.has_key("Edit"): |
353 if "Edit" in shortcuts: |
354 __setAction(e4App().getObject("ViewManager").getActions('edit'), |
354 __setAction(e4App().getObject("ViewManager").getActions('edit'), |
355 shortcuts["Edit"]) |
355 shortcuts["Edit"]) |
356 |
356 |
357 if shortcuts.has_key("File"): |
357 if "File" in shortcuts: |
358 __setAction(e4App().getObject("ViewManager").getActions('file'), |
358 __setAction(e4App().getObject("ViewManager").getActions('file'), |
359 shortcuts["File"]) |
359 shortcuts["File"]) |
360 |
360 |
361 if shortcuts.has_key("Search"): |
361 if "Search" in shortcuts: |
362 __setAction(e4App().getObject("ViewManager").getActions('search'), |
362 __setAction(e4App().getObject("ViewManager").getActions('search'), |
363 shortcuts["Search"]) |
363 shortcuts["Search"]) |
364 |
364 |
365 if shortcuts.has_key("View"): |
365 if "View" in shortcuts: |
366 __setAction(e4App().getObject("ViewManager").getActions('view'), |
366 __setAction(e4App().getObject("ViewManager").getActions('view'), |
367 shortcuts["View"]) |
367 shortcuts["View"]) |
368 |
368 |
369 if shortcuts.has_key("Macro"): |
369 if "Macro" in shortcuts: |
370 __setAction(e4App().getObject("ViewManager").getActions('macro'), |
370 __setAction(e4App().getObject("ViewManager").getActions('macro'), |
371 shortcuts["Macro"]) |
371 shortcuts["Macro"]) |
372 |
372 |
373 if shortcuts.has_key("Bookmarks"): |
373 if "Bookmarks" in shortcuts: |
374 __setAction(e4App().getObject("ViewManager").getActions('bookmark'), |
374 __setAction(e4App().getObject("ViewManager").getActions('bookmark'), |
375 shortcuts["Bookmarks"]) |
375 shortcuts["Bookmarks"]) |
376 |
376 |
377 if shortcuts.has_key("Spelling"): |
377 if "Spelling" in shortcuts: |
378 __setAction(e4App().getObject("ViewManager").getActions('spelling'), |
378 __setAction(e4App().getObject("ViewManager").getActions('spelling'), |
379 shortcuts["Spelling"]) |
379 shortcuts["Spelling"]) |
380 |
380 |
381 if shortcuts.has_key("Window"): |
381 if "Window" in shortcuts: |
382 actions = e4App().getObject("ViewManager").getActions('window') |
382 actions = e4App().getObject("ViewManager").getActions('window') |
383 if actions: |
383 if actions: |
384 __setAction(actions, shortcuts["Window"]) |
384 __setAction(actions, shortcuts["Window"]) |
385 |
385 |
386 for category, ref in e4App().getPluginObjects(): |
386 for category, ref in e4App().getPluginObjects(): |
387 if shortcuts.has_key(category) and hasattr(ref, "getActions"): |
387 if category in shortcuts and hasattr(ref, "getActions"): |
388 actions = ref.getActions() |
388 actions = ref.getActions() |
389 __setAction(actions, shortcuts[category]) |
389 __setAction(actions, shortcuts[category]) |
390 |
390 |
391 if shortcuts.has_key("HelpViewer"): |
391 if "HelpViewer" in shortcuts: |
392 __setAction(e4App().getObject("DummyHelpViewer").getActions(), |
392 __setAction(e4App().getObject("DummyHelpViewer").getActions(), |
393 shortcuts["HelpViewer"]) |
393 shortcuts["HelpViewer"]) |