Skip to content

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

refactor(core): 重构核心服务,实现异步任务管理和线程安全回调

XiaoYouChRdd094fe78b3c
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index 2f615668..93ac54ba 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -1,10 +1,15 @@
-import os
import sys
+import os
+
+# import orjson
+# sys.modules['json'] = orjson
from PySide6.QtCore import QStandardPaths
from qfluentwidgets import qconfig
+from app.services.core_service import coreService
+from app.services.feature_service import featureService
from app.supports.application import SingletonApplication
from app.supports.config import cfg
@@ -32,6 +37,8 @@ logger.add(f"{appLocalDataLocation}/GhostDownloader/GhostDownloader.log", rotati
logger.info(f"Ghost Downloader v{VERSION} is Launched at {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))}")
warnings.warn = logger.warning
+coreService.start()
mainWindow = MainWindow(silent = "silent" in sys.argv)
+featureService.loadFeatures(mainWindow)
sys.exit(application.exec())
diff --git a/app/bases/interfaces.py b/app/bases/interfaces.py
index e69de29b..23d16b4d 100644
--- a/app/bases/interfaces.py
+++ b/app/bases/interfaces.py
@@ -0,0 +1,15 @@
+from typing import TYPE_CHECKING
+
+from app.view.components.cards import TaskCardBase
+
+if TYPE_CHECKING:
+ from app.view.windows.main_window import MainWindow
+
+
+class FeaturePackBase:
+
+ def parse(self, payload: dict) -> TaskCardBase:
+ raise NotImplementedError
+
+ def load(self, mainWindow: "MainWindow"):
+ raise NotImplementedError
\ No newline at end of file
diff --git a/app/services/core_service.py b/app/services/core_service.py
index 4d91f4cb..8635634c 100644
--- a/app/services/core_service.py
+++ b/app/services/core_service.py
@@ -1,46 +1,307 @@
-# 一个自给自足的 AsyncIO 循环, 跑在 QThread 中?
import asyncio
+import traceback
+import sys
+from typing import Callable, Dict, Any, Coroutine
+from concurrent.futures import Future
-from PySide6.QtCore import QThread
+from PySide6.QtCore import QThread, QTimer
+from PySide6.QtWidgets import QApplication
+from loguru import logger
from app.bases.models import Task
-from app.services.feature_service import featuresService
+from app.services.feature_service import featureService
-class CoreService(QThread):
- """用于接收来自前端的任务, 在 Asyncio 循环中一直等待任务"""
+class CoreService(QThread):
+ """核心服务类,在子线程中运行独立的 AsyncIO 事件循环
+
+ 设计理念:
+ 1. 在 QThread 子线程中创建并运行独立的 asyncio 事件循环
+ 2. 提供线程安全的接口供主线程(Qt UI)调用
+ 3. 仅使用回调函数进行通知,避免 Qt Signal 的维护复杂性
+ 4. 通过 Qt 的线程安全机制确保 UI 更新的安全性
+ 5. 协调 FeatureService 进行 URL 解析和任务创建
+ """
def __init__(self):
super().__init__()
- self.loop: asyncio.AbstractEventLoop = None
+ self.loop = asyncio.new_event_loop()
+ asyncio.set_event_loop(self.loop)
+ self.mainLoop = self.loop.create_task(self.main())
self.tasks: set[Task] = set()
+ self._pending_callbacks: Dict[str, Callable] = {} # 存储待执行的回调函数
+
+ def runCoroutine(self, coroutine: Coroutine, callback):
+ # 生成回调标识符
+ callback_id = f"custom_{id(callback)}_{hash(str(coroutine))}"
+
+ # 存储回调函数
+ self._pending_callbacks[callback_id] = callback
+
+ self.loop.create_task(self._runCoroutine(coroutine, callback_id))
+
+ return callback_id
- async def _parseUrl(self, payload: dict):
- url = payload['url']
- function = featuresService.getParseFunction(url)
- payload = await function(payload)
+ async def _runCoroutine(self, coroutine: Coroutine, callback_id):
+ try:
+ result = await coroutine
+ callback = self._pending_callbacks.pop(callback_id)
+ self._executeCallback(callback, result, None)
+ except Exception as e:
+ callback = self._pending_callbacks.pop(callback_id)
+ self._executeCallback(callback, None, repr(e))
- def parseUrl(self, payload: dict) -> str:
- """前端调用这玩意, 前端记录和生成了任务的 ID"""
- self.loop.create_task(self._parseUrl(payload)) # 这里不是 thread safe 的
+ async def _parseUrl(self, payload: dict, callback_id: str = None):
+ """内部异步方法:解析 URL 并通过线程安全方式调用回调
+
+ Args:
+ payload: 包含 url, headers, proxies 等信息的字典
+ callback_id: 回调函数标识符
+ """
+ try:
+ url = payload.get('url', '')
+ if not url:
+ raise ValueError("URL 不能为空")
+
+ # 从 FeatureService 获取对应的解析函数
+ parse_function = featureService.getParseFunction(url)
+ if parse_function is None:
+ raise ValueError(f"不支持的 URL 类型: {url}")
+
+ # 执行解析
+ result = await parse_function(payload)
+
+ # 通过线程安全方式调用回调
+ if callback_id and callback_id in self._pending_callbacks:
+ callback = self._pending_callbacks.pop(callback_id)
+ self._executeCallback(callback, result, None)
+
+ except Exception as e:
+ error_msg = f"解析 URL 失败: {str(e)}\n{traceback.format_exc()}"
+ # 在子线程中打印错误信息到终端
+ logger.exception(error_msg)
+
+ if callback_id and callback_id in self._pending_callbacks:
+ callback = self._pending_callbacks.pop(callback_id)
+ self._executeCallback(callback, None, error_msg)
+
+ def parseUrl(self, payload: dict, callback: Callable = None) -> str:
+ """线程安全的 URL 解析接口,仅使用回调函数
+
+ Args:
+ payload: 包含解析所需信息的字典
+ 必须包含: url (str)
+ 可选包含: headers (dict), proxies (dict)
+ callback: 回调函数,签名应为 callback(result: dict, error: str = None)
+
+ Returns:
+ str: 操作标识符,可用于追踪该解析请求
+ """
+ if not self.loop or not self.loop.is_running():
+ raise RuntimeError("CoreService 事件循环未运行")
+
+ if callback is None:
+ raise ValueError("必须提供回调函数")
+
+ # 生成回调标识符
+ callback_id = f"parse_{id(callback)}_{hash(str(payload))}"
+
+ # 存储回调函数
+ self._pending_callbacks[callback_id] = callback
+
+ # 在事件循环中调度解析任务
+ self.loop.create_task(self._parseUrl(payload, callback_id))
+
+ return callback_id
async def _createTask(self, payload: dict) -> Task:
- ...
+ """内部异步方法:创建下载任务
+
+ Args:
+ payload: 包含任务创建信息的字典
+
+ Returns:
+ Task: 创建的任务对象
+ """
+ try:
+ # TODO: 实现具体的任务创建逻辑
+ # 这里应该调用 FeatureService 获取相应的任务创建函数
+ # 然后执行任务创建流程
+
+ # 示例实现
+ task_data = {
+ 'title': payload.get('filename', '未知文件'),
+ 'metadata': {
+ 'url': payload.get('url', ''),
+ 'file_size': payload.get('fileSize', 0),
+ 'download_path': payload.get('downloadPath', '')
+ }
+ }
+
+ task = Task(**task_data)
+ self.tasks.add(task)
+
+ return task
+
+ except Exception as e:
+ error_msg = f"创建任务失败: {str(e)}\n{traceback.format_exc()}"
+ raise
- def createTask(self, payload: dict):
- """前端调用这玩意, 前端记录和生成了任务的 ID"""
- return asyncio.run_coroutine_threadsafe(self._createTask(payload), self.loop)
+ def createTask(self, payload: dict, callback: Callable = None) -> str:
+ """线程安全的任务创建接口,使用回调函数
+
+ Args:
+ payload: 包含任务创建所需信息的字典
+ callback: 回调函数,签名应为 callback(task: Task, error: str = None)
+
+ Returns:
+ str: 操作标识符
+ """
+ if not self.loop or not self.loop.is_running():
+ raise RuntimeError("CoreService 事件循环未运行")
+
+ if callback is None:
+ raise ValueError("必须提供回调函数")
+
+ # 生成回调标识符
+ callback_id = f"create_{id(callback)}_{hash(str(payload))}"
+
+ # 存储回调函数
+ self._pending_callbacks[callback_id] = callback
+
+ # 在事件循环中调度任务创建
+ self.loop.create_task(self._createTaskWithCallback(payload, callback_id))
+
+ return callback_id
+
+ async def _createTaskWithCallback(self, payload: dict, callback_id: str):
+ """带回调的任务创建包装方法"""
+ try:
+ task = await self._createTask(payload)
+ if callback_id in self._pending_callbacks:
+ callback = self._pending_callbacks.pop(callback_id)
+ self._executeCallback(callback, task, None)
+ except Exception as e:
+ error_msg = f"创建任务失败: {str(e)}\n{traceback.format_exc()}"
+ # 在子线程中打印错误信息到终端
+ logger.exception(error_msg)
+
+ if callback_id in self._pending_callbacks:
+ callback = self._pending_callbacks.pop(callback_id)
+ self._executeCallback(callback, None, str(e))
def getAllTaskInfo(self) -> set:
- return self.tasks
+ """获取所有任务信息
+
+ Returns:
+ set: 所有任务对象的集合
+ """
+ return self.tasks.copy()
+
+ def getTaskById(self, task_id: str) -> Task:
+ """根据任务ID获取任务对象
+
+ Args:
+ task_id: 任务ID
+
+ Returns:
+ Task: 对应的任务对象,如果不存在则返回None
+ """
+ for task in self.tasks:
+ if task.taskId == task_id:
+ return task
+ return None
+
+ def removeCallback(self, callback_id: str) -> bool:
+ """移除待执行的回调函数
+
+ Args:
+ callback_id: 回调函数标识符
+
+ Returns:
+ bool: 是否成功移除
+ """
+ if callback_id in self._pending_callbacks:
+ del self._pending_callbacks[callback_id]
+ return True
+ return False
+
+ def _executeCallback(self, callback: Callable, result: Any, error: str = None):
+ """线程安全地执行回调函数
+
+ 通过 Qt 的事件循环机制确保回调在主线程中执行,
+ 避免子线程直接操作 UI 导致的崩溃问题。
+
+ Args:
+ callback: 回调函数
+ result: 成功结果
+ error: 错误信息
+ """
+ def wrapper():
+ try:
+ if asyncio.iscoroutinefunction(callback):
+ # 如果是协程函数,在事件循环中执行
+ self.loop.create_task(callback(result, error))
+ else:
+ # 普通函数直接调用
+ callback(result, error)
+ except Exception as e:
+ errorMsg = f"回调函数执行失败: {str(e)}\n{traceback.format_exc()}"
+ logger.exception(errorMsg)
+
+ if QApplication.instance():
+ QTimer.singleShot(0, QApplication.instance(), wrapper)
+ else:
+ wrapper()
async def main(self):
+ """主事件循环
+
+ 在这里可以添加周期性任务,如清理过期回调、监控任务状态等
+ """
while True:
- await asyncio.sleep(1)
+ try:
+ # 清理过期的回调函数(超过一定时间未执行的)
+ # TODO: 实现回调清理逻辑
+
+ # 监控任务状态
+ # TODO: 实现任务状态监控逻辑
+
+ await asyncio.sleep(1)
+
+ except asyncio.CancelledError:
+ # 优雅退出
+ break
+ except Exception as e:
+ print(f"主循环发生错误: {e}")
+ await asyncio.sleep(1)
def run(self):
- self.loop = asyncio.new_event_loop()
- asyncio.set_event_loop(self.loop)
- self.mainLoop = self.loop.create_task(self.main())
- self.loop.run_until_complete(self.mainLoop)
+ """启动线程和事件循环"""
+ try:
+ self.loop.run_until_complete(self.mainLoop)
+ except Exception as e:
+ print(f"CoreService 启动失败: {e}")
+ finally:
+ if self.loop:
+ self.loop.close()
+
+ def stop(self):
+ """停止服务"""
+ if self.loop and self.loop.is_running():
+ # 取消主循环任务
+ if hasattr(self, 'mainLoop') and not self.mainLoop.done():
+ self.mainLoop.cancel()
+
+ # 关闭事件循环
+ self.loop.call_soon_threadsafe(self.loop.stop)
+
+ # def isRunning(self) -> bool:
+ # """检查服务是否正在运行
+ #
+ # Returns:
+ # bool: 服务运行状态
+ # """
+ # return self.loop is not None and self.loop.is_running()
+coreService = CoreService()
diff --git a/app/services/feature_service.py b/app/services/feature_service.py
index d30d4b36..12c949d8 100644
--- a/app/services/feature_service.py
+++ b/app/services/feature_service.py
@@ -1,18 +1,131 @@
+import os
+import sys
+import importlib.util
+from typing import TYPE_CHECKING, Dict, Any, Callable
+from pathlib import Path
+
+if TYPE_CHECKING:
+ from app.view.windows.main_window import MainWindow
+
+
class FeatureService:
+ """从 features 文件夹加载 features pack, 当 CoreService 询问时, 返回对应动态加载的函数"""
+
def __init__(self):
- self.parseFunction = {}
- self.availableTask = {}
+ self.parseFunction: Dict[str, Callable] = {}
+ self.availableTask: Dict[str, Any] = {}
+ self.loadedPacks: Dict[str, Any] = {}
+ self.featuresPath = Path(__file__).parent.parent.parent / "features"
- """从 features 文件夹加载 features pack, 当 CoreService 询问时, 返回对应动态加载的函数"""
def getParseFunction(self, url: str):
"""返回对应 url 的解析函数"""
+ # TODO: 实现 URL 匹配逻辑,返回对应的解析函数
return None
def getAvailableTask(self):
- ...
+ # TODO: 实现获取可用任务类型的逻辑
+ return self.availableTask
+
+ def discoverFeaturePacks(self) -> list:
+ """发现 features 文件夹中的所有 feature packs"""
+ featurePacks = []
+
+ if not self.featuresPath.exists():
+ print(f"警告: features 文件夹不存在: {self.featuresPath}")
+ return featurePacks
+
+ # 遍历 features 目录下的所有子目录
+ for item in self.featuresPath.iterdir():
+ if item.is_dir() and not item.name.startswith('.'):
+ packPath = item / "pack.py"
+ if packPath.exists():
+ featurePacks.append({
+ 'name': item.name,
+ 'path': str(packPath),
+ 'directory': str(item)
+ })
+
+ return featurePacks
+
+ def loadFeaturePack(self, packInfo: dict, mainWindow: "MainWindow"):
+ """加载单个 feature pack"""
+ try:
+ # 动态导入 pack.py 模块
+ spec = importlib.util.spec_from_file_location(
+ f"feature_pack_{packInfo['name']}",
+ packInfo['path']
+ )
+
+ if spec is None or spec.loader is None:
+ print(f"错误: 无法加载 feature pack: {packInfo['name']}")
+ return False
+
+ module = importlib.util.module_from_spec(spec)
+
+ # 添加模块到 sys.path 以便相对导入
+ sys.path.insert(0, packInfo['directory'])
+ try:
+ spec.loader.exec_module(module)
+ finally:
+ # 移除临时添加的路径
+ if packInfo['directory'] in sys.path:
+ sys.path.remove(packInfo['directory'])
+
+ # 查找 FeaturePackBase 的子类
+ from app.bases.interfaces import FeaturePackBase
+
+ featurePackClass = None
+ for attrName in dir(module):
+ attr = getattr(module, attrName)
+ if (isinstance(attr, type) and
+ issubclass(attr, FeaturePackBase) and
+ attr != FeaturePackBase):
+ featurePackClass = attr
+ break
+
+ if featurePackClass is None:
+ print(f"警告: 在 {packInfo['name']} 中未找到 FeaturePackBase 的子类")
+ return False
+
+ # 实例化并加载 feature pack
+ packInstance = featurePackClass()
+ packInstance.load(mainWindow)
+
+ # 保存加载的 pack 信息
+ self.loadedPacks[packInfo['name']] = {
+ 'instance': packInstance,
+ 'module': module,
+ 'class': featurePackClass
+ }
+
+ print(f"✓ 成功加载 feature pack: {packInfo['name']}")
+ return True
+
+ except Exception as e:
+ print(f"✗ 加载 feature pack 失败 {packInfo['name']}: {str(e)}")
+ import traceback
+ traceback.print_exc()
+ return False
- def reloadFeatures(self):
- """从 ./features 文件夹加载 feature pack"""
- ...
+ def loadFeatures(self, mainWindow: "MainWindow"):
+ """从 ./features 文件夹自动发现并加载所有 feature packs"""
+ print("开始加载 feature packs...")
+
+ # 发现所有 feature packs
+ featurePacks = self.discoverFeaturePacks()
+
+ if not featurePacks:
+ print("未发现任何 feature packs")
+ return
+
+ print(f"发现 {len(featurePacks)} 个 feature packs: {[pack['name'] for pack in featurePacks]}")
+
+ # 加载每个 feature pack
+ loadedCount = 0
+ for packInfo in featurePacks:
+ if self.loadFeaturePack(packInfo, mainWindow):
+ loadedCount += 1
+
+ print(f"feature packs 加载完成: {loadedCount}/{len(featurePacks)} 个成功加载")
-featuresService = FeatureService()
\ No newline at end of file
+featureService = FeatureService()
diff --git a/app/supports/utils.py b/app/supports/utils.py
index f82e3a3b..b938ab3d 100644
--- a/app/supports/utils.py
+++ b/app/supports/utils.py
@@ -129,16 +129,17 @@ def getSystemProxy():
return f"http://{_.get('HTTPProxy')}:{_.get('HTTPPort')}"
else:
return None
+
return None
-def getProxy():
+def getProxies():
if cfg.proxyServer.value == "Off":
return None
elif cfg.proxyServer.value == "Auto":
- return getSystemProxy()
+ return {"http": getSystemProxy(), "https": getSystemProxy()}
else:
- return cfg.proxyServer.value
+ return {"http": cfg.proxyServer.value, "https": cfg.proxyServer.value}
def getReadableSize(size: int):
diff --git a/app/view/components/add_task_dialog.py b/app/view/components/add_task_dialog.py
index d73366a6..aa6fa8ed 100644
--- a/app/view/components/add_task_dialog.py
+++ b/app/view/components/add_task_dialog.py
@@ -1,195 +1,15 @@
-from importlib.metadata import files
from typing import Any
-from PySide6.QtCore import QEvent, Qt, QPoint, QObject, QMargins, QFileInfo
-from PySide6.QtGui import QTextOption, QMouseEvent, QColor, QPainter, QFont
-from PySide6.QtWidgets import QTextEdit, QWidget, QVBoxLayout, QLayout, QSizePolicy, QHBoxLayout, QSpacerItem, \
- QFileIconProvider, QLabel
-from qfluentwidgets import MessageBoxBase, SubtitleLabel, TextEdit, ScrollArea, SettingCardGroup, SimpleCardWidget, \
- ImageLabel, LineEdit, Action, FluentIcon, GroupHeaderCardWidget, BodyLabel, StrongBodyLabel, isDarkTheme, \
- PlainTextEdit, setFont
-from qfluentwidgets.components.widgets.card_widget import CardSeparator
-
-from app.supports.config import cfg
-from app.supports.utils import getReadableSize
-from app.view.components.setting_cards import SelectFolderSettingCard
-
-
-class ResultCardBase(QWidget):
- """显示下载链接解析结果的卡片组件"""
-
- def __init__(self, filename: str, fileSize: int, url: str, parent: QWidget = None):
- super().__init__(parent)
- self.filename = filename
- self.fileSize = fileSize
- self.url = url
- self.borderRadius = 5
-
- self.iconLabel = ImageLabel(self)
- self.filenameLabel = StrongBodyLabel(filename, self)
- self.filenameEdit = LineEdit(self)
- self.sizeLabel = BodyLabel(getReadableSize(fileSize), self)
- self.mainLayout = QHBoxLayout(self)
-
- self.initWidget()
- self.initLayout()
-
- def initWidget(self):
- """初始化组件属性"""
- self.setFixedHeight(35)
- self.resetFileIcon()
- # 设置文件名标签
- self.filenameLabel.setCursor(Qt.CursorShape.PointingHandCursor)
- self.filenameLabel.installEventFilter(self)
- # 设置编辑框
- self.filenameEdit.setText(self.filename)
- self.filenameEdit.editingFinished.connect(self._onEditingFinished)
- self.filenameEdit.hide()
-
- def initLayout(self):
- """初始化布局"""
- self.mainLayout.setContentsMargins(10, 2, 10, 2)
- self.mainLayout.setSpacing(12)
- self.mainLayout.addWidget(self.iconLabel)
- self.mainLayout.addWidget(self.filenameLabel)
- self.mainLayout.addWidget(self.filenameEdit)
- self.mainLayout.addStretch()
- self.mainLayout.addWidget(self.sizeLabel)
-
- def eventFilter(self, obj, event: QEvent):
- """事件过滤器,处理双击事件"""
- if obj is self.filenameLabel:
- if event.type() == QEvent.Type.MouseButtonDblClick and isinstance(event, QMouseEvent):
- if event.button() == Qt.MouseButton.LeftButton:
- self._enterEditMode()
- return True
- return super().eventFilter(obj, event)
-
- def resetFileIcon(self):
- icon = QFileIconProvider().icon(QFileInfo(self.filename))
- self.iconLabel.setImage(icon.pixmap(16, 16))
- self.iconLabel.setFixedSize(16, 16)
-
- def _enterEditMode(self):
- """进入编辑模式"""
- self.filenameLabel.hide()
- self.filenameEdit.show()
- self.filenameEdit.setFocus()
- self.filenameEdit.selectAll()
-
- def _onEditingFinished(self):
- """编辑完成回调"""
- newFilename = self.filenameEdit.text().strip()
- if newFilename and newFilename != self.filename:
- self.filename = newFilename
- self.filenameLabel.setText(newFilename)
- self.resetFileIcon()
-
- self.filenameEdit.hide()
- self.filenameLabel.show()
- self.filenameLabel.setFocus()
-
- def getData(self) -> dict:
- """获取卡片数据"""
- return {
- "filename": self.filename,
- "file_size": self.file_size,
- "url": self.url
- }
-
- def setFilename(self, filename: str):
- """设置文件名"""
- self.filename = filename
- self.filenameLabel.setText(filename)
- self.filenameEdit.setText(filename)
-
- @property
- def backgroundColor(self):
- return QColor(255, 255, 255, 13 if isDarkTheme() else 200)
-
- def paintEvent(self, e):
- painter = QPainter(self)
- painter.setRenderHints(QPainter.RenderHint.Antialiasing)
-
- if isDarkTheme():
- painter.setPen(QColor(0, 0, 0, 48))
- else:
- painter.setPen(QColor(0, 0, 0, 12))
-
- painter.drawLine(self.rect().topLeft(), self.rect().topRight())
-
-
-class ParseResultHeaderCardWidget(QWidget):
- """解析结果标题栏组件"""
- def __init__(self, parent=None):
- super().__init__(parent)
- self.borderRadius = 5
-
- self.viewLayout = QVBoxLayout(self)
- self.headerLabel = QLabel(" " + self.tr("解析结果"), self)
-
- self.scrollArea = ScrollArea(self)
- self.scrollWidget = QWidget(self)
- self.scrollLayout = QVBoxLayout(self.scrollWidget)
-
- self.initWidget()
- self.initLayout()
-
- def initWidget(self):
- setFont(self.headerLabel, 15, QFont.Weight.DemiBold)
- self.headerLabel.setFixedHeight(30)
- self.headerLabel.setAlignment(Qt.AlignmentFlag.AlignVCenter)
-
- self.scrollArea.setWidget(self.scrollWidget)
- self.scrollArea.setWidgetResizable(True)
- self.scrollArea.enableTransparentBackground()
-
- def initLayout(self):
- self.viewLayout.setContentsMargins(0, 0, 0, 0)
- self.viewLayout.setSpacing(0)
- self.viewLayout.addWidget(self.headerLabel)
- self.viewLayout.addWidget(self.scrollArea)
-
- self.scrollLayout.setContentsMargins(0, 0, 0, 0)
- self.scrollLayout.setSpacing(0)
-
- @property
- def backgroundColor(self):
- return QColor(255, 255, 255, 13 if isDarkTheme() else 200)
-
- def paintEvent(self, e):
- painter = QPainter(self)
- painter.setRenderHints(QPainter.RenderHint.Antialiasing)
- painter.setBrush(self.backgroundColor)
-
- if isDarkTheme():
- painter.setPen(QColor(0, 0, 0, 48))
- else:
- painter.setPen(QColor(0, 0, 0, 12))
-
- r = self.borderRadius
- # painter.drawLine(self.rect().topLeft() + QPoint(0, 30), self.rect().topRight() + QPoint(0, 30))
- painter.drawRoundedRect(self.rect(), r, r)
-
- def addWidget(self, widget):
- self.scrollLayout.addWidget(widget)
-
- def clearResults(self):
- """清空所有解析结果"""
- while self.scrollLayout.count():
- child = self.scrollLayout.takeAt(0)
- if child.widget():
- child.widget().deleteLater()
-
- def getAllResults(self) -> list:
- """获取所有解析结果的数据"""
- results = []
- for i in range(self.scrollLayout.count()):
- widget = self.scrollLayout.itemAt(i).widget()
- if isinstance(widget, ResultCardBase):
- results.append(widget.getData())
- return results
+from PySide6.QtCore import QEvent, Qt, QPoint, QTimer
+from PySide6.QtGui import QTextOption
+from qfluentwidgets import MessageBoxBase, SubtitleLabel, LineEdit, Action, FluentIcon, GroupHeaderCardWidget, \
+ PlainTextEdit
+from app.services.core_service import coreService
+from app.supports.config import cfg, DEFAULT_HEADERS
+from app.supports.utils import getProxies
+from app.view.components.card_widgets import ParseResultHeaderCardWidget, SettingHeaderCardWidget
+from app.view.components.cards import ResultCardBase
class AddTaskDialog(MessageBoxBase):
@@ -201,17 +21,21 @@ class AddTaskDialog(MessageBoxBase):
self.titleLabel = SubtitleLabel(self.tr("添加任务"), self)
self.urlEdit = PlainTextEdit(self)
self.parseResultGroup = ParseResultHeaderCardWidget(self)
- self.settingGroup = GroupHeaderCardWidget(self)
+ self.settingGroup = SettingHeaderCardWidget(self)
self.pathEdit = LineEdit(self)
self.selectFolderAction = Action(FluentIcon.FOLDER, self.tr("选择文件夹"), self)
+ self._timer = QTimer(self, singleShot=True)
+
self.initWidget()
self.initLayout()
+ self.connectSignalToSlot()
+
# TODO For Test
# self.parseResultGroup.hide()
for i in range(5):
- self.parseResultGroup.addWidget(ResultCardBase(f"DingTalk-{i}.avi", 123456789, "https://example.com/DingTalk.exe", self.parseResultGroup))
-
+ self.parseResultGroup.addWidget(
+ ResultCardBase(f"DingTalk-{i}.avi", 123456789, "https://example.com/DingTalk.exe", self.parseResultGroup))
def initWidget(self):
self.setObjectName("AddTaskDialog")
@@ -219,11 +43,9 @@ class AddTaskDialog(MessageBoxBase):
self.urlEdit.setPlaceholderText(self.tr("添加多个下载链接时,请确保每行只有一个下载链接"))
self.urlEdit.setWordWrapMode(QTextOption.WrapMode.NoWrap)
- # Setting Group
- self.settingGroup.setTitle(self.tr("下载设置"))
- self.settingGroup.headerView.setFixedHeight(30)
+
self.pathEdit.addAction(self.selectFolderAction)
- self.settingGroup.addGroup(FluentIcon.DOWNLOAD, self.tr("选择下载路径"), self.tr("下载路径"), self.pathEdit, 2)
+ self.settingGroup.addGroup(FluentIcon.DOWNLOAD, self.tr("选择下载路径"), self.pathEdit, 2)
def initLayout(self):
self.viewLayout.addWidget(self.titleLabel)
@@ -231,19 +53,78 @@ class AddTaskDialog(MessageBoxBase):
self.viewLayout.addWidget(self.parseResultGroup)
self.viewLayout.addWidget(self.settingGroup)
- def parse(self, payload: dict[str, Any]):
- ...
+ def connectSignalToSlot(self):
+ self._timer.timeout.connect(self.parse)
+ self.pathEdit.textChanged.connect(lambda: (self._timer.stop(), self._timer.start(1000)))
+
+ def parse(self):
+ """解析输入的URL列表"""
+ urls = self.urlEdit.toPlainText().strip().split("\n")
+ headers = DEFAULT_HEADERS
+ proxies = getProxies()
+
+ # 清空之前的解析结果
+ self.parseResultGroup.clearResults()
+
+ for url in urls:
+ url = url.strip()
+ if url: # 跳过空行
+ payload = {
+ "url": url,
+ "headers": headers,
+ "proxies": proxies
+ }
+ # 使用回调函数处理解析结果
+ try:
+ coreService.parseUrl(payload, self._handleParseResult)
+ except Exception as e:
+ print(f"提交解析请求失败: {e}")
+
+ def _handleParseResult(self, result: dict, error: str = None):
+ """处理 URL 解析结果的回调函数
+
+ Args:
+ result: 解析成功时的结果字典
+ error: 解析失败时的错误信息
+ """
+ if error:
+ # 处理解析错误
+ print(f"解析失败: {error}")
+ # TODO: 显示错误信息给用户
+ return
+
+ if result:
+ # 提取解析结果
+ filename = result.get('filename', '未知文件')
+ file_size = result.get('fileSize', 0)
+ url = result.get('url', '')
+
+ # 添加到界面
+ self.addParseResult(filename, file_size, url)
+
+ def addParseResult(self, filename: str, fileSize: int, url: str):
+ """添加解析结果卡片到滚动区域
+
+ Args:
+ filename: 文件名
+ fileSize: 文件大小
+ url: 下载链接
+
+ Returns:
+ ResultCardBase: 创建的结果卡片对象
+ """
+ try:
+ resultCard = ResultCardBase(filename, fileSize, url, self.parseResultGroup)
+ self.parseResultGroup.addWidget(resultCard)
+ return resultCard
+ except Exception as e:
+ print(f"添加解析结果失败: {e}")
+ return None
def done(self, code):
...
super().done(code)
- def addParseResult(self, filename: str, fileSize: int, url: str):
- """添加解析结果卡片到滚动区域"""
- resultCard = ResultCardBase(filename, fileSize, url, self.parseResultGroup)
- self.parseResultGroup.addWidget(resultCard)
- return resultCard
-
@classmethod
def display(cls, payload: dict[str, Any]=None, parent=None):
if cls._instance is None:
diff --git a/app/view/components/card_widgets.py b/app/view/components/card_widgets.py
new file mode 100644
index 00000000..05103eef
--- /dev/null
+++ b/app/view/components/card_widgets.py
@@ -0,0 +1,118 @@
+from PySide6.QtCore import Qt
+from PySide6.QtGui import QFont, QColor, QPainter
+from PySide6.QtWidgets import QWidget, QVBoxLayout, QLabel
+from qfluentwidgets import ScrollArea, setFont, isDarkTheme, CardGroupWidget
+
+from app.view.components.cards import ResultCardBase, GroupSettingCard
+
+
+class HeaderCardWidgetBase(QWidget):
+ def __init__(self, parent = None):
+ super().__init__(parent)
+ self.borderRadius = 5
+
+ self.viewLayout = QVBoxLayout(self)
+ self.headerLabel = QLabel(self)
+
+ self.scrollArea = ScrollArea(self)
+ self.scrollWidget = QWidget(self)
+ self.scrollLayout = QVBoxLayout(self.scrollWidget)
+
+ self.initWidget()
+ self.initLayout()
+
+ def initWidget(self):
+ setFont(self.headerLabel, 15, QFont.Weight.DemiBold)
+ self.headerLabel.setFixedHeight(30)
+ self.headerLabel.setAlignment(Qt.AlignmentFlag.AlignVCenter)
+
+ self.scrollArea.setWidget(self.scrollWidget)
+ self.scrollArea.setWidgetResizable(True)
+ self.scrollArea.enableTransparentBackground()
+
+ def initLayout(self):
+ self.viewLayout.setContentsMargins(0, 0, 0, 0)
+ self.viewLayout.setSpacing(0)
+ self.viewLayout.addWidget(self.headerLabel)
+ self.viewLayout.addWidget(self.scrollArea)
+
+ self.scrollLayout.setContentsMargins(0, 0, 0, 0)
+ self.scrollLayout.setSpacing(0)
+
+ @property
+ def backgroundColor(self):
+ return QColor(255, 255, 255, 13 if isDarkTheme() else 200)
+
+ def paintEvent(self, e):
+ painter = QPainter(self)
+ painter.setRenderHints(QPainter.RenderHint.Antialiasing)
+ painter.setBrush(self.backgroundColor)
+
+ if isDarkTheme():
+ painter.setPen(QColor(0, 0, 0, 96))
+ else:
+ painter.setPen(QColor(0, 0, 0, 24))
+
+ r = self.borderRadius
+ # painter.drawLine(self.rect().topLeft() + QPoint(0, 30), self.rect().topRight() + QPoint(0, 30))
+ painter.drawRoundedRect(self.rect(), r, r)
+
+ def addWidget(self, widget):
+ self.scrollLayout.addWidget(widget)
+
+ def setTitle(self, title: str):
+ self.headerLabel.setText(" " + title)
+
+
+class ParseResultHeaderCardWidget(HeaderCardWidgetBase):
+ """解析结果标题栏组件"""
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.setTitle("解析结果")
+
+ def clearResults(self):
+ """清空所有解析结果"""
+ while self.scrollLayout.count():
+ child = self.scrollLayout.takeAt(0)
+ if child.widget():
+ child.widget().deleteLater()
+
+ def getAllResults(self) -> list:
+ """获取所有解析结果的数据"""
+ results = []
+ for i in range(self.scrollLayout.count()):
+ widget = self.scrollLayout.itemAt(i).widget()
+ if isinstance(widget, ResultCardBase):
+ results.append(widget.getData())
+ return results
+
+
+class SettingHeaderCardWidget(HeaderCardWidgetBase):
+ """设置标题栏组件"""
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.setTitle("下载设置")
+
+ def addGroup(self, icon, title: str, widget: QWidget, stretch=0) -> GroupSettingCard:
+ """ add widget to a new group
+
+ Parameters
+ ----------
+ icon: str | QIcon | FluentIconBase
+ the icon to be drawn
+
+ title: str
+ the title of card
+
+ widget: QWidget
+ the widget to be added
+
+ stretch: int
+ the layout stretch of widget
+ """
+ group = GroupSettingCard(icon, title, self)
+ group.addWidget(widget, stretch=stretch)
+
+ self.scrollLayout.addWidget(group)
+
+ return group
diff --git a/app/view/components/cards.py b/app/view/components/cards.py
new file mode 100644
index 00000000..b88febee
--- /dev/null
+++ b/app/view/components/cards.py
@@ -0,0 +1,280 @@
+from PySide6.QtCore import Qt, QEvent, QFileInfo, Signal
+from PySide6.QtGui import QMouseEvent, QColor, QPainter, QPen
+from PySide6.QtWidgets import QWidget, QHBoxLayout, QFileIconProvider, QVBoxLayout
+from qfluentwidgets import ImageLabel, StrongBodyLabel, LineEdit, BodyLabel, isDarkTheme, CardWidget, CheckBox, \
+ themeColor, FluentIcon, PrimaryToolButton, ToolButton, TransparentToolButton, ProgressBar, IconWidget, CaptionLabel
+
+from app.bases.models import Task
+from app.supports.utils import getReadableSize
+from app.view.components.dialogs import DeleteTaskDialog
+from app.view.components.labels import IconBodyLabel
+
+
+class ResultCardBase(QWidget):
+ """显示下载链接解析结果的卡片组件"""
+
+ def __init__(self, filename: str, fileSize: int, url: str, parent: QWidget = None):
+ super().__init__(parent)
+ self.filename = filename
+ self.fileSize = fileSize
+ self.url = url
+ self.borderRadius = 5
+
+ self.iconLabel = ImageLabel(self)
+ self.filenameLabel = StrongBodyLabel(filename, self)
+ self.filenameEdit = LineEdit(self)
+ self.sizeLabel = BodyLabel(getReadableSize(fileSize), self)
+ self.mainLayout = QHBoxLayout(self)
+
+ self.initWidget()
+ self.initLayout()
+
+ def initWidget(self):
+ """初始化组件属性"""
+ self.setFixedHeight(35)
+ self.resetFileIcon()
+ # 设置文件名标签
+ self.filenameLabel.setCursor(Qt.CursorShape.PointingHandCursor)
+ self.filenameLabel.installEventFilter(self)
+ # 设置编辑框
+ self.filenameEdit.setText(self.filename)
+ self.filenameEdit.editingFinished.connect(self._onEditingFinished)
+ self.filenameEdit.hide()
+
+ def initLayout(self):
+ """初始化布局"""
+ self.mainLayout.setContentsMargins(10, 2, 10, 2)
+ self.mainLayout.setSpacing(12)
+ self.mainLayout.addWidget(self.iconLabel)
+ self.mainLayout.addWidget(self.filenameLabel)
+ self.mainLayout.addWidget(self.filenameEdit)
+ self.mainLayout.addStretch()
+ self.mainLayout.addWidget(self.sizeLabel)
+
+ def eventFilter(self, obj, event: QEvent):
+ """事件过滤器,处理双击事件"""
+ if obj is self.filenameLabel:
+ if event.type() == QEvent.Type.MouseButtonDblClick and isinstance(event, QMouseEvent):
+ if event.button() == Qt.MouseButton.LeftButton:
+ self._enterEditMode()
+ return True
+ return super().eventFilter(obj, event)
+
+ def resetFileIcon(self):
+ icon = QFileIconProvider().icon(QFileInfo(self.filename))
+ self.iconLabel.setImage(icon.pixmap(16, 16))
+ self.iconLabel.setFixedSize(16, 16)
+
+ def _enterEditMode(self):
+ """进入编辑模式"""
+ self.filenameLabel.hide()
+ self.filenameEdit.show()
+ self.filenameEdit.setFocus()
+ self.filenameEdit.selectAll()
+
+ def _onEditingFinished(self):
+ """编辑完成回调"""
+ newFilename = self.filenameEdit.text().strip()
+ if newFilename and newFilename != self.filename:
+ self.filename = newFilename
+ self.filenameLabel.setText(newFilename)
+ self.resetFileIcon()
+
+ self.filenameEdit.hide()
+ self.filenameLabel.show()
+ self.filenameLabel.setFocus()
+
+ def getData(self) -> dict:
+ """获取卡片数据"""
+ return {
+ "filename": self.filename,
+ "file_size": self.fileSize,
+ "url": self.url
+ }
+
+ def setFilename(self, filename: str):
+ """设置文件名"""
+ self.filename = filename
+ self.filenameLabel.setText(filename)
+ self.filenameEdit.setText(filename)
+
+ @property
+ def backgroundColor(self):
+ return QColor(255, 255, 255, 13 if isDarkTheme() else 200)
+
+ def paintEvent(self, e):
+ painter = QPainter(self)
+ painter.setRenderHints(QPainter.RenderHint.Antialiasing)
+
+ if isDarkTheme():
+ painter.setPen(QColor(0, 0, 0, 96))
+ else:
+ painter.setPen(QColor(0, 0, 0, 24))
+
+ painter.drawLine(self.rect().topLeft(), self.rect().topRight())
+
+
+class GroupSettingCard(QWidget):
+
+ def __init__(self, icon, title: str, parent=None):
+ super().__init__(parent=parent)
+ self.hBoxLayout = QHBoxLayout(self)
+
+ self.iconWidget = IconWidget(icon, self)
+ self.titleLabel = BodyLabel(title, self)
+
+ self.initWidget()
+
+ def initWidget(self):
+ self.iconWidget.setFixedSize(16, 16)
+
+ self.hBoxLayout.addWidget(self.iconWidget)
+ self.hBoxLayout.addWidget(self.titleLabel)
+ self.hBoxLayout.addStretch(1)
+
+ self.hBoxLayout.setSpacing(15)
+ self.hBoxLayout.setContentsMargins(24, 5, 24, 5)
+
+ def addWidget(self, widget: QWidget, stretch=0):
+ self.hBoxLayout.addWidget(widget, stretch=stretch)
+
+ @property
+ def backgroundColor(self):
+ return QColor(255, 255, 255, 13 if isDarkTheme() else 200)
+
+ def paintEvent(self, e):
+ painter = QPainter(self)
+ painter.setRenderHints(QPainter.RenderHint.Antialiasing)
+
+ if isDarkTheme():
+ painter.setPen(QColor(0, 0, 0, 96))
+ else:
+ painter.setPen(QColor(0, 0, 0, 24))
+
+ painter.drawLine(self.rect().topLeft(), self.rect().topRight())
+
+
+class TaskCardBase(CardWidget):
+ """ Task card base class """
+
+ deleted = Signal(str) # Send Task ID
+ checkedChanged = Signal(bool)
+
+ def __init__(self, parent=None):
+ super().__init__(parent)
+
+ self.keyword = "" # Task keyword, 用于搜索
+
+ self.checkBox = CheckBox(self)
+ self.checkBox.setFixedSize(23, 23)
+ self.setSelectionMode(False)
+
+ self.checkBox.stateChanged.connect(self._onCheckedChanged)
+
+ def setSelectionMode(self, isSelected: bool):
+ self.isSelectionMode = isSelected
+ self.checkBox.setVisible(isSelected)
+ if not isSelected:
+ self.checkBox.setChecked(False)
+
+ self.update()
+
+ def isChecked(self):
+ return self.checkBox.isChecked()
+
+ def setChecked(self, checked):
+ if checked == self.isChecked():
+ return
+
+ self.checkBox.setChecked(checked)
+ self.update()
+
+ def removeTask(self, deleteFile=False):
+ raise NotImplementedError
+
+ def mouseReleaseEvent(self, e):
+ super().mouseReleaseEvent(e)
+ if self.isSelectionMode:
+ self.setChecked(not self.isChecked())
+ else:
+ self.setSelectionMode(True)
+ self.setChecked(True)
+
+ def _onDeleteButtonClicked(self):
+ w = DeleteTaskDialog(self.window(), deleteOnClose=False)
+ w.deleteFileCheckBox.setChecked(False)
+
+ if w.exec():
+ self.removeTask(w.deleteFileCheckBox.isChecked())
+
+ w.deleteLater()
+
+ def _onCheckedChanged(self):
+ self.setChecked(self.checkBox.isChecked())
+ self.checkedChanged.emit(self.checkBox.isChecked())
+ self.update()
+
+ def paintEvent(self, e):
+ if self.isSelectionMode and self.isChecked():
+ painter = QPainter(self)
+ painter.setRenderHints(QPainter.RenderHint.Antialiasing)
+
+ r = self.borderRadius
+ painter.setPen(QPen(themeColor(), 2))
+ painter.setBrush(QColor(255, 255, 255, 15) if isDarkTheme() else QColor(0, 0, 0, 8))
+ painter.drawRoundedRect(self.rect().adjusted(2, 2, -2, -2), r, r)
+
+ return super().paintEvent(e)
+
+
+class TaskCard(TaskCardBase):
+ """ Task card """
+ def __init__(self, task: Task, parent=None):
+ super().__init__(parent)
+ self.task = task
+ self.setFixedHeight(60)
+
+ self.hBoxLayout = QHBoxLayout(self)
+ self.iconLabel = ImageLabel(QFileIconProvider().icon(QFileInfo("C:/Users/XiaoYouChR/Videos/Captures/反恐精英:全球攻势 2025-11-09 12-51-21.mp4")).pixmap(48, 48), self)
+ # TODO macOS
+ self.iconLabel.setFixedSize(48, 48)
+
+ self.infoVBoxLayout = QVBoxLayout(self)
+ self.filenameLabel = StrongBodyLabel(self.task.title, self)
+ self.infoLayout = QHBoxLayout(self)
+ self.speedLabel = IconBodyLabel("0.00MB/s", FluentIcon.SPEED_HIGH, self)
+ self.leftTimeLabel = IconBodyLabel("00:00:00", FluentIcon.STOP_WATCH, self)
+ self.progressLabel = IconBodyLabel("2.22MB/342.12MB", FluentIcon.LIBRARY, self)
+ self.pauseButton = PrimaryToolButton(FluentIcon.PAUSE, self)
+ self.openFileButton = ToolButton(FluentIcon.LINK, self)
+ self.openFolderButton = ToolButton(FluentIcon.FOLDER, self)
+ self.cancelButton = TransparentToolButton(FluentIcon.CLOSE, self)
+ self.progressBar = ProgressBar(self)
+ self.progressBar.setCustomBackgroundColor(QColor(0, 0, 0, 0), QColor(0, 0, 0, 0))
+ # init
+ self.initLayout()
+ # TODO For Test
+ self.progressBar.setValue(24)
+
+ def initLayout(self):
+ self.hBoxLayout.addWidget(self.checkBox)
+ self.hBoxLayout.addWidget(self.iconLabel)
+
+ self.infoVBoxLayout.addWidget(self.filenameLabel)
+ self.infoLayout.addWidget(self.speedLabel)
+ self.infoLayout.addWidget(self.leftTimeLabel)
+ self.infoLayout.addWidget(self.progressLabel)
+ self.infoVBoxLayout.addLayout(self.infoLayout)
+ self.infoVBoxLayout.setContentsMargins(2, 8, 2, 8)
+ self.hBoxLayout.addLayout(self.infoVBoxLayout)
+ self.hBoxLayout.addStretch()
+ self.hBoxLayout.addWidget(self.pauseButton)
+ self.hBoxLayout.addWidget(self.openFileButton)
+ self.hBoxLayout.addWidget(self.openFolderButton)
+ self.hBoxLayout.addWidget(self.cancelButton)
+
+ self.hBoxLayout.setContentsMargins(12, 0, 12, 0)
+
+ def resizeEvent(self, e):
+ self.progressBar.setGeometry(4, self.height() - 4, self.width() - 8, 4)
+ return super().resizeEvent(e)
diff --git a/app/view/components/task_card.py b/app/view/components/task_card.py
deleted file mode 100644
index 5aaea13b..00000000
--- a/app/view/components/task_card.py
+++ /dev/null
@@ -1,141 +0,0 @@
-from pathlib import Path
-import sys
-from PySide6.QtCore import Qt, Signal, Property, QFileInfo, QSize
-from PySide6.QtGui import QPixmap, QPainter, QFont, QColor, QPen
-from PySide6.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QFileIconProvider
-
-from qfluentwidgets import (CardWidget, IconWidget, ToolButton, FluentIcon,
- BodyLabel, CaptionLabel, ProgressBar, ImageLabel, setFont,
- MessageBoxBase, SubtitleLabel, CheckBox, InfoBar, InfoBarPosition,
- PushButton, ToolTipFilter, InfoLevel, DotInfoBadge, MessageBox,
- isDarkTheme, themeColor, RoundMenu, Action, MenuAnimationType, StrongBodyLabel,
- PrimaryPushButton, TransparentToolButton, PrimaryToolButton)
-
-from app.view.components.dialogs import DeleteTaskDialog
-from app.bases.models import Task
-from app.view.components.labels import IconBodyLabel
-
-
-class TaskCardBase(CardWidget):
- """ Task card base class """
-
- deleted = Signal(str) # Send Task ID
- checkedChanged = Signal(bool)
-
- def __init__(self, parent=None):
- super().__init__(parent)
-
- self.keyword = "" # Task keyword, 用于搜索
-
- self.checkBox = CheckBox(self)
- self.checkBox.setFixedSize(23, 23)
- self.setSelectionMode(False)
-
- self.checkBox.stateChanged.connect(self._onCheckedChanged)
-
- def setSelectionMode(self, isSelected: bool):
- self.isSelectionMode = isSelected
- self.checkBox.setVisible(isSelected)
- if not isSelected:
- self.checkBox.setChecked(False)
-
- self.update()
-
- def isChecked(self):
- return self.checkBox.isChecked()
-
- def setChecked(self, checked):
- if checked == self.isChecked():
- return
-
- self.checkBox.setChecked(checked)
- self.update()
-
- def removeTask(self, deleteFile=False):
- raise NotImplementedError
-
- def mouseReleaseEvent(self, e):
- super().mouseReleaseEvent(e)
- if self.isSelectionMode:
- self.setChecked(not self.isChecked())
- else:
- self.setSelectionMode(True)
- self.setChecked(True)
-
- def _onDeleteButtonClicked(self):
- w = DeleteTaskDialog(self.window(), deleteOnClose=False)
- w.deleteFileCheckBox.setChecked(False)
-
- if w.exec():
- self.removeTask(w.deleteFileCheckBox.isChecked())
-
- w.deleteLater()
-
- def _onCheckedChanged(self):
- self.setChecked(self.checkBox.isChecked())
- self.checkedChanged.emit(self.checkBox.isChecked())
- self.update()
-
- def paintEvent(self, e):
- if self.isSelectionMode and self.isChecked():
- painter = QPainter(self)
- painter.setRenderHints(QPainter.RenderHint.Antialiasing)
-
- r = self.borderRadius
- painter.setPen(QPen(themeColor(), 2))
- painter.setBrush(QColor(255, 255, 255, 15) if isDarkTheme() else QColor(0, 0, 0, 8))
- painter.drawRoundedRect(self.rect().adjusted(2, 2, -2, -2), r, r)
-
- return super().paintEvent(e)
-
-class TaskCard(TaskCardBase):
- """ Task card """
- def __init__(self, task: Task, parent=None):
- super().__init__(parent)
- self.task = task
- self.setFixedHeight(60)
-
- self.hBoxLayout = QHBoxLayout(self)
- self.iconLabel = ImageLabel(QFileIconProvider().icon(QFileInfo("C:/Users/XiaoYouChR/Videos/Captures/反恐精英:全球攻势 2025-11-09 12-51-21.mp4")).pixmap(48, 48), self)
- # TODO macOS
- self.iconLabel.setFixedSize(48, 48)
-
- self.infoVBoxLayout = QVBoxLayout(self)
- self.filenameLabel = StrongBodyLabel(self.task.title, self)
- self.infoLayout = QHBoxLayout(self)
- self.speedLabel = IconBodyLabel("0.00MB/s", FluentIcon.SPEED_HIGH, self)
- self.leftTimeLabel = IconBodyLabel("00:00:00", FluentIcon.STOP_WATCH, self)
- self.progressLabel = IconBodyLabel("2.22MB/342.12MB", FluentIcon.LIBRARY, self)
- self.pauseButton = PrimaryToolButton(FluentIcon.PAUSE, self)
- self.openFileButton = ToolButton(FluentIcon.LINK, self)
- self.openFolderButton = ToolButton(FluentIcon.FOLDER, self)
- self.cancelButton = TransparentToolButton(FluentIcon.CLOSE, self)
- self.progressBar = ProgressBar(self)
- self.progressBar.setCustomBackgroundColor(QColor(0, 0, 0, 0), QColor(0, 0, 0, 0))
- # init
- self.initLayout()
- # TODO For Test
- self.progressBar.setValue(24)
-
- def initLayout(self):
- self.hBoxLayout.addWidget(self.checkBox)
- self.hBoxLayout.addWidget(self.iconLabel)
-
- self.infoVBoxLayout.addWidget(self.filenameLabel)
- self.infoLayout.addWidget(self.speedLabel)
- self.infoLayout.addWidget(self.leftTimeLabel)
- self.infoLayout.addWidget(self.progressLabel)
- self.infoVBoxLayout.addLayout(self.infoLayout)
- self.infoVBoxLayout.setContentsMargins(2, 8, 2, 8)
- self.hBoxLayout.addLayout(self.infoVBoxLayout)
- self.hBoxLayout.addStretch()
- self.hBoxLayout.addWidget(self.pauseButton)
- self.hBoxLayout.addWidget(self.openFileButton)
- self.hBoxLayout.addWidget(self.openFolderButton)
- self.hBoxLayout.addWidget(self.cancelButton)
-
- self.hBoxLayout.setContentsMargins(12, 0, 12, 0)
-
- def resizeEvent(self, e):
- self.progressBar.setGeometry(4, self.height() - 4, self.width() - 8, 4)
- return super().resizeEvent(e)
diff --git a/app/view/pages/task_page.py b/app/view/pages/task_page.py
index 3454fc12..2891cc17 100644
--- a/app/view/pages/task_page.py
+++ b/app/view/pages/task_page.py
@@ -8,7 +8,7 @@ from qfluentwidgets import ScrollArea, FlowLayout, setFont, TitleLabel, PrimaryP
DropDownToolButton
from app.view.components.labels import IconBodyLabel
-from app.view.components.task_card import TaskCardBase, TaskCard
+from app.view.components.cards import TaskCardBase, TaskCard
from app.bases.models import Task
diff --git a/app/view/windows/main_window.py b/app/view/windows/main_window.py
index 1a8680f8..7333e33b 100644
--- a/app/view/windows/main_window.py
+++ b/app/view/windows/main_window.py
@@ -10,7 +10,7 @@ from app.supports.config import cfg
from PySide6.QtCore import QRect, QPropertyAnimation, Qt
-from app.supports.utils import getProxy
+from app.supports.utils import getProxies
from app.view.components.add_task_dialog import AddTaskDialog
from app.view.pages.setting_page import SettingPage
from app.view.pages.task_page import TaskPage
@@ -119,6 +119,6 @@ class MainWindow(MSFluentWindow):
"""显示 Release 详情对话框"""
releaseData = niquests.get(url="https://api.github.com/repos/XiaoYouChR/Ghost-Downloader-3/releases/latest", headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.64"},
- allow_redirects=True).json()
+ allow_redirects=True, proxies=getProxies()).json()
dialog = ReleaseInfoDialog(releaseData, parent=self)
dialog.exec()
diff --git a/features/http_pack/pack.py b/features/http_pack/pack.py
index e69de29b..063e940d 100644
--- a/features/http_pack/pack.py
+++ b/features/http_pack/pack.py
@@ -0,0 +1,15 @@
+from app.bases.interfaces import FeaturePackBase
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from app.view.windows.main_window import MainWindow
+
+
+class HttpPack(FeaturePackBase):
+ """HTTP 下载功能包"""
+
+ def load(self, mainWindow: "MainWindow"):
+ """加载 HTTP 下载功能"""
+ # 这里可以添加 HTTP 下载相关的界面或功能
+ print("HTTP Pack 已加载 - 提供 HTTP/HTTPS 链接解析和下载功能")
+ # TODO: 实现具体的 HTTP 下载界面和功能
\ No newline at end of file
diff --git a/features/jack_yao/pack.py b/features/jack_yao/pack.py
new file mode 100644
index 00000000..a955a6b3
--- /dev/null
+++ b/features/jack_yao/pack.py
@@ -0,0 +1,459 @@
+import sys
+from base64 import b64decode
+
+import niquests
+import orjson
+from PySide6.QtCore import QThread, Signal, Qt, QSize, QUrl
+from PySide6.QtGui import QPixmap, QColor, QDesktopServices, QPainter
+from PySide6.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QHBoxLayout, QFileDialog
+from loguru import logger
+
+from app.bases.interfaces import FeaturePackBase
+from typing import TYPE_CHECKING
+
+from app.services.core_service import coreService
+from app.supports.config import cfg
+from app.supports.utils import getProxies
+
+from qfluentwidgets import IndeterminateProgressRing, MaskDialogBase, \
+ FluentStyleSheet, SettingCardGroup, OptionsConfigItem, OptionsValidator, ComboBoxSettingCard, FluentIcon, \
+ PlainTextEdit, PushSettingCard, RangeSettingCard, RangeConfigItem, RangeValidator, PrimaryPushButton, PushButton, \
+ PixmapLabel, TitleLabel, BodyLabel, PrimarySplitPushButton, SimpleCardWidget, RoundMenu, Action, IconWidget, \
+ CaptionLabel, isDarkTheme
+
+if sys.platform != "darwin":
+ from qfluentwidgets import SmoothScrollArea as ScrollArea
+else:
+ from qfluentwidgets import ScrollArea
+
+if TYPE_CHECKING:
+ from app.view.windows.main_window import MainWindow
+
+
+class JackYaoPack(FeaturePackBase):
+
+ def load(self, mainWindow:"MainWindow"):
+ mainWindow.resourceInterface = ResourceInterface()
+ mainWindow.addSubInterface(mainWindow.resourceInterface, FluentIcon.CLOUD_DOWNLOAD, "资源下载")
+
+
+async def run():
+ # with open("./Content.json", "r", encoding="utf-8") as f:
+ # self.json = json.loads(f.read())["OS"]
+ # f.close()
+ _ = getProxies()
+ result = await niquests.aget(
+ url="https://xineko-my.sharepoint.com/personal/os_store_xineko_onmicrosoft_com/_layouts/52/download.aspx?share=IQCK7kKU1-8oSqWDNNPss2xeAbmG3v4cItTXNqW2NG9Hzwc",
+ headers={
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.64"},
+ proxies=_, allow_redirects=True)
+ return orjson.loads(result.text)["OS"]
+
+
+class LoadingStatusWidget(QWidget):
+ retrySignal = Signal()
+
+ def __init__(self, parent=None):
+ super().__init__(parent=parent)
+ self.iconWidget = IconWidget(FluentIcon.SYNC, self)
+ self.label = CaptionLabel("正在加载...", self)
+ self.retryButton = PushButton("重试", self)
+ self.vBoxLayout = QVBoxLayout(self)
+ self.borderRadius = 10
+
+ self.initWidget()
+
+ def initWidget(self):
+ self.iconWidget.setFixedSize(64, 64)
+
+ self.label.setTextColor(QColor(96, 96, 96), QColor(216, 216, 216))
+ self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)
+ self.label.setWordWrap(True)
+
+ self.retryButton.setVisible(False)
+ self.retryButton.clicked.connect(self.onRetryClicked)
+
+ self.vBoxLayout.setSpacing(10)
+ self.vBoxLayout.setContentsMargins(16, 20, 16, 20)
+ self.vBoxLayout.addWidget(self.iconWidget, 0, Qt.AlignmentFlag.AlignHCenter)
+ self.vBoxLayout.addWidget(self.label, 0, Qt.AlignmentFlag.AlignHCenter)
+ self.vBoxLayout.addWidget(self.retryButton, 0, Qt.AlignmentFlag.AlignHCenter)
+
+ def setLoading(self):
+ """设置为加载状态"""
+ self.iconWidget.setIcon(FluentIcon.SYNC)
+ self.label.setText("正在加载...")
+ self.retryButton.setVisible(False)
+
+ def setError(self, errorText: str):
+ """设置为错误状态"""
+ self.iconWidget.setIcon(FluentIcon.CANCEL)
+ self.label.setText(errorText)
+ self.retryButton.setVisible(True)
+
+ def onRetryClicked(self):
+ """重试按钮点击事件"""
+ self.setLoading()
+ self.retrySignal.emit()
+
+ @property
+ def backgroundColor(self):
+ return QColor(255, 255, 255, 13 if isDarkTheme() else 200)
+
+ def paintEvent(self, e):
+ painter = QPainter(self)
+ painter.setRenderHints(QPainter.RenderHint.Antialiasing)
+ painter.setBrush(self.backgroundColor)
+ painter.setPen(Qt.PenStyle.NoPen)
+
+ r = self.borderRadius
+ painter.drawRoundedRect(self.rect(), r, r)
+
+
+class ResourceInterface(ScrollArea):
+ def __init__(self, parent=None):
+ super().__init__(parent=parent)
+
+ self.setObjectName("ResourceInterface")
+ self.cards = []
+ self.jsonData = []
+
+ self.initWidget()
+ self.initLayout()
+ self.connectSignalToSlot()
+ self.loadData()
+
+ def initWidget(self):
+ """初始化UI组件"""
+ self.scrollWidget = QWidget()
+ self.scrollWidget.setMinimumWidth(816)
+ self.expandLayout = QVBoxLayout(self.scrollWidget)
+ self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
+
+ self.loadingStatusWidget = LoadingStatusWidget(self.scrollWidget)
+ self.expandLayout.addWidget(self.loadingStatusWidget, 0, Qt.AlignmentFlag.AlignCenter)
+
+ def initLayout(self):
+ """设置布局"""
+ self.setWidget(self.scrollWidget)
+ self.setWidgetResizable(True)
+ self.enableTransparentBackground()
+
+ def connectSignalToSlot(self):
+ """初始化信号连接"""
+ self.loadingStatusWidget.retrySignal.connect(self.loadData)
+
+ def loadData(self):
+ """加载数据"""
+ self.loadingStatusWidget.setLoading()
+ coreService.runCoroutine(run(), self.loadInfoCards)
+
+ def loadInfoCards(self, jsonData: list, error: str):
+ """加载信息卡片"""
+ if error:
+ self.loadingStatusWidget.setError(f"加载失败: {error}")
+ return
+
+ self.jsonData = jsonData
+
+ # 清除现有的卡片
+ for card in self.cards:
+ self.expandLayout.removeWidget(card)
+ card.deleteLater()
+ self.cards.clear()
+
+ for item in self.jsonData:
+ card = SystemInfoCard(self.scrollWidget)
+ self.cards.append(card)
+
+ card.listData = item["List"]
+ card.titleLabel.setText(item["Name"])
+
+ logger.debug(f'Loading System Card: {item["Name"]}')
+
+ # 从字节数据中创建QPixmap对象
+ pixmap = QPixmap()
+ pixmap.loadFromData(b64decode(item["Icon"]))
+ card.logoPixmapLabel.setPixmap(pixmap)
+ card.logoPixmapLabel.setFixedSize(71, 71)
+
+ card.bodyLabel.setText(item["Intro"].replace(r"\n", "\n"))
+ card.videoUrl = item["Video"]
+
+ card.connectSignalToSlot()
+ self.expandLayout.addWidget(card)
+ card.show()
+
+ self.hideLoadingStatusWidget()
+
+ def hideLoadingStatusWidget(self):
+ """隐藏加载状态控件"""
+ self.expandLayout.removeWidget(self.loadingStatusWidget)
+ self.loadingStatusWidget.hide()
+ self.loadingStatusWidget.setParent(None)
+ self.loadingStatusWidget.deleteLater()
+
+
+class DownloadOptionDialog(MaskDialogBase):
+ startSignal = Signal()
+
+ def __init__(self, parent=None, listData=None, cardData=None):
+ super().__init__(parent=parent)
+
+ FluentStyleSheet.DIALOG.apply(self.widget)
+
+ self.cardData = cardData
+ self.listData = listData
+ self.versions = []
+
+ self.initWidget()
+ self.initGroups()
+ self.initButtons()
+ self.initLayout()
+ self.connectSignalToSlot()
+
+ def initWidget(self):
+ """初始化UI基础设置"""
+ self.setShadowEffect(60, (0, 10), QColor(0, 0, 0, 50))
+ self.setMaskColor(QColor(0, 0, 0, 76))
+
+ self.mainLayout = QVBoxLayout(self.widget)
+ self.mainLayout.setContentsMargins(18, 18, 18, 18)
+ self.widget.setLayout(self.mainLayout)
+ self.widget.setMinimumSize(510, 580)
+ self.widget.setMaximumSize(680, 580)
+
+ def initGroups(self):
+ """设置各功能组"""
+ self.initVersionGroup()
+ self.initLogGroup()
+ self.initSettingGroup()
+
+ def initVersionGroup(self):
+ """设置版本选择组"""
+ self.versionGroup = SettingCardGroup("选择版本", self.widget)
+
+ for item in self.listData:
+ self.versions.append(item["Version"])
+
+ versionItem = OptionsConfigItem(
+ "Material", "Version", self.versions[0], OptionsValidator(self.versions))
+
+ self.versionCard = ComboBoxSettingCard(
+ versionItem,
+ FluentIcon.VIEW,
+ "选择版本",
+ "选择你想下载的版本",
+ texts=self.versions,
+ parent=self.versionGroup
+ )
+
+ self.versionGroup.addSettingCard(self.versionCard)
+
+ def initLogGroup(self):
+ """设置日志组"""
+ self.logGroup = SettingCardGroup("更新日志", self.widget)
+
+ self.logTextEdit = PlainTextEdit(self.logGroup)
+ self.logTextEdit.setReadOnly(True)
+ self.logTextEdit.setMinimumHeight(140)
+ self.logTextEdit.setPlainText(self.listData[0]["Log"])
+
+ sizePolicy = QSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Maximum)
+ self.logTextEdit.setSizePolicy(sizePolicy)
+ self.logGroup.addSettingCard(self.logTextEdit)
+
+ def initSettingGroup(self):
+ """设置下载设置组"""
+ self.settingGroup = SettingCardGroup("下载设置", self.widget)
+
+ # 下载目录设置卡
+ self.downloadFolderCard = PushSettingCard(
+ "选择下载目录",
+ FluentIcon.DOWNLOAD,
+ "下载目录",
+ cfg.downloadFolder.value,
+ self.settingGroup
+ )
+
+ # 下载线程数设置卡
+ self.threadCountCard = RangeSettingCard(
+ RangeConfigItem("Material", "AcrylicBlurRadius", 24, RangeValidator(1, 256)),
+ FluentIcon.CHAT,
+ "下载线程数",
+ '下载线程越多,下载越快,同时也越吃性能',
+ self.settingGroup
+ )
+
+ self.settingGroup.addSettingCards([self.downloadFolderCard, self.threadCountCard])
+
+ def initButtons(self):
+ """设置按钮"""
+ self.buttonLayout = QHBoxLayout()
+
+ self.cancelButton = PushButton(self)
+ self.cancelButton.setObjectName("cancelButton")
+ self.cancelButton.setText("取消下载")
+
+ self.startButton = PrimaryPushButton(self)
+ self.startButton.setObjectName("startButton")
+ self.startButton.setText("开始下载")
+
+ self.buttonLayout.addWidget(self.cancelButton)
+ self.buttonLayout.addWidget(self.startButton)
+ self.buttonLayout.setSpacing(18)
+
+ def initLayout(self):
+ """设置整体布局"""
+ self.mainLayout.addWidget(self.versionGroup)
+ self.mainLayout.addWidget(self.logGroup)
+ self.mainLayout.addWidget(self.settingGroup)
+ self.mainLayout.addLayout(self.buttonLayout)
+
+ def connectSignalToSlot(self):
+ """连接信号槽"""
+ self.downloadFolderCard.clicked.connect(self.onDownloadFolderClicked)
+ self.cancelButton.clicked.connect(self.close)
+ self.startButton.clicked.connect(self.startDownload)
+ self.versionCard.comboBox.currentIndexChanged.connect(self.onVersionChanged)
+
+ def startDownload(self):
+ """开始下载任务"""
+ # path = Path(self.downloadFolderCard.contentLabel.text())
+ #
+ # # 检测路径是否有权限写入
+ # if not path.exists():
+ # try:
+ # path.mkdir(parents=True, exist_ok=True)
+ # except Exception as e:
+ # MessageBox("错误", repr(e), self)
+ # else:
+ # if not os.access(path, os.W_OK):
+ # MessageBox("错误", "似乎是没有权限向此目录写入文件", self)
+ #
+ # addDownloadTask(self.list[self.versionCard.comboBox.currentIndex()]["Url"],
+ # filePath=str(path), preBlockNum=self.blockNumCard.configItem.value)
+ self.close()
+
+ def onDownloadFolderClicked(self):
+ """下载目录点击事件"""
+ folder = QFileDialog.getExistingDirectory(self, "选择文件夹", "./")
+ if not folder or self.downloadFolderCard.contentLabel.text() == folder:
+ return
+
+ self.downloadFolderCard.setContent(folder)
+
+ def onVersionChanged(self, index: int):
+ """版本选择变化事件"""
+ self.logTextEdit.setPlainText(self.listData[index]["Log"])
+
+
+class SystemInfoCard(SimpleCardWidget):
+ def __init__(self, parent=None):
+ super().__init__(parent=parent)
+
+ self.listData = []
+ self.videoUrl = ""
+ self.pixmap = None
+
+ self.initWidget()
+ self.initMenu()
+ self.initButtonText()
+
+ def initWidget(self):
+ """初始化UI组件"""
+ self.setObjectName("SystemInfoCard")
+ self.setFixedHeight(91)
+
+ self.initMainLayout()
+ self.initLogoLabel()
+ self.initTextLayout()
+ self.initTitleLabel()
+ self.initBodyLabel()
+ self.initDownloadButton()
+
+ def initMainLayout(self):
+ """设置主布局"""
+ self.horizontalLayout = QHBoxLayout(self)
+ self.horizontalLayout.setSpacing(12)
+ self.horizontalLayout.setObjectName("horizontalLayout")
+
+ def initLogoLabel(self):
+ """设置Logo标签"""
+ self.logoPixmapLabel = PixmapLabel(self)
+ self.logoPixmapLabel.setObjectName("logoPixmapLabel")
+ self.logoPixmapLabel.setMinimumSize(QSize(71, 71))
+ self.logoPixmapLabel.setMaximumSize(QSize(71, 71))
+ self.logoPixmapLabel.setScaledContents(True)
+ self.logoPixmapLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
+ self.horizontalLayout.addWidget(self.logoPixmapLabel)
+
+ def initTextLayout(self):
+ """设置文本布局"""
+ self.bodyVBoxLayout = QVBoxLayout()
+ self.bodyVBoxLayout.setSpacing(0)
+ self.bodyVBoxLayout.setObjectName("bodyVBoxLayout")
+
+ def initTitleLabel(self):
+ """设置标题标签"""
+ self.titleLabel = TitleLabel(self)
+ self.titleLabel.setObjectName("titleLabel")
+
+ sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.titleLabel.sizePolicy().hasHeightForWidth())
+ self.titleLabel.setSizePolicy(sizePolicy)
+ self.bodyVBoxLayout.addWidget(self.titleLabel)
+
+ def initBodyLabel(self):
+ """设置内容标签"""
+ self.bodyLabel = BodyLabel(self)
+ self.bodyLabel.setObjectName("bodyLabel")
+
+ sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Maximum)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.bodyLabel.sizePolicy().hasHeightForWidth())
+ self.bodyLabel.setSizePolicy(sizePolicy)
+ self.bodyLabel.setMaximumSize(QSize(16777215, 61))
+ self.bodyLabel.setWordWrap(True)
+ self.bodyVBoxLayout.addWidget(self.bodyLabel)
+ self.horizontalLayout.addLayout(self.bodyVBoxLayout)
+
+ def initDownloadButton(self):
+ """设置下载按钮"""
+ self.downloadButton = PrimarySplitPushButton(self)
+ self.downloadButton.setObjectName("downloadButton")
+ self.downloadButton.setFixedSize(QSize(121, 31))
+ self.downloadButton.setText(" 下载 ")
+ self.horizontalLayout.addWidget(self.downloadButton)
+
+ def initMenu(self):
+ """设置菜单"""
+ self.menu = RoundMenu(parent=self)
+ self.videoAction = Action(FluentIcon.VIDEO, "视频")
+ self.menu.addAction(self.videoAction)
+ self.downloadButton.setFlyout(self.menu)
+
+ def initButtonText(self):
+ """设置按钮文本"""
+ self.downloadButton.setText(" 下载 ")
+
+ def connectSignalToSlot(self):
+ """连接信号槽"""
+ self.videoAction.triggered.connect(self.openVideoUrl)
+ self.downloadButton.clicked.connect(self.openDownloadDialog)
+
+ def openVideoUrl(self):
+ """打开视频链接"""
+ QDesktopServices.openUrl(QUrl(self.videoUrl))
+
+ def openDownloadDialog(self):
+ """打开下载对话框"""
+ dialog = DownloadOptionDialog(
+ self.window(),
+ self.listData,
+ {"pixmap": self.pixmap, "name": self.titleLabel.text()}
+ )
+ dialog.exec()
diff --git a/pyproject.toml b/pyproject.toml
index 0b4c4d77..39a5c909 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,11 +5,8 @@ description = "Add your description here"
requires-python = ">=3.13"
dependencies = [
"aiosqlite>=0.22.1",
- "black>=26.1.0",
- "logger>=1.4",
"loguru>=0.7.3",
- "niquests>=3.17.0",
+ "niquests[http3,socks,speedups]>=3.17.0",
"pyside6>=6.10.1",
"pyside6-fluent-widgets>=1.11.0",
- "ty>=0.0.15",
]