from PyQt4.Qt import QObject
from model.cfg.storeinfoparser import StoreInfoParser
import os

class PersonalizedSet(QObject):
    def __init__(self):
        super(PersonalizedSet, self).__init__()

    def ctrlResolutionAutoAdjust(self,action):
        if(action == "open"):
            s = "ON"
            n=os.environ["SMEP_SEND_MONITOR_CONFIG"]="ON"
            # print "smep_send_monitor_config ON"
            StoreInfoParser.instance().setAutoAdjust(s)
            return 0
        elif(action == "close"):
            s = "OFF"
            # print "smep_send_monitor_config OFF"
            n=os.environ["SMEP_SEND_MONITOR_CONFIG"]="OFF"
            StoreInfoParser.instance().setAutoAdjust(s)
            return 0
    
    def updateVmScreenState(self):
        retv=StoreInfoParser.instance().getAutoVmScreenState()
        return retv

    def setVmScreenState(self,stateV):
        StoreInfoParser.instance().setAutoVmScreenState(stateV)

    def getResolutionAutoAdjustType(self):
        current_text = StoreInfoParser.instance().getAutoAdjust()
        if (current_text == "ON"):
            return "open"
        elif(current_text == "OFF"):
            return "close"
        else:
            return ""