Drop refactor re-export shims, update imports to canonical locations
Final commit of the gui/app.py + gui/preview.py structural refactor.
Updates the four call sites that were importing through the
preview.py / app.py shims to import from each entity's canonical
sibling module instead, then deletes the now-empty shim files.
Edits:
- main_gui.py:38 from booru_viewer.gui.app import run
→ from booru_viewer.gui.app_runtime import run
- main_window.py:44 from .preview import ImagePreview
→ from .preview_pane import ImagePreview
- main_window.py:1133 from .preview import VIDEO_EXTENSIONS
→ from .media.constants import VIDEO_EXTENSIONS
- main_window.py:2061 from .preview import FullscreenPreview
→ from .popout.window import FullscreenPreview
- main_window.py:2135 from .preview import FullscreenPreview
→ from .popout.window import FullscreenPreview
Deleted:
- booru_viewer/gui/app.py
- booru_viewer/gui/preview.py
Final gui/ tree:
gui/
__init__.py (unchanged, empty)
app_runtime.py entry point + style loader
main_window.py BooruApp QMainWindow
preview_pane.py ImagePreview embedded preview
info_panel.py InfoPanel widget
log_handler.py LogHandler (Qt-aware logger adapter)
async_signals.py AsyncSignals signal hub
search_state.py SearchState dataclass
media/
__init__.py
constants.py VIDEO_EXTENSIONS, _is_video
image_viewer.py ImageViewer (zoom/pan)
mpv_gl.py _MpvGLWidget, _MpvOpenGLSurface
video_player.py VideoPlayer + _ClickSeekSlider
popout/
__init__.py
viewport.py Viewport NamedTuple, _DRIFT_TOLERANCE
window.py FullscreenPreview popout window
grid.py, bookmarks.py, library.py, search.py, sites.py,
settings.py, dialogs.py (all untouched)
Net result for the refactor: 2 god-files (app.py 3608 lines +
preview.py 2273 lines = 5881 lines mixing every concern) replaced
by 12 small clean modules + 2 oversize-by-design god-class files
(main_window.py and popout/window.py — see docs/REFACTOR_PLAN.md
for the indivisible-class rationale).
Followups discovered during execution are recorded in
docs/REFACTOR_NOTES.md (gitignored, local-only).
This commit is contained in:
parent
af1715708b
commit
c4efdb76f8
@ -1,60 +0,0 @@
|
||||
"""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
|
||||
@ -41,7 +41,7 @@ from ..core.cache import download_image, download_thumbnail, cache_size_bytes, e
|
||||
from ..core.config import MEDIA_EXTENSIONS
|
||||
|
||||
from .grid import ThumbnailGrid
|
||||
from .preview import ImagePreview
|
||||
from .preview_pane import ImagePreview
|
||||
from .search import SearchBar
|
||||
from .sites import SiteManagerDialog
|
||||
from .bookmarks import BookmarksView
|
||||
@ -1130,7 +1130,7 @@ class BooruApp(QMainWindow):
|
||||
# the entire multi-MB file to land. Cached videos go through
|
||||
# the normal flow because the local path is already there.
|
||||
from ..core.cache import is_cached
|
||||
from .preview import VIDEO_EXTENSIONS
|
||||
from .media.constants import VIDEO_EXTENSIONS
|
||||
is_video = bool(
|
||||
post.file_url
|
||||
and Path(post.file_url.split('?')[0]).suffix.lower() in VIDEO_EXTENSIONS
|
||||
@ -2058,7 +2058,7 @@ class BooruApp(QMainWindow):
|
||||
idx = self._grid.selected_index
|
||||
if 0 <= idx < len(self._posts):
|
||||
self._info_panel.set_post(self._posts[idx])
|
||||
from .preview import FullscreenPreview
|
||||
from .popout.window import FullscreenPreview
|
||||
# Restore persisted window state
|
||||
saved_geo = self._db.get_setting("slideshow_geometry")
|
||||
saved_fs = self._db.get_setting_bool("slideshow_fullscreen")
|
||||
@ -2132,7 +2132,7 @@ class BooruApp(QMainWindow):
|
||||
def _on_fullscreen_closed(self) -> None:
|
||||
# Persist popout window state to DB
|
||||
if self._fullscreen_window:
|
||||
from .preview import FullscreenPreview
|
||||
from .popout.window import FullscreenPreview
|
||||
fs = FullscreenPreview._saved_fullscreen
|
||||
geo = FullscreenPreview._saved_geometry
|
||||
self._db.set_setting("slideshow_fullscreen", "1" if fs else "0")
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
"""Full media preview — image viewer with zoom/pan and video player."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple
|
||||
|
||||
from PySide6.QtCore import Qt, QPointF, QRect, Signal, QTimer, Property
|
||||
from PySide6.QtGui import QPixmap, QPainter, QWheelEvent, QMouseEvent, QKeyEvent, QMovie, QColor
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QHBoxLayout, QLabel, QMainWindow,
|
||||
QStackedWidget, QPushButton, QSlider, QMenu, QInputDialog, QStyle,
|
||||
)
|
||||
|
||||
import mpv as mpvlib
|
||||
|
||||
_log = logging.getLogger("booru")
|
||||
|
||||
|
||||
# -- Refactor compatibility shims (deleted in commit 14) --
|
||||
from .media.constants import VIDEO_EXTENSIONS, _is_video # re-export for refactor compat
|
||||
from .popout.viewport import Viewport, _DRIFT_TOLERANCE # re-export for refactor compat
|
||||
from .media.image_viewer import ImageViewer # re-export for refactor compat
|
||||
from .media.mpv_gl import _MpvGLWidget, _MpvOpenGLSurface # re-export for refactor compat
|
||||
from .media.video_player import _ClickSeekSlider, VideoPlayer # re-export for refactor compat
|
||||
from .popout.window import FullscreenPreview # re-export for refactor compat
|
||||
from .preview_pane import ImagePreview # re-export for refactor compat
|
||||
@ -35,7 +35,7 @@ def main() -> None:
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
from booru_viewer.gui.app import run
|
||||
from booru_viewer.gui.app_runtime import run
|
||||
run()
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user