#!/usr/bin/python
# coding=utf8

from PyQt4.QtGui import QWidget, QAbstractItemView, QFrame
from PyQt4.QtCore import Qt
from ui.ui_autoStartDesktopSet import Ui_Form
from common import common_run


class AutoStartDesktopSetQss(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(AutoStartDesktopSetQss, self).__init__(parent)

        self.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)  # 当窗口关闭时释放内存
        self.__set_stylesheet()

    def update_screen_show(self):
        self.__set_stylesheet()

    def __set_stylesheet(self):
        self.verticalLayout_3.setContentsMargins(int(common_run.get_width(40.0)),
                                                 int(common_run.get_width(30.0)),
                                                 int(common_run.get_width(40.0)),
                                                 int(common_run.get_width(50.0)))

        __font_size = str(int(common_run.get_height(13.0)))
        self.widget.setStyleSheet("background-color: rgb(220, 220, 220);"
                                  "font: 63 " + __font_size + "pt \"ubuntu\" ;")

        self.widget.setMinimumHeight(int(common_run.get_height(40.0)))
        self.horizontalLayout_top.setContentsMargins(int(common_run.get_width(40.0)),
                                                     0,
                                                     int(common_run.get_width(40.0)),
                                                     0)

        __font_size = str(int(common_run.get_height(11.0)))
        self.tableWidget.setStyleSheet("font: 63 " + __font_size + "pt \"ubuntu\" ;"
                                                                   "text-align: center;"
                                                                   "border:0px groove rgb(200,200,200);")

        self.tableWidget.verticalHeader().setHidden(True)
        self.tableWidget.horizontalHeader().setHidden(True)
        self.tableWidget.setShowGrid(False)
        self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tableWidget.setFrameShape(QFrame.NoFrame)


###############################
#   单元测试
##############################
if __name__ == "__main__":
    from PyQt4 import QtGui
    from os import environ

    environ["WIN_UI_IMAGES_PATH"] = "../../../images2"
    app = QtGui.QApplication([])
    win = AutoStartDesktopSetQss()
    win.show()
    app.exec_()
