#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@文件    :palette_theme.py
@时间    :2022/01/15 19:42:22
@作者    :None
@版本    :1.0
@说明    :主题
'''

import os
from utils.globalvar import SD
from utils.resource import resource_path
from utils.qt import QPalette, QFont, QBrush, QPixmap, QColor, QIcon

THEME = 0


def set_my_palette(self):

    icon = QIcon()
    icon.addPixmap(QPixmap(resource_path(os.path.join("assets", "ic_launch.png"))), QIcon.Normal, QIcon.Off)
    self.setWindowIcon(icon)

    self.setAutoFillBackground(True)
    palette = QPalette()

    if THEME:
        # 背景图片
        palette.setBrush(QPalette.Window, QBrush(QPixmap(resource_path(os.path.join("assets", "background.jpeg")))))
        # 背景字体
        palette.setColor(QPalette.WindowText, QColor(255, 255, 255))
        palette.setColor(QPalette.ButtonText, QColor(255, 255, 255))
        palette.setColor(QPalette.Button, QColor("#1A1A1A"))
        palette.setColor(QPalette.Base, QColor("#1A1A1A"))
        palette.setColor(QPalette.Text, QColor(255, 255, 255))
        palette.setColor(QPalette.ToolTipBase, QColor(255, 255, 255))

    self.setPalette(palette)
    # 定义字体样式
    font = QFont('Microsoft YaHei')
    if SD.HIGH_DPI == 1:
        font.setPixelSize(17)
    self.setFont(font)


def set_sure_background(self):
    palette = self.palette()
    palette.setColor(QPalette.Button, QColor("#99CC99"))
    self.setPalette(palette)
    self.setAutoFillBackground(True)
    self.setFlat(True)


def set_edt_bg(self, color):
    palette = self.palette()
    palette.setColor(QPalette.Base, color)
    self.setPalette(palette)
    self.setAutoFillBackground(True)


def set_edt_bg_white(self):
    palette = self.palette()
    palette.setColor(QPalette.Base, QColor("#FFFFFF"))
    self.setPalette(palette)
    self.setAutoFillBackground(True)


def set_tab_bg(self):
    palette = QPalette()
    palette.setColor(QPalette.Active, QPalette.Button, QColor(0, 0, 255))
    self.setPalette(palette)
    self.setAutoFillBackground(True)


def set_table_header_bg(self):
    palette = QPalette()
    palette.setColor(QPalette.Button, QColor("#FFA500"))
    self.setPalette(palette)
    self.setAutoFillBackground(True)


def set_table_line_bg(self):
    palette = QPalette()
    palette.setColor(QPalette.Active, QPalette.ColorRole, QColor("#FFA500"))
    self.setPalette(palette)
    self.setAutoFillBackground(True)
