The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(theme): 修复 Windows 重启后主题色深浅交替变化 #1054
XiaoYouChR01e92adece36
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.pyindex 768f10c8..a3689983 100644--- a/Ghost-Downloader-3.py+++ b/Ghost-Downloader-3.py@@ -74,7 +74,7 @@ def startApp(application: Application, primaryInstance: PrimaryInstance, isSilenfrom app.signal_bus import signalBusfrom app.services.port_listener import ListenStatusfrom app.services.update_service import UpdateService- from app.startup import loadResources, createEngine, deleteBackupDir, deleteLegacyAppIdFiles, loadPacks, checkUpdateAtStartup+ from app.startup import loadResources, setupThemeColor, createEngine, deleteBackupDir, deleteLegacyAppIdFiles, loadPacks, checkUpdateAtStartupfrom app.view.windows.main_window import MainWindowdef exceptionHook(exceptionType: type[BaseException], value: BaseException, tb: TracebackType | None) -> None:@@ -113,7 +113,7 @@ def startApp(application: Application, primaryInstance: PrimaryInstance, isSilenif cfg.shouldRunAtLogin.value:setRunAtLogin(True)- MainWindow.refreshThemeColor()+ setupThemeColor(application)updateService = UpdateService(coroutineRunner)loadPacks(featureService, coroutineRunner, speedMeter)diff --git a/app/platform/application.py b/app/platform/application.pyindex 15365684..a89e4462 100644--- a/app/platform/application.py+++ b/app/platform/application.py@@ -22,6 +22,7 @@ if TYPE_CHECKING:class Application(QApplication):openRequested = Signal(str)activated = Signal()+ systemPaletteChanged = Signal()def __init__(self, argv: list[str]) -> None:super().__init__(argv)@@ -40,6 +41,8 @@ class Application(QApplication):return Trueif e.type() == QEvent.Type.ApplicationActivate:self.activated.emit()+ if e.type() == QEvent.Type.ApplicationPaletteChange:+ self.systemPaletteChanged.emit()return super().event(e)def _onInterrupt(self, _signum: int, _frame: FrameType | None) -> None:diff --git a/app/startup.py b/app/startup.pyindex 3e8c14b0..a9cfa4bb 100644--- a/app/startup.py+++ b/app/startup.py@@ -37,6 +37,24 @@ def loadTranslators(application: Application) -> None:cfg.language.valueChanged.connect(setLocale)+def setupThemeColor(application: Application) -> None:+ import sys+ from PySide6.QtGui import QPalette+ from qfluentwidgets import setThemeColor+ from app.config.cfg import cfg++ # Issue #1054+ role = QPalette.ColorRole.Highlight if sys.platform == "win32" else QPalette.ColorRole.Accent++ def refresh() -> None:+ color = application.palette().color(QPalette.ColorGroup.Active, role)+ if color != cfg.themeColor.value:+ setThemeColor(color, save=False)++ refresh()+ application.systemPaletteChanged.connect(refresh)++def createEngine(application: Application) -> Engine:import sysfrom PySide6.QtCore import QFileSystemWatcher, QTimerdiff --git a/app/view/windows/config/config.json b/app/view/windows/config/config.jsondeleted file mode 100644index 2f747bd2..00000000--- a/app/view/windows/config/config.json+++ /dev/null@@ -1,54 +0,0 @@-{- "GeneralDownload": {- "AutoSpeedUp": true,- "DownloadFolder": "/Users/xiaoyouchr/Downloads",- "isSpeedLimitEnabled": false,- "MaxReassignSize": 3,- "MaxTaskNum": 3,- "HistoryDownloadFolder": [],- "PreBlockNum": 8,- "ProxyServer": "Auto",- "shouldVerifySsl": false,- "SpeedLimitation": 4194304- },- "Browser": {- "BrowserExtensionPairToken": "",- "EnableBrowserExtension": false,- "EnableRaiseWindowWhenReceiveMsg": false- },- "Category": {- "CategoryRules": "[{\"categoryId\": \"cat_video\", \"name\": \"视频\", \"icon\": \"VIDEO\", \"extensions\": [\"mp4\", \"mkv\", \"avi\", \"mov\", \"wmv\", \"flv\", \"webm\", \"m4v\", \"rmvb\", \"rm\", \"mpg\", \"mpeg\", \"mpe\", \"mpa\", \"3gp\", \"ts\", \"m2ts\", \"ogv\", \"asf\", \"qt\"], \"folder\": \"{default}/Video\"}, {\"categoryId\": \"cat_audio\", \"name\": \"音频\", \"icon\": \"MUSIC\", \"extensions\": [\"mp3\", \"flac\", \"wav\", \"aac\", \"ogg\", \"m4a\", \"wma\", \"ape\", \"opus\", \"mid\", \"ra\", \"aif\"], \"folder\": \"{default}/Audio\"}, {\"categoryId\": \"cat_image\", \"name\": \"图片\", \"icon\": \"PHOTO\", \"extensions\": [\"jpg\", \"jpeg\", \"png\", \"gif\", \"bmp\", \"webp\", \"avif\", \"svg\", \"tif\", \"tiff\", \"ico\", \"heic\", \"heif\"], \"folder\": \"{default}/Images\"}, {\"categoryId\": \"cat_subtitle\", \"name\": \"字幕\", \"icon\": \"CHAT\", \"extensions\": [\"srt\", \"ass\", \"ssa\", \"sub\", \"sup\", \"idx\", \"vtt\", \"lrc\", \"smi\", \"psb\"], \"folder\": \"{default}/Subtitles\"}, {\"categoryId\": \"cat_document\", \"name\": \"文档\", \"icon\": \"DOCUMENT\", \"extensions\": [\"pdf\", \"doc\", \"docx\", \"xls\", \"xlsx\", \"ppt\", \"pptx\", \"txt\", \"epub\", \"mobi\", \"azw3\", \"rtf\", \"odt\", \"ods\", \"odp\", \"md\", \"csv\", \"nfo\", \"chm\"], \"folder\": \"{default}/Documents\"}, {\"categoryId\": \"cat_archive\", \"name\": \"压缩包\", \"icon\": \"ZIP_FOLDER\", \"extensions\": [\"zip\", \"rar\", \"7z\", \"tar\", \"gz\", \"gzip\", \"bz2\", \"xz\", \"tgz\", \"tbz2\", \"zst\", \"ace\", \"arj\", \"cab\", \"lzh\", \"sea\", \"sit\", \"sitx\", \"z\", \"001\", \"tar.gz\", \"tar.bz2\", \"tar.xz\", \"tar.zst\"], \"folder\": \"{default}/Archives\"}, {\"categoryId\": \"cat_program\", \"name\": \"程序\", \"icon\": \"APPLICATION\", \"extensions\": [\"exe\", \"msi\", \"msu\", \"msp\", \"apk\", \"apks\", \"apkm\", \"dmg\", \"pkg\", \"deb\", \"rpm\", \"appimage\", \"iso\", \"img\", \"esd\", \"wim\", \"bin\", \"jar\", \"bat\", \"sh\", \"com\"], \"folder\": \"{default}/Programs\"}, {\"categoryId\": \"cat_other\", \"name\": \"其他\", \"icon\": \"HELP\", \"extensions\": [], \"folder\": null}]",- "EnableCategory": false- },- "Network": {- "ClientProfile": "auto",- "DefaultHeaders": "{\"accept-encoding\": \"deflate, br, gzip\", \"accept-language\": \"zh-CN,zh;q=0.9\", \"cookie\": \"down_ip=1\", \"sec-fetch-dest\": \"document\", \"sec-fetch-mode\": \"navigate\", \"sec-fetch-site\": \"none\", \"sec-fetch-user\": \"?1\", \"upgrade-insecure-requests\": \"1\"}"- },- "UI": {- "CollapsedSettingGroups": [],- "SettingGroupOrder": []- },- "Personalization": {- "ThemeMode": "Auto",- "DpiScale": 0,- "Language": "Auto",- "ShowDockIcon": true,- "ShowDockSpeed": true,- "ShowMenuBarSpeed": true- },- "QFluentWidgets": {- "FontFamilies": [- "Segoe UI",- "Microsoft YaHei",- "PingFang SC"- ],- "ThemeColor": "#ff009faa",- "ThemeMode": "Light"- },- "Software": {- "Geometry": "0,0,0,0",- "ClipboardListener": true,- "CheckUpdateAtStartUp": true,- "AutoRun": false- }-}\ No newline at end of filediff --git a/app/view/windows/main_window.py b/app/view/windows/main_window.pyindex 46173cdf..41c89d66 100644--- a/app/view/windows/main_window.py+++ b/app/view/windows/main_window.py@@ -5,11 +5,11 @@ from functools import cached_propertyfrom typing import TYPE_CHECKINGfrom PySide6.QtCore import QCoreApplication, QEvent, QRect, QUrl, QTimer, Qt-from PySide6.QtGui import QColor, QIcon, QDesktopServices, QKeySequence, QPainter, QPalette, QShortcut+from PySide6.QtGui import QColor, QIcon, QDesktopServices, QKeySequence, QPainter, QShortcutfrom PySide6.QtWidgets import QApplication, QHBoxLayout, QVBoxLayout, QWidgetfrom qfluentwidgets import (MSFluentWindow, FluentIcon, NavigationItemPosition, MessageBox, Theme, InfoBar, InfoBarIcon, InfoBarPosition,- SearchLineEdit, setThemeColor, IconWidget, SubtitleLabel, isDarkTheme, CheckBox, PrimaryPushButton,+ SearchLineEdit, IconWidget, SubtitleLabel, isDarkTheme, CheckBox, PrimaryPushButton,PushButton, ToolTipFilter, TransparentToolButton, qconfig,)from qfluentwidgets.common import qrouter@@ -577,21 +577,10 @@ class MainWindow(MSFluentWindow):def changeEvent(self, event) -> None:super().changeEvent(event)- if event.type() == QEvent.Type.PaletteChange:- self.refreshThemeColor()if self._isBackgroundEffectDirty and event.type() == QEvent.Type.ThemeChange:self._isBackgroundEffectDirty = Falseself._refreshBackgroundEffect()- @staticmethod- def refreshThemeColor() -> None:- palette = QApplication.palette()- for role in (QPalette.ColorRole.Accent, QPalette.ColorRole.Highlight):- color = palette.color(role)- if color.isValid() and cfg.themeColor.value != color:- setThemeColor(color, save=False)- return-def _setTheme(self, value, deferBackgroundRefresh: bool = False) -> None:prevTheme = qconfig.themeqconfig.theme = value