Exemplo n.º 1
0
 def _createEncodingAction(self, codecName, activeCodecName, menu):
     '''
     @param: codecName QString
     @param: activeCodecName QString
     @param: menu QMenu
     '''
     action = QAction(codecName, menu)
     action.setData(codecName)
     action.setCheckable(True)
     action.triggered.connect(self._changeEncoding)
     if activeCodecName.lower() == codecName.lower():
         action.setChecked(True)
     return action
Exemplo n.º 2
0
    def contextMenuEvent(self, event):
        '''
        @param: event QContextMenuEvent
        '''
        if not self._menu:
            self._menu = QMenu(self)

            for idx in range(self.count()):
                act = QAction(self.model().headerData(idx, Qt.Horizontal),
                              self._menu)
                act.setCheckable(True)
                act.setData(idx)

                act.triggered.connect(self._toggleSectionVisibility)
                self._menu.addAction(act)

        for idx, act in enumerate(self._menu.actions()):
            act.setEnabled(idx > 0)
            act.setChecked(not self.isSectionHidden(idx))

        self._menu.popup(event.globalPos())
Exemplo n.º 3
0
    def _aboutToShowTabsMenu(self):
        self._menuTabs.clear()

        for idx in range(self.count()):
            tab = self._weTab(idx)
            if not tab or tab.isPinned():
                continue

            action = QAction(self)
            action.setIcon(tab.icon())

            if idx == self.currentIndex():
                f = action.font()
                f.setBold(True)
                action.setFont(f)

            title = tab.title()
            title.replace('&', '&&')
            action.setText(gVar.appTools.truncatedText(title, 40))

            # TODO: QVariant::fromValue(qobject_cast<QWidget*>(tab)
            action.setData(tab)
            action.triggered.connect(self._actionChangeIndex)
            self._menuTabs.addAction(action)
Exemplo n.º 4
0
    def menuHeros(self,event):
        #====== Menu Move ==========
        print ('context menu event de heros')
        menu_move = QMenu("Move")
        moveNormal = QAction("Normal",None)
        moveNormal.setData(1.0)
        moveNormal.triggered.connect(self.onActionMoveNormal)
        menu_move.addAction(moveNormal)
        moveSlow= QAction("Slow",None)
        moveSlow.setData(0.5)
        moveSlow.triggered.connect(self.onActionMoveNormal)
        menu_move.addAction(moveSlow)
#         moveVerySlow= QAction("Very Slow",None)
#         moveVerySlow.setData(0.25)
#         moveVerySlow.triggered.connect(self.onActionMove)
#        menu_move.addAction(moveVerySlow)
        moveFast= QAction("Fast",None)
        moveFast.setData(2.0)
        moveFast.triggered.connect(self.onActionMoveNormal)
        menu_move.addAction(moveFast)
#         moveVeryFast= QAction("Very Fast",None)
#         moveVeryFast.setData(4.0)
#         moveVeryFast.triggered.connect(self.onActionMove)
#         menu_move.addAction(moveVeryFast)
        actionTeleport= QAction("Teleport",None)
        actionTeleport.setData(0.0)
        actionTeleport.triggered.connect(self.onActionMoveNormal)
        menu_move.addAction(actionTeleport)        
        #========== Menu Actions ========
        menu_actions = QMenu("Action")
        actionAttack= QAction("Attack",None)
        menu_actions.addAction(actionAttack)
        actionHeal= QAction("Soigne",None)
        menu_actions.addAction(actionHeal)        
        
        #======== MENU GENERAL ================
        menu = QMenu()
#         ok = True
#         for w in self.univers.selectedWarriors():
#             for action in self.univers.list_actions.values():
#                 if action.LeftPartContainHeros(w.id):
#                     ok = False
#                     break
#         if ok == True : 
        action_running = False
        for w in self.univers.selectedWarriors():
            if w.attribs['status']!= "repos":
                print ("mmmmmmmmm",w.attribs['status'])
                action_running = True

        if action_running == True :
            actionCancel= QAction("Cancel",None)
            actionCancel.triggered.connect(self.onActionCancel)
            menu.addAction(actionCancel)            
        else:
            menu.addMenu(menu_move)
            menu.addMenu(menu_actions)
            actionPlacement= QAction("Placement",None)
            actionPlacement.triggered.connect(self.onActionPlacement)
            actionPlacement.setData(0.0)  # en placement on teleport forcement
            menu.addAction(actionPlacement)

                

                
        if len(self.univers.selectedWarriors())==1 : 
            if self.univers.selectedWarriors()[0].attribs['HP']== 0:
                actionRebirth= QAction("Rebirth",None)
                menu.addAction(actionRebirth)  
            else:
                actionKill= QAction("Kill",None)
                menu.addAction(actionKill)
                    
        #menu.exec_(event.screenPos())
        #event.accept()
        menu.exec_(event.globalPos())