Skip to content

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

fix(notice): 修复下载完成弹窗不会自动消失

XiaoYouChRa1be79c4881d
diff --git a/GLOSSARY.md b/GLOSSARY.md
index c30d6879..77c61198 100644
--- a/GLOSSARY.md
+++ b/GLOSSARY.md
@@ -171,7 +171,7 @@ _Avoid_: worker、thread、chunk
### 用户告知
**Notice**:
-一次性的、需要告知用户的事件。发出即完成,不可撤回也不需要消解。经由 Popup 或系统通知送达,用户在设置里二选一,也可以关闭。
+一次性的、需要告知用户的事件。发出即完成,不可撤回也不需要消解。经由 Popup 或系统通知送达,用户在设置里二选一,也可以关闭。需要用户处理、或错过就无从查起的 Notice 不自动消失,其余的到时自动消失。
_Avoid_: message、alert、event
**Popup**:
@@ -191,7 +191,7 @@ _Avoid_: 配对弹窗
_Avoid_: 剪贴板弹窗
**Task Popup**:
-新建任务第一次开始下载时显示其进度的 Popup,拥有自己的任务栏按钮,按钮显示该任务的文件图标,可最小化。用户可以让它通过弹窗显示,或只显示于任务栏。任务完成或失败时,由不自动关闭的结果提示原地取代。从弹出到用户关闭 Task Popup 或结果提示之前,该任务是被跟踪的任务,它完成时不另发 Notice。
+新建任务第一次开始下载时显示其进度的 Popup,拥有自己的任务栏按钮,按钮显示该任务的文件图标,可最小化。用户可以让它通过弹窗显示,或只显示于任务栏。任务完成或失败时,由结果提示原地取代。从弹出到 Task Popup 或结果提示关闭之前,该任务是被跟踪的任务,它完成时不另发 Notice。
_Avoid_: 进度窗口、progress dialog、下载弹窗
**Pair Token**:
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index 24873f55..f2ec48a2 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -332,7 +332,7 @@ def startApp(application: Application, primaryInstance: PrimaryInstance, isSilen
if popupNotifier is not None and popupStack is not None and popupStack.has(popupId):
if not cfg.isNoticeSoundEnabled.value:
notice = replace(notice, sound=None)
- popupNotifier.send(replace(notice, timeout=0), popupId)
+ popupNotifier.send(notice, popupId)
return
sendNotice(notice)
diff --git a/app/platform/desktop_notification.py b/app/platform/desktop_notification.py
index d170bf25..ab4fb73b 100644
--- a/app/platform/desktop_notification.py
+++ b/app/platform/desktop_notification.py
@@ -111,6 +111,7 @@ def buildDiskSpaceInsufficient(free: int, needed: int, activate: Callable[[], No
toReadableSize(free), toReadableSize(needed)),
urgency=Urgency.Critical,
on_clicked=activate,
+ timeout=0,
)
@@ -122,6 +123,7 @@ def buildParseFailed(url: str, error: TaskError, activate: Callable[[], None]) -
message=f"{url}\n{toLocalizedError(error)}",
urgency=Urgency.Critical,
on_clicked=activate,
+ timeout=0,
)
diff --git a/tests/test_notice.py b/tests/test_notice.py
index 5880c598..e390fa65 100644
--- a/tests/test_notice.py
+++ b/tests/test_notice.py
@@ -68,6 +68,7 @@ def test_build_error_notices_activate_window_on_click():
assert diskSpace.message.splitlines()[0] == "任务未自动开始"
assert parseFailed.message.splitlines()[0] == "https://example.com/a"
assert diskSpace.urgency == parseFailed.urgency == Urgency.Critical
+ assert diskSpace.timeout == parseFailed.timeout == 0
diskSpace.on_clicked()
parseFailed.on_clicked()
assert activated == ["disk", "parse"]
@@ -163,6 +164,16 @@ def test_send_replaces_notice_in_place(qtbot, popupNotifier):
assert dismissed == []
+def test_send_replacing_with_timeout_dismisses_after_duration(qtbot, popupNotifier):
+ popupNotifier.send(buildNotice("进度", timeout=0), "task:1")
+ qtbot.waitUntil(lambda: len(shownPopups()) == 1 and isSettled())
+
+ popupNotifier.send(buildNotice("完成", timeout=1), "task:1")
+
+ qtbot.waitUntil(lambda: [p.titleLabel.text() for p in shownPopups()] == ["完成"])
+ qtbot.waitUntil(lambda: not shownPopups(), timeout=3000)
+
+
def test_add_replacing_takes_position_without_dismissing(qtbot, popupStack):
dismissed = []
old = NotificationPopup(buildNotice("进度", timeout=0, on_dismissed=lambda: dismissed.append(True)))