Step 13 of the gui/app.py + gui/preview.py structural refactor — final move out of app.py. The four entry-point helpers move together because they're a tightly-coupled cluster: run() calls all three of the others (_apply_windows_dark_mode, _load_user_qss, _BASE_POPOUT_OVERLAY_QSS). Splitting them across commits would just add bookkeeping overhead with no bisect benefit. app_runtime.py imports BooruApp from main_window for run()'s instantiation site, plus Qt at module level (the nested _DarkArrowStyle class inside run() needs Qt.PenStyle.NoPen at call time). Otherwise the four helpers are byte-identical to their app.py originals. After this commit app.py is just the original imports header + log + the shim block — every entity that used to live in it now lives in its canonical module. main_gui.py still imports from booru_viewer.gui.app via the shim (`from .app_runtime import run` re-exports it). Commit 14 swaps main_gui.py to the canonical path and deletes app.py.
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
"""Main Qt6 application window."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import logging
|
|
import os
|
|
import sys
|
|
import threading
|
|
from pathlib import Path
|
|
|
|
from PySide6.QtCore import Qt, QTimer, Signal, QObject, QUrl, Property
|
|
from PySide6.QtGui import QPixmap, QAction, QKeySequence, QDesktopServices, QShortcut, QColor
|
|
from PySide6.QtWidgets import (
|
|
QApplication,
|
|
QMainWindow,
|
|
QWidget,
|
|
QVBoxLayout,
|
|
QHBoxLayout,
|
|
QStackedWidget,
|
|
QComboBox,
|
|
QLabel,
|
|
QPushButton,
|
|
QStatusBar,
|
|
QSplitter,
|
|
QMessageBox,
|
|
QTextEdit,
|
|
QMenu,
|
|
QFileDialog,
|
|
QSpinBox,
|
|
QScrollArea,
|
|
QProgressBar,
|
|
)
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from ..core.db import Database, Site
|
|
from ..core.api.base import BooruClient, Post
|
|
from ..core.api.detect import client_for_type
|
|
from ..core.cache import download_image, download_thumbnail, cache_size_bytes, evict_oldest, evict_oldest_thumbnails
|
|
from ..core.config import MEDIA_EXTENSIONS
|
|
|
|
from .grid import ThumbnailGrid
|
|
from .preview import ImagePreview
|
|
from .search import SearchBar
|
|
from .sites import SiteManagerDialog
|
|
from .bookmarks import BookmarksView
|
|
from .library import LibraryView
|
|
from .settings import SettingsDialog
|
|
|
|
log = logging.getLogger("booru")
|
|
|
|
|
|
# -- 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
|
|
from .info_panel import InfoPanel # re-export for refactor compat
|
|
from .main_window import BooruApp # re-export for refactor compat
|
|
from .app_runtime import run # re-export for refactor compat
|