#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)  
    
        self.actionShutdown = self.addAction(u'关机')  
        self.actionReboot = self.addAction(u'重启')
 
        self.actionShutdown.triggered.connect(self.actionHandlerShutdown)  
        self.actionReboot.triggered.connect(self.actionHandlerReboot) 
        
    
    def setActionStatus(self, status):
        self.setShutDownActionStatus(status)
        self.setRebootActionStatus(status)
        
    def setRebootActionStatus(self, status):
        self.actionReboot.setEnabled(status)
        
    def setShutDownActionStatus(self, status):
        self.actionShutdown.setEnabled(status)
    
    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")
    
  