Skip to content

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

修复 Windows 平台上缩放导致的托盘菜单重叠问题;修复无法暂停的 Bug (#42)

XiaoYouChR253003dfb084
diff --git a/app/common/download_task.py b/app/common/download_task.py
index 19927168..b941bf5b 100644
--- a/app/common/download_task.py
+++ b/app/common/download_task.py
@@ -73,6 +73,7 @@ class DownloadTask(QThread):
def __init__(self, url, maxBlockNum: int = 8, filePath=None, fileName=None, parent=None):
super().__init__(parent)
+ self.isStop = False
self.process = 0
self.url = url
self.fileName = fileName
@@ -88,6 +89,8 @@ class DownloadTask(QThread):
self.__tempThread.start()
def __reassignWorker(self, task: Task):
+ if self.isStop:
+ return
# 找到剩余进度最多的线程
maxRemainder = 0
@@ -286,8 +289,6 @@ class DownloadTask(QThread):
self.file.close()
self.ghdFile.close()
- print("File closed.")
-
if self.process == self.fileSize:
# 删除历史记录文件
try:
@@ -304,16 +305,28 @@ class DownloadTask(QThread):
self.gotWrong.emit(repr(e))
def stop(self):
+ self.isStop = True
+
for task in self.tasks:
task.cancel()
# 关闭
- self.supervisorTask.cancel()
- self.file.close()
- self.ghdFile.close()
+ try:
+ self.supervisorTask.cancel()
+ finally:
+ self.file.close()
+ self.ghdFile.close()
while not all(task.done() for task in self.tasks): # 等待所有任务完成
- time.sleep(0.01)
+ for task in self.tasks:
+ try:
+ task.cancel()
+ except RuntimeError:
+ pass
+ except Exception as e:
+ raise e
+
+ time.sleep(0.05)
# @retry(3, 0.1)
def run(self):
diff --git a/app/components/custom_tray.py b/app/components/custom_tray.py
index 16b135fc..b1dbc2bf 100644
--- a/app/components/custom_tray.py
+++ b/app/components/custom_tray.py
@@ -1,4 +1,3 @@
-from PySide6.QtCore import QRect
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QSystemTrayIcon, QApplication
from qfluentwidgets import Action
@@ -23,7 +22,7 @@ class FixedAcrylicSystemTrayMenu(AcrylicMenu):
def showEvent(self, e):
super().showEvent(e)
self.adjustPosition()
- self.view.acrylicBrush.grabImage(QRect(self.pos() + self.view.pos(), self.view.size()))
+ # self.view.acrylicBrush.grabImage(QRect(self.pos() + self.view.pos(), self.view.size()))
class CustomSystemTrayIcon(QSystemTrayIcon):
diff --git a/app/view/main_window.py b/app/view/main_window.py
index a46132d0..f295f55f 100644
--- a/app/view/main_window.py
+++ b/app/view/main_window.py
@@ -131,7 +131,7 @@ class MainWindow(MSFluentWindow):
self.windowEffect.removeBackgroundEffect(self.winId())
if cfg.backgroundEffect.value == 'Acrylic':
- self.windowEffect.setAcrylicEffect(self.winId(), "F2F2F230" if darkdetect.isDark() else "00000030")
+ self.windowEffect.setAcrylicEffect(self.winId(), "00000030" if darkdetect.isDark() else "F2F2F230")
elif cfg.backgroundEffect.value == 'Mica':
self.windowEffect.setMicaEffect(self.winId(), darkdetect.isDark())
elif cfg.backgroundEffect.value == 'MicaBlur':