import os

from PyQt5.QtCore import QObject


class Config(QObject):

    def __init__(self):
        super().__init__()
        # 工程根目录
        self.root_path = ""
        self.getRootPath()

    def getRootPath(self):
        # 获取当前文件所在的绝对路径
        current_path = os.path.abspath(__file__)
        # 获取当前文件所在的目录
        self.root_path = os.path.dirname(current_path)

    def init_qss(self):
        theme_dir = self.root_path + "\\style\\"
        theme_list = os.listdir(theme_dir)
        qss = ""
        for file in theme_list:
            if file.endswith(".qss"):
                with open(theme_dir + file, "r", encoding="utf-8") as f:
                    qss += f.read()
        return qss


config = Config()
