The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
加入macOS支持,做了一点优化 (#17)
YHX2010fa7088b81105
diff --git a/main.py b/main.pyindex 47362069..e5be19d6 100644--- a/main.py+++ b/main.py@@ -50,32 +50,65 @@ app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)setTheme(Theme.DARK if darkdetect.isDark() else Theme.LIGHT, save=False)# Get Theme Color-try:- # 定义用于获取主题色的函数-- 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)--except Exception as e:- logger.error(f"Cannot get theme color: {e}")-+# Windows Only+if sys.platform == "win32":+ try:+ # 定义用于获取主题色的函数++ 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)++ except Exception as e:+ logger.error(f"Cannot get theme color: {e}")+elif sys.platform == "darwin": # macOS Only+ # 咱就是说为什么苹果要把开发者文档做成英文,出个中文版不好吗?+ # TM的让我找得好苦…… - By YHX+ import objc # PyObjC+ from Foundation import NSBundle++ # 加载AppKit框架+ AppKit = NSBundle.bundleWithIdentifier_('com.apple.AppKit')++ # 获取NSColor类+ NSColor = AppKit.classNamed_('NSColor')+ NSColorSpace = AppKit.classNamed_('NSColorSpace')++ # 获取当前主题色+ theme_color = NSColor.controlAccentColor() #md就是这个API让我找了好久……+ # 欸,这时还不能用,因为现在这是NSColor Catalog color,还要转换!+ color = theme_color.colorUsingColorSpace_(NSColorSpace.sRGBColorSpace())+ # 获取颜色的 RGB 分量+ red = color.redComponent()+ green = color.greenComponent()+ blue = color.blueComponent()++ # 将颜色分量转换为 0-255 范围+ red = int(red * 255)+ green = int(green * 255)+ blue = int(blue * 255)++ setThemeColor(QColor(red, green, blue), save=False)+else:+ logger.warning("Cannot get theme color on this platform: "+sys.platform)+# create main windoww = MainWindow()# loading plugins-loadPlugins(w)+pluginsPath=os.path.join(os.path.dirname(__file__), "plugins")+loadPlugins(w, pluginsPath)try: # 静默启动if sys.argv[1] == "--silence":diff --git a/requirements.txt b/requirements.txtindex 269baa0d..b260f3d1 100644--- a/requirements.txt+++ b/requirements.txt@@ -2,3 +2,4 @@ PySide6-Fluent-Widgets>=1.1.8PySide6>=6.4.2loguru>=0.7.2httpx>=0.27.0+pyobjc>=10.3.1