From 9d99ecfcb5118c003e4a22386702d1ea2b347d56 Mon Sep 17 00:00:00 2001 From: pax Date: Wed, 8 Apr 2026 14:36:57 -0500 Subject: [PATCH] Move AsyncSignals from app.py to async_signals.py (no behavior change) Step 10 of the gui/app.py + gui/preview.py structural refactor. Pure copy: the QObject signal hub that BooruApp uses to marshal async worker results back to the GUI thread moves to its own module. All 14 signals are preserved verbatim. app.py grows another shim line so internal `AsyncSignals()` references in BooruApp keep working. Shim removed in commit 14. --- booru_viewer/gui/app.py | 25 +------------------------ booru_viewer/gui/async_signals.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 booru_viewer/gui/async_signals.py diff --git a/booru_viewer/gui/app.py b/booru_viewer/gui/app.py index 4de9ea6..b8480b9 100644 --- a/booru_viewer/gui/app.py +++ b/booru_viewer/gui/app.py @@ -51,30 +51,6 @@ from .settings import SettingsDialog log = logging.getLogger("booru") -class AsyncSignals(QObject): - """Signals for async worker results.""" - search_done = Signal(list) - search_append = Signal(list) - search_error = Signal(str) - thumb_done = Signal(int, str) - image_done = Signal(str, str) - image_error = Signal(str) - # Fast-path for uncached video posts: emit the remote URL directly - # so mpv can start streaming + decoding immediately instead of - # waiting for download_image to write the whole file to disk first. - # download_image still runs in parallel to populate the cache for - # next time. Args: (url, info, width, height) — width/height come - # from post.width/post.height for the popout pre-fit optimization. - video_stream = Signal(str, str, int, int) - bookmark_done = Signal(int, str) - bookmark_error = Signal(str) - autocomplete_done = Signal(list) - batch_progress = Signal(int, int) # current, total - batch_done = Signal(str) - download_progress = Signal(int, int) # bytes_downloaded, total_bytes - prefetch_progress = Signal(int, float) # index, progress (0-1 or -1 to hide) - - # -- Info Panel -- class InfoPanel(QWidget): @@ -3577,3 +3553,4 @@ def run() -> None: # -- Refactor compatibility shims (deleted in commit 14) -- from .search_state import SearchState # re-export for refactor compat from .log_handler import LogHandler # re-export for refactor compat +from .async_signals import AsyncSignals # re-export for refactor compat diff --git a/booru_viewer/gui/async_signals.py b/booru_viewer/gui/async_signals.py new file mode 100644 index 0000000..9ae7920 --- /dev/null +++ b/booru_viewer/gui/async_signals.py @@ -0,0 +1,29 @@ +"""Qt signal hub for async worker results.""" + +from __future__ import annotations + +from PySide6.QtCore import QObject, Signal + + +class AsyncSignals(QObject): + """Signals for async worker results.""" + search_done = Signal(list) + search_append = Signal(list) + search_error = Signal(str) + thumb_done = Signal(int, str) + image_done = Signal(str, str) + image_error = Signal(str) + # Fast-path for uncached video posts: emit the remote URL directly + # so mpv can start streaming + decoding immediately instead of + # waiting for download_image to write the whole file to disk first. + # download_image still runs in parallel to populate the cache for + # next time. Args: (url, info, width, height) — width/height come + # from post.width/post.height for the popout pre-fit optimization. + video_stream = Signal(str, str, int, int) + bookmark_done = Signal(int, str) + bookmark_error = Signal(str) + autocomplete_done = Signal(list) + batch_progress = Signal(int, int) # current, total + batch_done = Signal(str) + download_progress = Signal(int, int) # bytes_downloaded, total_bytes + prefetch_progress = Signal(int, float) # index, progress (0-1 or -1 to hide)