# coding=utf-8
from PyQt4.QtCore import QString, Qt
from PyQt4.QtGui import QWidget
from ui.ui_networkCheck import Ui_Form
from common import common_run
from os import getenv

class NetworkCheckQss(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(NetworkCheckQss, self).__init__(parent)
        self.setupUi(self)
        self.__borderImagesPath = getenv('WIN_UI_IMAGES_PATH')
        self.__set_style_sheet()

    def __set_style_sheet(self):
        self.setStyleSheet(QString("QWidget#Form{background-color: rgb(255,255,255)}"))
        self.verticalLayout_2.setContentsMargins(int(common_run.get_width(40.0)),
                                                 int(common_run.get_height(20.0)),
                                                 int(common_run.get_width(40.0)),
                                                 int(common_run.get_height(60.0)))

        __font_size = str(int(common_run.get_height(14.0)))

        self.comBox.setMinimumWidth(int(common_run.get_width(125.0)))
        self.comBox.setMaximumWidth(int(common_run.get_width(125.0)))
        self.comBox.setMinimumHeight(int(common_run.get_height(30.0)))
        self.comBox.setMaximumHeight(int(common_run.get_height(30.0)))
        self.horizontalLayout.setSpacing(int(common_run.get_width(15.0)))
        self.verticalLayout_2.setSpacing(int(common_run.get_height(20.0)))
        self.comBox.setStyleSheet(QString("QComboBox{border:1px groove rgb(200,200,200);"
                                          "font: "+__font_size+"pt}"
                                            "QComboBox::drop-down{border-image: url(%1/settingWindow/combox_down.png);"
                                            "subcontrol-position: center right;"
                                            "Height: " + str(int(common_run.get_width(10.0))) + "px;"                                  "Width: " + str(
                                             int(common_run.get_width(16.0))) + "px;"
                                               "}").arg(str(self.__borderImagesPath)))

        self.lineEdit.setMinimumHeight(int(common_run.get_height(30.0)))
        self.lineEdit.setStyleSheet(QString("border:1px groove rgb(200,200,200);"
                                            "font: "+__font_size+"pt;"))

        __font_size = str(int(common_run.get_height(12.0)))
        self.runButton.setText(u'执行')
        self.runButton.setMinimumHeight(int(common_run.get_height(30.0)))
        self.runButton.setMinimumWidth(int(common_run.get_width(70.0)))
        self.runButton.setStyleSheet(
            QString(
                "QPushButton{color: rgb(255,255,255);font: 63 " + __font_size + "pt;border-image: url(%1/settingWindow/btn_backgound1.png);border: 2px;}"
                                                                                "QPushButton:hover{border-image:url(%1/settingWindow/btn_backgound2.png);border: 2px;}"
                                                                                "QPushButton:pressed{border-image: url(%1/settingWindow/btn_backgound3.png);border: 2px;}").arg(
                str(self.__borderImagesPath))
        )

        self.widget_hander.setStyleSheet("background-color: #e6e6e6")
        self.widget_hander.setMinimumHeight(int(common_run.get_height(30.0)))
        self.textBrowser.setStyleSheet(QString("border:1px groove rgb(200,200,200);"))

    #
    def lineEditSetStyGroove(self,flag=True):
        __font_size = str(int(common_run.get_height(14.0)))

        if flag == True:
            self.lineEdit.setStyleSheet("QLineEdit{"
                                    "border:1px groove rgb(200,200,200);"
                                    "background-color:rgb(230,230,230);"
                                    "font: "+__font_size+"pt;"
                                    "}")
        else:
            self.lineEdit.setStyleSheet(""
                                    "border:1px groove rgb(200,200,200);"
                                    "font: "+__font_size+"pt;"
                                     "")
