#coding:utf-8
from PyQt4.QtGui import QMenu
from PyQt4.QtCore import SIGNAL

class CustomMenuWidget(QMenu):  
    def __init__(self,parent=None):
        super(CustomMenuWidget, self).__init__(parent)
        
    def createOnMenu(self):  
        ''''' 
        创建菜单 
        '''  
        OnRunningMenu = QMenu(self)  
        actionShutdown = OnRunningMenu.addAction(u'关机')  
        actionReboot = OnRunningMenu.addAction(u'重启')

        actionShutdown.triggered.connect(self.actionHandlerShutdown)  
        actionReboot.triggered.connect(self.actionHandlerReboot) 

        return OnRunningMenu
    
    def createPoweroffMenu(self):
        OnRunningMenu = QMenu(self)  
        actionShutdown = OnRunningMenu.addAction(u'关机')  
        actionReboot = OnRunningMenu.addAction(u'重启')

        actionShutdown.triggered.connect(self.actionHandlerShutdown)  
        actionReboot.triggered.connect(self.actionHandlerReboot) 
    
    
    def actionHandlerShutdown(self):
        self.emit(SIGNAL("menuAction"),"shutDown")
        
    def actionHandlerStart(self):
        self.emit(SIGNAL("menuAction"),"start")
        
    def actionHandlerReboot(self):
        self.emit(SIGNAL("menuAction"),"reboot")
        
        
    def actionHandlerPowerOff(self):
        self.emit(SIGNAL("menuAction"),"poweroff")
    
  