The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
refactor(service): FeatureService 去 Qt,ClipboardListener 移至 View 层
XiaoYouChR3a5a487663a5
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.pyindex 0280abdc..2745d3c4 100644--- a/Ghost-Downloader-3.py+++ b/Ghost-Downloader-3.py@@ -67,7 +67,7 @@ def startApp(application, isSilent=False):from PySide6.QtGui import QIconfrom app.config.cfg import cfgfrom app.config.paths import executableDir- from app.services.clipboard_listener import ClipboardListener+ from app.view.clipboard_listener import ClipboardListenerfrom app.signal_bus import signalBusfrom app.startup import loadEngine, createServices, loadPacks, startEngine, bindNotifications, checkUpdateAtStartup, stopEnginefrom app.view.windows.main_window import MainWindowdiff --git a/app/services/feature_service.py b/app/services/feature_service.pyindex 5fde328c..0bdfc9e4 100644--- a/app/services/feature_service.py+++ b/app/services/feature_service.py@@ -1,11 +1,10 @@from __future__ import annotationsfrom dataclasses import replace+from threading import Eventfrom typing import TYPE_CHECKINGfrom urllib.parse import urlparse-from PySide6.QtCore import QObject-from app.config.paths import FEATURES_DIRfrom app.models.task import TaskOptionsfrom app.platform import file_association@@ -19,9 +18,8 @@ if TYPE_CHECKING:from app.view.components.setting_card_group import CollapsibleSettingCardGroup-class FeatureService(QObject):- def __init__(self, taskService, categoryService, coroutineRunner, runtimeStatusService, parent=None):- super().__init__(parent)+class FeatureService:+ def __init__(self, taskService, categoryService, coroutineRunner, runtimeStatusService):self._taskService = taskServiceself._categoryService = categoryServiceself._coroutineRunner = coroutineRunner@@ -39,12 +37,12 @@ class FeatureService(QObject):for pack in loadPacks(FEATURES_DIR, services):self._register(pack)- def activate(self, coroutineRunner) -> None:+ def activate(self) -> None:async def activateAll():for pack in self._packs:await pack.activate()- coroutineRunner.submit(activateAll())+ self._coroutineRunner.submit(activateAll())def _register(self, pack: FeaturePack) -> None:self._packs.append(pack)@@ -216,13 +214,15 @@ class FeatureService(QObject):for s in enabledSchemes:url_scheme.registerUrlScheme(s.scheme)- def deactivate(self, coroutineRunner) -> None:- from PySide6.QtCore import QEventLoop+ def deactivate(self) -> None:+ event = Event()async def deactivateAll():- for pack in self._packs:- await pack.deactivate()-- loop = QEventLoop()- coroutineRunner.submit(deactivateAll(), done=lambda _: loop.quit())- loop.exec()+ try:+ for pack in self._packs:+ await pack.deactivate()+ finally:+ event.set()++ self._coroutineRunner.submit(deactivateAll())+ event.wait()diff --git a/app/startup.py b/app/startup.pyindex bd81e89d..01a7a998 100644--- a/app/startup.py+++ b/app/startup.py@@ -86,7 +86,7 @@ def startEngine(taskService, speedMeter, featureService, coroutineRunner):taskService.taskStarted.connect(lambda _: speedMeter.start())taskService.tasksAllCompleted.connect(speedMeter.stop)taskService.resumeSaved()- featureService.activate(coroutineRunner)+ featureService.activate()def bindNotifications(taskService, notifyCompleted, notifyDiskSpace):@@ -107,7 +107,7 @@ def stopEngine(taskService, browserService, aria2RpcServer, featureService, corospeedMeter.stop()browserService.stop()aria2RpcServer.stop()- featureService.deactivate(coroutineRunner)+ featureService.deactivate()taskService.flush()if updateService is not None:updateService.apply()diff --git a/app/services/clipboard_listener.py b/app/view/clipboard_listener.pysimilarity index 100%rename from app/services/clipboard_listener.pyrename to app/view/clipboard_listener.py