initial fluent-widgets ui
This commit is contained in:
71
app/common/config.py
Normal file
71
app/common/config.py
Normal file
@ -0,0 +1,71 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
from enum import Enum
|
||||
|
||||
from PySide6.QtCore import QLocale
|
||||
from qfluentwidgets import (qconfig, QConfig, ConfigItem, OptionsConfigItem, BoolValidator,
|
||||
OptionsValidator, RangeConfigItem, RangeValidator,
|
||||
FolderListValidator, Theme, 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
|
||||
|
||||
|
||||
def isWin11():
|
||||
return sys.platform == 'win32' and sys.getwindowsversion().build >= 22000
|
||||
|
||||
|
||||
class Config(QConfig):
|
||||
""" Config of application """
|
||||
|
||||
# folders
|
||||
musicFolders = ConfigItem(
|
||||
"Folders", "LocalMusic", [], FolderListValidator())
|
||||
downloadFolder = ConfigItem(
|
||||
"Folders", "Download", "app/download", FolderValidator())
|
||||
|
||||
# main window
|
||||
micaEnabled = ConfigItem("MainWindow", "MicaEnabled", isWin11(), BoolValidator())
|
||||
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 = "zhiyiYo"
|
||||
VERSION = __version__
|
||||
HELP_URL = "https://qfluentwidgets.com"
|
||||
REPO_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets"
|
||||
EXAMPLE_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/PySide6/examples"
|
||||
FEEDBACK_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/issues"
|
||||
RELEASE_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/releases/latest"
|
||||
ZH_SUPPORT_URL = "https://qfluentwidgets.com/zh/price/"
|
||||
EN_SUPPORT_URL = "https://qfluentwidgets.com/price/"
|
||||
|
||||
|
||||
cfg = Config()
|
||||
cfg.themeMode.value = Theme.AUTO
|
||||
qconfig.load('app/config/config.json', cfg)
|
||||
16
app/common/icon.py
Normal file
16
app/common/icon.py
Normal file
@ -0,0 +1,16 @@
|
||||
# coding: utf-8
|
||||
from enum import Enum
|
||||
|
||||
from qfluentwidgets import FluentIconBase, getIconColor, Theme
|
||||
|
||||
|
||||
class Icon(FluentIconBase, Enum):
|
||||
|
||||
GRID = "Grid"
|
||||
MENU = "Menu"
|
||||
TEXT = "Text"
|
||||
PRICE = "Price"
|
||||
EMOJI_TAB_SYMBOLS = "EmojiTabSymbols"
|
||||
|
||||
def path(self, theme=Theme.AUTO):
|
||||
return f":/gallery/images/icons/{self.value}_{getIconColor(theme)}.svg"
|
||||
260885
app/common/resource.py
Normal file
260885
app/common/resource.py
Normal file
File diff suppressed because it is too large
Load Diff
13
app/common/signal_bus.py
Normal file
13
app/common/signal_bus.py
Normal file
@ -0,0 +1,13 @@
|
||||
# coding: utf-8
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
|
||||
|
||||
class SignalBus(QObject):
|
||||
""" Signal bus """
|
||||
|
||||
switchToSampleCard = Signal(str, int)
|
||||
micaEnableChanged = Signal(bool)
|
||||
supportSignal = Signal()
|
||||
|
||||
|
||||
signalBus = SignalBus()
|
||||
25
app/common/style_sheet.py
Normal file
25
app/common/style_sheet.py
Normal file
@ -0,0 +1,25 @@
|
||||
# coding: utf-8
|
||||
from enum import Enum
|
||||
|
||||
from qfluentwidgets import StyleSheetBase, Theme, isDarkTheme, qconfig
|
||||
|
||||
|
||||
class StyleSheet(StyleSheetBase, Enum):
|
||||
""" Style sheet """
|
||||
|
||||
LINK_CARD = "link_card"
|
||||
SAMPLE_CARD = "sample_card"
|
||||
HOME_INTERFACE = "home_interface"
|
||||
ICON_INTERFACE = "icon_interface"
|
||||
VIEW_INTERFACE = "view_interface"
|
||||
SETTING_INTERFACE = "setting_interface"
|
||||
GALLERY_INTERFACE = "gallery_interface"
|
||||
NAVIGATION_VIEW_INTERFACE = "navigation_view_interface"
|
||||
|
||||
SYSTEM_INTERFACE = "system_interface"
|
||||
|
||||
def path(self, theme=Theme.AUTO):
|
||||
theme = qconfig.theme if theme == Theme.AUTO else theme
|
||||
#D:\Downloads\PyQt-Fluent-Widgets-PySide6\app\resource\qss\dark\view_interface.qss
|
||||
#return f"./app/gallery/qss/{theme.value.lower()}/{self.value}.qss"
|
||||
return f"./app/resource/qss/{theme.value.lower()}/{self.value}.qss"
|
||||
21
app/common/translator.py
Normal file
21
app/common/translator.py
Normal file
@ -0,0 +1,21 @@
|
||||
# coding: utf-8
|
||||
from PySide6.QtCore import QObject
|
||||
|
||||
|
||||
class Translator(QObject):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.text = self.tr('Text')
|
||||
self.view = self.tr('View')
|
||||
self.menus = self.tr('Menus & toolbars')
|
||||
self.icons = self.tr('Icons')
|
||||
self.layout = self.tr('Layout')
|
||||
self.dialogs = self.tr('Dialogs & flyouts')
|
||||
self.scroll = self.tr('Scrolling')
|
||||
self.material = self.tr('Material')
|
||||
self.dateTime = self.tr('Date & time')
|
||||
self.navigation = self.tr('Navigation')
|
||||
self.basicInput = self.tr('Basic input')
|
||||
self.statusInfo = self.tr('Status & info')
|
||||
self.price = self.tr("Price")
|
||||
73
app/common/trie.py
Normal file
73
app/common/trie.py
Normal file
@ -0,0 +1,73 @@
|
||||
# coding: utf-8
|
||||
from queue import Queue
|
||||
|
||||
|
||||
class Trie:
|
||||
""" String trie """
|
||||
|
||||
def __init__(self):
|
||||
self.key = ''
|
||||
self.value = None
|
||||
self.children = [None] * 26
|
||||
self.isEnd = False
|
||||
|
||||
def insert(self, key: str, value):
|
||||
""" insert item """
|
||||
key = key.lower()
|
||||
|
||||
node = self
|
||||
for c in key:
|
||||
i = ord(c) - 97
|
||||
if not 0 <= i < 26:
|
||||
return
|
||||
|
||||
if not node.children[i]:
|
||||
node.children[i] = Trie()
|
||||
|
||||
node = node.children[i]
|
||||
|
||||
node.isEnd = True
|
||||
node.key = key
|
||||
node.value = value
|
||||
|
||||
def get(self, key, default=None):
|
||||
""" get value of key """
|
||||
node = self.searchPrefix(key)
|
||||
if not (node and node.isEnd):
|
||||
return default
|
||||
|
||||
return node.value
|
||||
|
||||
def searchPrefix(self, prefix):
|
||||
""" search node matchs the prefix """
|
||||
prefix = prefix.lower()
|
||||
node = self
|
||||
for c in prefix:
|
||||
i = ord(c) - 97
|
||||
if not (0 <= i < 26 and node.children[i]):
|
||||
return None
|
||||
|
||||
node = node.children[i]
|
||||
|
||||
return node
|
||||
|
||||
def items(self, prefix):
|
||||
""" search items match the prefix """
|
||||
node = self.searchPrefix(prefix)
|
||||
if not node:
|
||||
return []
|
||||
|
||||
q = Queue()
|
||||
result = []
|
||||
q.put(node)
|
||||
|
||||
while not q.empty():
|
||||
node = q.get()
|
||||
if node.isEnd:
|
||||
result.append((node.key, node.value))
|
||||
|
||||
for c in node.children:
|
||||
if c:
|
||||
q.put(c)
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user