Skip to content

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

Fixes #446

XiaoYouChRcb9748a48901
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index f0679078..dc13d72c 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -29,9 +29,9 @@ appLocalDataLocation = QStandardPaths.writableLocation(QStandardPaths.StandardLo
logger.add(f"{appLocalDataLocation}/GhostDownloader/GhostDownloader.log", rotation="512 KB", enqueue=True)
sys.excepthook = exceptionHook
-from qfluentwidgets import qconfig
+from qfluentwidgets import qconfig, setTheme
from app.supports.application import SingletonApplication
-from app.supports.config import VERSION, cfg
+from app.supports.config import VERSION, cfg, toQFluentTheme
from app.supports.signal_bus import signalBus as exceptionSignalBus
logger.info(
@@ -47,6 +47,8 @@ if cfg.get(cfg.dpiScale) != 0:
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))
application = SingletonApplication(sys.argv, "gd3")
+# Prime qfluentwidgets before widgets are constructed; its own default is light.
+setTheme(toQFluentTheme(cfg.customThemeMode.value), save=False)
# --- Start Program ---
import warnings
diff --git a/app/supports/config.py b/app/supports/config.py
index c46bb975..9c053885 100644
--- a/app/supports/config.py
+++ b/app/supports/config.py
@@ -17,6 +17,7 @@ from qfluentwidgets import (
ConfigValidator,
ConfigSerializer,
FolderListValidator,
+ Theme,
)
DEFAULT_HEADERS = {
@@ -152,6 +153,13 @@ class HeadersSerializer(ConfigSerializer):
return DEFAULT_HEADERS
+def toQFluentTheme(value: str) -> Theme:
+ return {
+ "Dark": Theme.DARK,
+ "Light": Theme.LIGHT,
+ }.get(value, Theme.AUTO)
+
+
class Config(QConfig):
# 总下载设置
diff --git a/app/view/windows/main_window.py b/app/view/windows/main_window.py
index 8d30cead..468b43f1 100644
--- a/app/view/windows/main_window.py
+++ b/app/view/windows/main_window.py
@@ -10,13 +10,13 @@ from PySide6.QtGui import QDesktopServices, QIcon, QColor, QPalette
from PySide6.QtWidgets import QApplication, QGraphicsOpacityEffect, QDialog
from loguru import logger
from qfluentwidgets import MSFluentWindow, SplashScreen, FluentIcon, NavigationItemPosition, InfoBar, InfoBarPosition, \
- PushButton, PrimaryPushButton, setTheme, Theme, isDarkTheme, setThemeColor
+ PushButton, PrimaryPushButton, setTheme, isDarkTheme, setThemeColor
from app.services.browser_service import BrowserService
from app.services.core_service import coreService
from app.services.feature_service import featureService
from app.supports.config import cfg, DEFAULT_HEADERS, AUTHOR_URL, VERSION, FEEDBACK_URL, GD3_COPY_MIME_TYPE, isWin10, \
- isLessThanWin10
+ isLessThanWin10, toQFluentTheme
from app.supports.recorder import taskRecorder
from app.supports.signal_bus import signalBus
from app.supports.update import bestAsset, fetchRelease, isOutdated, toVersion
@@ -69,7 +69,8 @@ class MainWindow(MSFluentWindow):
self.connectSignalToSlot()
self._syncClipboardListener()
- self._toggleTheme(cfg.customThemeMode.value, triggeredByUser=True)
+ if platform == 'win32':
+ self._applyBackgroundEffectByCfg(cfg.backgroundEffect.value)
self.syncThemeColor()
if cfg.checkUpdateAtStartUp.value:
@@ -155,12 +156,7 @@ class MainWindow(MSFluentWindow):
value: "Literal['System', 'Dark', 'Light']",
triggeredByUser: bool = False,
):
- if value == 'Dark':
- setTheme(Theme.DARK, save=False)
- elif value == 'Light':
- setTheme(Theme.LIGHT, save=False)
- else:
- setTheme(Theme.AUTO, save=False)
+ setTheme(toQFluentTheme(value), save=False)
IconBodyLabel.clearCache()