Skip to content

The only downloader you need. 下载器的集大成者。

feat(theme): 实现自定义主题模式支持

XiaoYouChR26bc27397600
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index 93cae287..159d0175 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -1,8 +1,5 @@
-import sys
import os
-
-# import orjson
-# sys.modules['json'] = orjson
+import sys
from PySide6.QtCore import QStandardPaths
@@ -11,8 +8,10 @@ from qfluentwidgets import qconfig
from app.supports.application import SingletonApplication
from app.supports.config import cfg
-appLocalDataLocation = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppLocalDataLocation)
+# import orjson
+# sys.modules['json'] = orjson
+appLocalDataLocation = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppLocalDataLocation)
qconfig.load(f"{appLocalDataLocation}/GhostDownloader/UserConfig.json", cfg)
if cfg.get(cfg.dpiScale) != 0:
@@ -25,6 +24,10 @@ application = SingletonApplication(sys.argv, "gd3")
from loguru import logger
import time
import warnings
+from getpass import getuser
+from qfluentwidgets import setThemeColor, setTheme, Theme
+from qframelesswindow.utils import getSystemAccentColor
+from PySide6.QtGui import QColor
from app.supports.config import VERSION
from app.view.windows.main_window import MainWindow
@@ -33,14 +36,35 @@ from app.supports.recorder import taskRecorder
import app.assets.resources
from app.services.core_service import coreService
from app.services.feature_service import featureService
-from niquests.packages import urllib3
logger.add(f"{appLocalDataLocation}/GhostDownloader/GhostDownloader.log", rotation="512 KB", enqueue=True)
logger.info(f"Ghost Downloader v{VERSION} is Launched at {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))}")
-urllib3.disable_warnings()
warnings.warn = logger.warning
+if cfg.customThemeMode.value == "System":
+ setTheme(Theme.AUTO, save=False)
+elif cfg.customThemeMode.value == "Light":
+ setTheme(Theme.LIGHT, save=False)
+else:
+ setTheme(Theme.DARK, save=False)
+
+if sys.platform in {"win32", "darwin"}:
+ print(getSystemAccentColor())
+ setThemeColor(getSystemAccentColor(), save=False)
+if sys.platform == "linux":
+
+ if 'KDE_SESSION_UID' in os.environ: # KDE Plasma
+
+ import configparser
+ config = configparser.ConfigParser()
+
+ config.read(f"/home/{getuser()}/.config/kdeglobals")
+
+ if 'Colors:Window' in config:
+ color = list(map(int, config.get('Colors:Window', 'DecorationFocus').split(",")))
+ setThemeColor(QColor(*color))
+
isSilently = "silent" in sys.argv
coreService.start()
mainWindow = MainWindow(isSilently)