60 |
60 |
61 def __resort(self): |
61 def __resort(self): |
62 """ |
62 """ |
63 Private method to resort the tree. |
63 Private method to resort the tree. |
64 """ |
64 """ |
65 self.shortcutsList.sortItems(self.shortcutsList.sortColumn(), |
65 self.shortcutsList.sortItems( |
|
66 self.shortcutsList.sortColumn(), |
66 self.shortcutsList.header().sortIndicatorOrder()) |
67 self.shortcutsList.header().sortIndicatorOrder()) |
67 |
68 |
68 def __resizeColumns(self): |
69 def __resizeColumns(self): |
69 """ |
70 """ |
70 Private method to resize the list columns. |
71 Private method to resize the list columns. |
94 @keyparam noCheck flag indicating that no uniqueness check should |
95 @keyparam noCheck flag indicating that no uniqueness check should |
95 be performed (boolean) |
96 be performed (boolean) |
96 @keyparam objectType type of the object (string). Objects of the same |
97 @keyparam objectType type of the object (string). Objects of the same |
97 type are not checked for duplicate shortcuts. |
98 type are not checked for duplicate shortcuts. |
98 """ |
99 """ |
99 itm = QTreeWidgetItem(category, |
100 itm = QTreeWidgetItem( |
|
101 category, |
100 [action.iconText(), action.shortcut().toString(), |
102 [action.iconText(), action.shortcut().toString(), |
101 action.alternateShortcut().toString()]) |
103 action.alternateShortcut().toString()]) |
102 itm.setIcon(0, action.icon()) |
104 itm.setIcon(0, action.icon()) |
103 itm.setData(0, self.objectNameRole, action.objectName()) |
105 itm.setData(0, self.objectNameRole, action.objectName()) |
104 itm.setData(0, self.noCheckRole, noCheck) |
106 itm.setData(0, self.noCheckRole, noCheck) |
306 for col in [1, 2]: # check against primary, |
308 for col in [1, 2]: # check against primary, |
307 # then alternative binding |
309 # then alternative binding |
308 itmseq = itm.text(col) |
310 itmseq = itm.text(col) |
309 # step 1: check if shortcut is already allocated |
311 # step 1: check if shortcut is already allocated |
310 if keystr == itmseq: |
312 if keystr == itmseq: |
311 res = E5MessageBox.yesNo(self, |
313 res = E5MessageBox.yesNo( |
|
314 self, |
312 self.trUtf8("Edit shortcuts"), |
315 self.trUtf8("Edit shortcuts"), |
313 self.trUtf8( |
316 self.trUtf8( |
314 """<p><b>{0}</b> has already been""" |
317 """<p><b>{0}</b> has already been""" |
315 """ allocated to the <b>{1}</b> action. """ |
318 """ allocated to the <b>{1}</b> action. """ |
316 """Remove this binding?</p>""") |
319 """Remove this binding?</p>""") |
325 if not itmseq: |
328 if not itmseq: |
326 continue |
329 continue |
327 |
330 |
328 # step 2: check if shortcut hides an already allocated |
331 # step 2: check if shortcut hides an already allocated |
329 if itmseq.startswith("{0}+".format(keystr)): |
332 if itmseq.startswith("{0}+".format(keystr)): |
330 res = E5MessageBox.yesNo(self, |
333 res = E5MessageBox.yesNo( |
|
334 self, |
331 self.trUtf8("Edit shortcuts"), |
335 self.trUtf8("Edit shortcuts"), |
332 self.trUtf8( |
336 self.trUtf8( |
333 """<p><b>{0}</b> hides the <b>{1}</b>""" |
337 """<p><b>{0}</b> hides the <b>{1}</b>""" |
334 """ action. Remove this binding?</p>""") |
338 """ action. Remove this binding?</p>""") |
335 .format(keystr, itm.text(0)), |
339 .format(keystr, itm.text(0)), |
341 return False |
345 return False |
342 |
346 |
343 # step 3: check if shortcut is hidden by an |
347 # step 3: check if shortcut is hidden by an |
344 # already allocated |
348 # already allocated |
345 if keystr.startswith("{0}+".format(itmseq)): |
349 if keystr.startswith("{0}+".format(itmseq)): |
346 res = E5MessageBox.yesNo(self, |
350 res = E5MessageBox.yesNo( |
|
351 self, |
347 self.trUtf8("Edit shortcuts"), |
352 self.trUtf8("Edit shortcuts"), |
348 self.trUtf8( |
353 self.trUtf8( |
349 """<p><b>{0}</b> is hidden by the """ |
354 """<p><b>{0}</b> is hidden by the """ |
350 """<b>{1}</b> action. """ |
355 """<b>{1}</b> action. """ |
351 """Remove this binding?</p>""") |
356 """Remove this binding?</p>""") |
378 |
383 |
379 def on_buttonBox_accepted(self): |
384 def on_buttonBox_accepted(self): |
380 """ |
385 """ |
381 Private slot to handle the OK button press. |
386 Private slot to handle the OK button press. |
382 """ |
387 """ |
383 self.__saveCategoryActions(self.projectItem, |
388 self.__saveCategoryActions( |
|
389 self.projectItem, |
384 e5App().getObject("Project").getActions()) |
390 e5App().getObject("Project").getActions()) |
385 self.__saveCategoryActions(self.uiItem, |
391 self.__saveCategoryActions( |
|
392 self.uiItem, |
386 e5App().getObject("UserInterface").getActions('ui')) |
393 e5App().getObject("UserInterface").getActions('ui')) |
387 self.__saveCategoryActions(self.wizardsItem, |
394 self.__saveCategoryActions( |
|
395 self.wizardsItem, |
388 e5App().getObject("UserInterface").getActions('wizards')) |
396 e5App().getObject("UserInterface").getActions('wizards')) |
389 self.__saveCategoryActions(self.debugItem, |
397 self.__saveCategoryActions( |
|
398 self.debugItem, |
390 e5App().getObject("DebugUI").getActions()) |
399 e5App().getObject("DebugUI").getActions()) |
391 self.__saveCategoryActions(self.editItem, |
400 self.__saveCategoryActions( |
|
401 self.editItem, |
392 e5App().getObject("ViewManager").getActions('edit')) |
402 e5App().getObject("ViewManager").getActions('edit')) |
393 self.__saveCategoryActions(self.fileItem, |
403 self.__saveCategoryActions( |
|
404 self.fileItem, |
394 e5App().getObject("ViewManager").getActions('file')) |
405 e5App().getObject("ViewManager").getActions('file')) |
395 self.__saveCategoryActions(self.searchItem, |
406 self.__saveCategoryActions( |
|
407 self.searchItem, |
396 e5App().getObject("ViewManager").getActions('search')) |
408 e5App().getObject("ViewManager").getActions('search')) |
397 self.__saveCategoryActions(self.viewItem, |
409 self.__saveCategoryActions( |
|
410 self.viewItem, |
398 e5App().getObject("ViewManager").getActions('view')) |
411 e5App().getObject("ViewManager").getActions('view')) |
399 self.__saveCategoryActions(self.macroItem, |
412 self.__saveCategoryActions( |
|
413 self.macroItem, |
400 e5App().getObject("ViewManager").getActions('macro')) |
414 e5App().getObject("ViewManager").getActions('macro')) |
401 self.__saveCategoryActions(self.bookmarkItem, |
415 self.__saveCategoryActions( |
|
416 self.bookmarkItem, |
402 e5App().getObject("ViewManager").getActions('bookmark')) |
417 e5App().getObject("ViewManager").getActions('bookmark')) |
403 self.__saveCategoryActions(self.spellingItem, |
418 self.__saveCategoryActions( |
|
419 self.spellingItem, |
404 e5App().getObject("ViewManager").getActions('spelling')) |
420 e5App().getObject("ViewManager").getActions('spelling')) |
405 |
421 |
406 actions = e5App().getObject("ViewManager").getActions('window') |
422 actions = e5App().getObject("ViewManager").getActions('window') |
407 if actions: |
423 if actions: |
408 self.__saveCategoryActions(self.windowItem, actions) |
424 self.__saveCategoryActions(self.windowItem, actions) |
411 category = categoryItem.text(0) |
427 category = categoryItem.text(0) |
412 ref = e5App().getPluginObject(category) |
428 ref = e5App().getPluginObject(category) |
413 if ref is not None and hasattr(ref, "getActions"): |
429 if ref is not None and hasattr(ref, "getActions"): |
414 self.__saveCategoryActions(categoryItem, ref.getActions()) |
430 self.__saveCategoryActions(categoryItem, ref.getActions()) |
415 |
431 |
416 self.__saveCategoryActions(self.helpViewerItem, |
432 self.__saveCategoryActions( |
|
433 self.helpViewerItem, |
417 e5App().getObject("DummyHelpViewer").getActions()) |
434 e5App().getObject("DummyHelpViewer").getActions()) |
418 |
435 |
419 Shortcuts.saveShortcuts() |
436 Shortcuts.saveShortcuts() |
420 Preferences.syncPreferences() |
437 Preferences.syncPreferences() |
421 |
438 |