UI/UserInterface.py

changeset 4117
40d4272b538a
parent 4113
feac3108a780
child 4137
54c38749f153
equal deleted inserted replaced
4116:2b39247e9cae 4117:40d4272b538a
3436 """ 3436 """
3437 Private slot to display the Window menu of the Window menu. 3437 Private slot to display the Window menu of the Window menu.
3438 """ 3438 """
3439 self.showMenu.emit("Subwindows", self.__menus["subwindow"]) 3439 self.showMenu.emit("Subwindows", self.__menus["subwindow"])
3440 3440
3441 def __showToolbarsMenu(self): 3441 def __populateToolbarsMenu(self, menu):
3442 """ 3442 """
3443 Private slot to display the Toolbars menu. 3443 Private method to populate a toolbars menu.
3444 """ 3444
3445 self.__menus["toolbars"].clear() 3445 @param menu reference to the menu to be populated (QMenu)
3446 """
3447 menu.clear()
3446 3448
3447 tbList = [] 3449 tbList = []
3448 for name, (text, tb) in list(self.__toolbars.items()): 3450 for name, (text, tb) in list(self.__toolbars.items()):
3449 tbList.append((text, tb, name)) 3451 tbList.append((text, tb, name))
3450 3452
3451 tbList.sort() 3453 for text, tb, name in sorted(tbList):
3452 for text, tb, name in tbList: 3454 act = menu.addAction(text)
3453 act = self.__menus["toolbars"].addAction(text)
3454 act.setCheckable(True) 3455 act.setCheckable(True)
3456 act.setChecked(not tb.isHidden())
3455 act.setData(name) 3457 act.setData(name)
3456 act.setChecked(not tb.isHidden()) 3458 menu.addSeparator()
3457 self.__menus["toolbars"].addSeparator() 3459 act = menu.addAction(self.tr("&Show all"))
3458 self.__toolbarsShowAllAct = \ 3460 act.setData("__SHOW__")
3459 self.__menus["toolbars"].addAction(self.tr("&Show all")) 3461 act = menu.addAction(self.tr("&Hide all"))
3460 self.__toolbarsHideAllAct = \ 3462 act.setData("__HIDE__")
3461 self.__menus["toolbars"].addAction(self.tr("&Hide all")) 3463
3464 def createPopupMenu(self):
3465 """
3466 Public method to create the toolbars menu for Qt.
3467
3468 @return toolbars menu (QMenu)
3469 """
3470 menu = QMenu(self)
3471 menu.triggered.connect(self.__TBPopupMenuTriggered)
3472
3473 self.__populateToolbarsMenu(menu)
3474
3475 return menu
3476
3477 def __showToolbarsMenu(self):
3478 """
3479 Private slot to display the Toolbars menu.
3480 """
3481 self.__populateToolbarsMenu(self.__menus["toolbars"])
3462 3482
3463 def __TBMenuTriggered(self, act): 3483 def __TBMenuTriggered(self, act):
3464 """ 3484 """
3465 Private method to handle the toggle of a toolbar. 3485 Private method to handle the toggle of a toolbar via the Window->
3486 Toolbars submenu.
3466 3487
3467 @param act reference to the action that was triggered (QAction) 3488 @param act reference to the action that was triggered (QAction)
3468 """ 3489 """
3469 if act == self.__toolbarsShowAllAct: 3490 name = act.data()
3470 for text, tb in list(self.__toolbars.values()): 3491 if name:
3471 tb.show() 3492 if name == "__SHOW__":
3472 if self.__menus["toolbars"].isTearOffMenuVisible(): 3493 for text, tb in list(self.__toolbars.values()):
3473 self.__showToolbarsMenu() 3494 tb.show()
3474 elif act == self.__toolbarsHideAllAct: 3495 if self.__menus["toolbars"].isTearOffMenuVisible():
3475 for text, tb in list(self.__toolbars.values()): 3496 self.__menus["toolbars"].hideTearOffMenu()
3476 tb.hide() 3497 elif name == "__HIDE__":
3477 if self.__menus["toolbars"].isTearOffMenuVisible(): 3498 for text, tb in list(self.__toolbars.values()):
3478 self.__showToolbarsMenu() 3499 tb.hide()
3479 else: 3500 if self.__menus["toolbars"].isTearOffMenuVisible():
3480 name = act.data() 3501 self.__menus["toolbars"].hideTearOffMenu()
3481 if name: 3502 else:
3482 tb = self.__toolbars[name][1] 3503 tb = self.__toolbars[name][1]
3483 if act.isChecked(): 3504 if act.isChecked():
3484 tb.show() 3505 tb.show()
3485 else: 3506 else:
3486 tb.hide() 3507 tb.hide()
3508
3509 def __TBPopupMenuTriggered(self, act):
3510 """
3511 Private method to handle the toggle of a toolbar via the QMainWindow
3512 Toolbars popup menu.
3513
3514 @param act reference to the action that was triggered (QAction)
3515 """
3516 name = act.data()
3517 if name:
3518 if name == "__SHOW__":
3519 for text, tb in list(self.__toolbars.values()):
3520 tb.show()
3521 elif name == "__HIDE__":
3522 for text, tb in list(self.__toolbars.values()):
3523 tb.hide()
3524 else:
3525 tb = self.__toolbars[name][1]
3526 if act.isChecked():
3527 tb.show()
3528 else:
3529 tb.hide()
3530 if self.__menus["toolbars"].isTearOffMenuVisible():
3531 self.__menus["toolbars"].hideTearOffMenu()
3487 3532
3488 def __saveCurrentViewProfile(self, save): 3533 def __saveCurrentViewProfile(self, save):
3489 """ 3534 """
3490 Private slot to save the window geometries of the active profile. 3535 Private slot to save the window geometries of the active profile.
3491 3536

eric ide

mercurial