#coding:utf-8

"""create by pbc on 2016.05.26 for ...
"""

from PyQt4.QtGui import QWidget,QMenu, QIcon
from PyQt4.QtCore import SIGNAL, QString


class ButtonMenu(QWidget):
    def __init__(self,parent=None):
        super(ButtonMenu, self).__init__(parent)
        from os import getenv
        self.__borderImagesPath = getenv('WIN_UI_IMAGES_PATH')
        self.createContextMenu() 
        self.setStyleSheet(
                            "QMenu::item{padding:0px 0px 0px 5px;}"
                            "QMenu::item{height:25px;}"
                            "QMenu::item{width:90px;}"
                            "QMenu::item{background:white;}"
                            "QMenu::item{margin:1px 0px 0px 0px;}"
                            "QMenu::item:selected:enabled{background:lightgray;}"
                            "QMenu::item:selected:enabled{color:white;}"
                            "QMenu::item:selected:!enabled{background:transparent;}"
                            )

    def createContextMenu(self):
        self.contextMenu = QMenu(self)
        self.actionB = self.contextMenu.addAction(QIcon(QString("%1/loginWindow/login/setting_pre_hov.png").arg(self.__borderImagesPath)),u'分享桌面')
        self.actionD = self.contextMenu.addAction(u'关机')
        self.actionE = self.contextMenu.addAction(u'断电')

        self.actionB.triggered.connect(self.actionHandlerShare)  
        self.actionD.triggered.connect(self.actionHandlerPoweroff)  
        self.actionE.triggered.connect(self.actionHandlerShutdown)

    def actionHandlerShare(self):#分享云桌面
        self.emit(SIGNAL("fromthemenu"),"shareonline")
    def actionHandlerShutdown(self):
        self.emit(SIGNAL("fromthemenu"),"stop")
    def actionHandlerPoweroff(self):
        self.emit(SIGNAL("fromthemenu"),"shutdown")

