The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
新增 KDE 主题色获取, 支持 Linux 添加开机自启
XiaoYouChR4d0f903f891e
diff --git a/app/common/config.py b/app/common/config.pyindex 5f765535..35e862e1 100644--- a/app/common/config.py+++ b/app/common/config.py@@ -33,7 +33,7 @@ class Config(QConfig):YEAR = 2024AUTHOR = "XiaoYouChR"-VERSION = "3.3.5"+VERSION = "3.3.4"AUTHOR_URL = "https://space.bilibili.com/437313511"FEEDBACK_URL = "https://github.com/XiaoYouChR/Ghost-Downloader-3/issues"# RELEASE_URL = "https://github.com/XiaoYouChR/Ghost-Downloader-3/releases/latest"diff --git a/app/common/methods.py b/app/common/methods.pyindex 6627536c..de4f7d82 100644--- a/app/common/methods.py+++ b/app/common/methods.py@@ -130,4 +130,4 @@ def openFile(fileResolve):elif sys.platform == "darwin": # macOSos.system(f"open '{fileResolve}'")else:- os.system(f"xdg-open '{fileResolve}'")\ No newline at end of file+ os.system(f"xdg-open '{fileResolve}'")diff --git a/app/view/setting_interface.py b/app/view/setting_interface.pyindex e547a39c..381dfc94 100644--- a/app/view/setting_interface.py+++ b/app/view/setting_interface.py@@ -1,6 +1,7 @@# coding:utf-8import osimport sys+from pathlib import Pathfrom PySide6.QtCore import Qt, QUrl, QResourcefrom PySide6.QtGui import QDesktopServices@@ -264,7 +265,7 @@ class SettingInterface(ScrollArea):<string>app.ghost.downloader</string><key>ProgramArguments</key><array>- <string>{QApplication.applicationFilePath()}</string>+ <string>'{QApplication.applicationFilePath()}'</string><string>--silence</string></array><key>RunAtLoad</key>@@ -273,10 +274,33 @@ class SettingInterface(ScrollArea):</plist>""")else:os.remove(f"/Users/{os.getlogin()}/Library/LaunchAgents/app.ghost.downloader.plist")+ elif sys.platform == "linux":+ if value:+ autoStartPath = Path(f'/home/{os.getlogin()}/.config/autostart/')+ if not autoStartPath.exists():+ autoStartPath.mkdir(parents=True, exist_ok=True)++ with open(f"/home/{os.getlogin()}/.config/autostart/gd3.desktop", "w", encoding="utf-8") as f:+ _ = (f"""[Desktop Entry]+Type=Application+Version={VERSION}+Name=Ghost Downloader 3+Comment=A multi-threading downloader with QThread based on PySide6+Exec="'{QApplication.applicationFilePath()}' --slience"+StartupNotify=false+Terminal=false+""")+ print(_)+ f.write(_)+ f.flush()++ else:+ os.remove(f"/home/{os.getlogin()}/.config/autostart/gd3.desktop")+else:InfoBar.warning(- title='注意',- content=f"该功能仅在 Windows/macOS 平台有效.",+ title='警告',+ content=f"鬼知道你用的是什么平台?",orient=Qt.Horizontal,isClosable=True,position=InfoBarPosition.TOP,diff --git a/main.py b/main.pyindex 543e4764..087b7dce 100644--- a/main.py+++ b/main.py@@ -4,6 +4,7 @@import sysfrom PySide6.QtWidgets import QApplication+from qframelesswindow.utils import getSystemAccentColorapp = QApplication(sys.argv)@@ -91,50 +92,26 @@ else:setTheme(Theme.DARK if darkdetect.isDark() else Theme.LIGHT, save=False)# Get Theme Color-try:- # Windows Only- if sys.platform == "win32":- import ctypes- # 定义用于获取主题色的函数- ctypes.windll.dwmapi.DwmGetColorizationColor.restype = ctypes.c_ulong- ctypes.windll.dwmapi.DwmGetColorizationColor.argtypes = [ctypes.POINTER(ctypes.c_ulong),- ctypes.POINTER(ctypes.c_bool)]-- color = ctypes.c_ulong()- opaque = ctypes.c_bool()-- # 获取主题颜色值- ctypes.windll.dwmapi.DwmGetColorizationColor(ctypes.byref(color), ctypes.byref(opaque))-- # 将颜色值转换为RGB元组- b, g, r = color.value % 256, (color.value >> 8) % 256, (color.value >> 16) % 256-- setThemeColor(QColor(r, g, b), save=False)-- elif sys.platform == "darwin": # macOS Only- # 咱就是说为什么苹果要把开发者文档做成英文,出个中文版不好吗?- # TM的让我找得好苦…… - By YHX (#17)- import objc # PyObjC- from Foundation import NSBundle+# try:+# 上游仅支持 Windows 和 macOS+if sys.platform == "win32" and "darwin":+ setThemeColor(getSystemAccentColor(), save=False)+if sys.platform == "linux":- # 加载AppKit框架- AppKit = NSBundle.bundleWithIdentifier_('com.apple.AppKit')+ if 'KDE_SESSION_UID' in os.environ: # KDE Plasma- # 获取NSColor类- NSColor = AppKit.classNamed_('NSColor')- NSColorSpace = AppKit.classNamed_('NSColorSpace')+ import configparser+ config = configparser.ConfigParser()- # 获取当前主题色- color = NSColor.controlAccentColor() #md就是这个API让我找了好久……- # 欸,这时还不能用,因为现在这是NSColor Catalog color,还要转换!- color = color.colorUsingColorSpace_(NSColorSpace.sRGBColorSpace())- # 获取颜色的 RGB 分量, 并将颜色分量转换为 0-255 范围- r, g, b = int(color.redComponent() * 255), int(color.greenComponent() * 255), int(color.blueComponent() * 255)+ config.read(f"/home/{os.getlogin()}/.config/kdeglobals")- setThemeColor(QColor(r, g, b), save=False)+ # 获取 DecorationFocus 的值+ if 'Colors:Window' in config:+ color = list(map(int, config.get('Colors:Window', 'DecorationFocus').split(",")))+ setThemeColor(QColor(*color))-except Exception as e:- logger.error(f"Cannot get theme color: {e}")+# except Exception as e:+# logger.error(f"Cannot get theme color: {e}")# create main windoww = MainWindow()