#coding=utf-8
from PyQt4.QtCore import Qt,QString,SIGNAL
from PyQt4.Qt import QPalette,QColor, QDialog,QIcon
from view.setting.settingview import Ui_Form

import controller.setting.centerset
import controller.setting.domainsettings
import controller.setting.personalizedsetting
 
class Setting(QDialog,Ui_Form):
    def __init__(self):
        super(Setting,self).__init__()
        self.setupUi(self)
        flags = Qt.FramelessWindowHint
        self.setWindowFlags(flags)
        windowIconPath="../images/logo32.png"
        self.setWindowIcon(QIcon(windowIconPath))#设置windows窗口图标
        self.frame.setStyleSheet(QString("QWidget#frame{border-image: url(../images/setop.png);}"))
        self.frame.setAttribute(Qt.WA_TransparentForMouseEvents)
        _centerSetC = controller.setting.centerset.CenterSet()
        _domainSettingsC=controller.setting.domainsettings.DomainSettings()
        _personalizedSettingC = controller.setting.personalizedsetting.PersonalizedSetting()

        self.tabWidget.addTab(_centerSetC, QString.fromUtf8("中心设置"))
        self.tabWidget.addTab(_domainSettingsC,QString.fromUtf8("域名设置"))
        self.tabWidget.addTab(_personalizedSettingC,QString.fromUtf8("个性化设置"))

        self.mousePressed = False
        self.setAutoFillBackground(True)
        palettle=QPalette()
        palettle.setColor(QPalette.Background,QColor(150,150,150))
        self.setPalette(palettle)
        self.setStyleSheet(QString("QWidget#Form{background-color:rgba(110, 110, 110,110);}"))
        self.setStyleSheet(QString("QComboBox{border:1px groove rgb(170,214,252);height:25;}"))
        self.connect(self.pushButtonQuit, SIGNAL("clicked()"),self.closeSelf)
        self.connect(_centerSetC, SIGNAL("updateCenter_Date"),self.updateCenterDate)
        self.tabWidget.setFocus()
        
    def closeSelf(self):
        self.close()
        
    def resetScreen(self):
        self.emit(SIGNAL("setscreenover"))
        
    def updateCenterDate(self):
        self.emit(SIGNAL("updateCenterDateS"))

    def mouseMoveEvent(self,event):
        if self.mousePressed:
            self.move(self.pos() + event.pos() - self.currentPos)   
        self.default = QString()
    def mousePressEvent(self,event):
        if event.buttons() == Qt.LeftButton:
            self.currentPos = event.pos()
            self.mousePressed = True
    def mouseReleaseEvent(self,event):
        if event.buttons() == Qt.LeftButton:
            self.mousePressed = False
        
        
        
        