You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.2 KiB
63 lines
2.2 KiB
# coding:utf-8
|
|
from enum import Enum
|
|
|
|
from PySide6.QtCore import QLocale
|
|
from qfluentwidgets import (qconfig, QConfig, ConfigItem, OptionsConfigItem, BoolValidator,
|
|
OptionsValidator, RangeConfigItem, RangeValidator,
|
|
FolderListValidator, EnumSerializer, FolderValidator, ConfigSerializer, __version__)
|
|
|
|
|
|
class Language(Enum):
|
|
""" Language enumeration """
|
|
|
|
CHINESE_SIMPLIFIED = QLocale(QLocale.Chinese, QLocale.China)
|
|
CHINESE_TRADITIONAL = QLocale(QLocale.Chinese, QLocale.HongKong)
|
|
ENGLISH = QLocale(QLocale.English)
|
|
AUTO = QLocale()
|
|
|
|
|
|
class LanguageSerializer(ConfigSerializer):
|
|
""" Language serializer """
|
|
|
|
def serialize(self, language):
|
|
return language.value.name() if language != Language.AUTO else "Auto"
|
|
|
|
def deserialize(self, value: str):
|
|
return Language(QLocale(value)) if value != "Auto" else Language.AUTO
|
|
|
|
|
|
class Config(QConfig):
|
|
""" Config of application """
|
|
|
|
# folders
|
|
musicFolders = ConfigItem(
|
|
"Folders", "LocalMusic", [], FolderListValidator())
|
|
downloadFolder = ConfigItem(
|
|
"Folders", "Download", "app/download", FolderValidator())
|
|
|
|
# main window
|
|
dpiScale = OptionsConfigItem(
|
|
"MainWindow", "DpiScale", "Auto", OptionsValidator([1, 1.25, 1.5, 1.75, 2, "Auto"]), restart=True)
|
|
language = OptionsConfigItem(
|
|
"MainWindow", "Language", Language.AUTO, OptionsValidator(Language), LanguageSerializer(), restart=True)
|
|
|
|
# Material
|
|
blurRadius = RangeConfigItem("Material", "AcrylicBlurRadius", 15, RangeValidator(0, 40))
|
|
|
|
# software update
|
|
checkUpdateAtStartUp = ConfigItem("Update", "CheckUpdateAtStartUp", True, BoolValidator())
|
|
|
|
|
|
YEAR = 2023
|
|
AUTHOR = "Cinple, Carlo, Rbin"
|
|
VERSION = __version__
|
|
HELP_URL = "https://code.educoder.net/xtu202105570201/libmangers/about"
|
|
REPO_URL = "https://code.educoder.net/xtu202105570201/libmangers"
|
|
EXAMPLE_URL = "https://code.educoder.net/xtu202105570201/libmangers/about"
|
|
FEEDBACK_URL = "https://code.educoder.net/xtu202105570201/libmangers/issues"
|
|
RELEASE_URL = "https://code.educoder.net/xtu202105570201/libmangers/releases/latest"
|
|
SUPPORT_URL = "https://code.educoder.net/xtu202105570201"
|
|
|
|
|
|
cfg = Config()
|
|
qconfig.load('app/config/config.json', cfg) |