The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(drag): 内部拖文件不再触发 MainWindow 的拖放接收
XiaoYouChRc93fdc5e59f0
diff --git a/app/platform/application.py b/app/platform/application.pyindex e18f1087..aa24bdfb 100644--- a/app/platform/application.py+++ b/app/platform/application.py@@ -35,6 +35,7 @@ class SingletonApplication(QApplication):def __init__(self, argv: list[str], key: str):super().__init__(argv)self._key = key+ self.isFileDragActive = Falseself._memory: QSharedMemory | None = Noneself._lockSingleInstance()diff --git a/app/platform/desktop.py b/app/platform/desktop.pyindex d8ccbaee..eeb20dc9 100644--- a/app/platform/desktop.py+++ b/app/platform/desktop.py@@ -6,7 +6,7 @@ from pathlib import Pathfrom PySide6.QtCore import QMimeData, QProcess, QUrl, Qtfrom PySide6.QtGui import QDesktopServices, QDrag-from PySide6.QtWidgets import QWidget+from PySide6.QtWidgets import QApplication, QWidgetfrom loguru import logger@@ -264,14 +264,18 @@ def raiseWindow(window) -> None:def startFileDrag(paths: list[Path], source: QWidget) -> None:- if sys.platform == "win32":- try:- hwnd = int(source.window().winId())- _startFileDragWin32([str(p) for p in paths], hwnd)- return- except Exception as e:- logger.opt(exception=e).debug("COM drag failed, falling back to Qt")- _startFileDragQt(paths, source)+ QApplication.instance().isFileDragActive = True+ try:+ if sys.platform == "win32":+ try:+ hwnd = int(source.window().winId())+ _startFileDragWin32([str(p) for p in paths], hwnd)+ return+ except Exception as e:+ logger.opt(exception=e).debug("COM drag failed, falling back to Qt")+ _startFileDragQt(paths, source)+ finally:+ QApplication.instance().isFileDragActive = Falsedef _startFileDragQt(paths: list[Path], source: QWidget) -> None:diff --git a/app/view/windows/main_window.py b/app/view/windows/main_window.pyindex 3a0b2aff..00b75cce 100644--- a/app/view/windows/main_window.py+++ b/app/view/windows/main_window.py@@ -76,6 +76,7 @@ class MainWindow(MSFluentWindow):coroutineRunner: CoroutineRunner,plan,updateService=None,+ setClipboardUrls=None,parent=None,):self._isGeometryRestored = False@@ -92,6 +93,7 @@ class MainWindow(MSFluentWindow):self._speedMeter = speedMeterself._updateService = updateServiceself._plan = plan+ self._setClipboardUrls = setClipboardUrlsself.setMicaEffectEnabled(False)if sys.platform != "darwin":self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)@@ -183,7 +185,8 @@ class MainWindow(MSFluentWindow):if pageClass is TaskPage:return TaskPage(self._taskService, self._featureService,- self._categoryService, self._speedMeter, self._plan, parent=self,+ self._categoryService, self._speedMeter, self._plan,+ self._setClipboardUrls, parent=self,)if pageClass is SettingPage:return SettingPage(@@ -451,6 +454,9 @@ class MainWindow(MSFluentWindow):QApplication.quit()def dragEnterEvent(self, event) -> None:+ if QApplication.instance().isFileDragActive:+ event.ignore()+ returnif not event.mimeData().hasUrls():event.ignore()return