diff --git a/booru_viewer/gui/media_controller.py b/booru_viewer/gui/media_controller.py index cb0ecdd..aaf6b18 100644 --- a/booru_viewer/gui/media_controller.py +++ b/booru_viewer/gui/media_controller.py @@ -7,8 +7,6 @@ import logging from pathlib import Path from typing import TYPE_CHECKING -from PySide6.QtGui import QPixmap - from ..core.cache import download_image, cache_size_bytes, evict_oldest, evict_oldest_thumbnails if TYPE_CHECKING: @@ -265,6 +263,7 @@ class MediaController: if _is_video(path): return 0, 0 try: + from PySide6.QtGui import QPixmap pix = QPixmap(path) if not pix.isNull(): return pix.width(), pix.height() diff --git a/booru_viewer/gui/post_actions.py b/booru_viewer/gui/post_actions.py index 31ccc0a..034a709 100644 --- a/booru_viewer/gui/post_actions.py +++ b/booru_viewer/gui/post_actions.py @@ -6,8 +6,6 @@ import logging from pathlib import Path from typing import TYPE_CHECKING -from PySide6.QtWidgets import QMessageBox - from ..core.cache import download_image if TYPE_CHECKING: @@ -163,6 +161,7 @@ class PostActionsController: self._app._popout_ctrl.update_state() def blacklist_tag_from_popout(self, tag: str) -> None: + from PySide6.QtWidgets import QMessageBox reply = QMessageBox.question( self._app, "Blacklist Tag", f"Blacklist tag \"{tag}\"?\nPosts with this tag will be hidden.", @@ -178,6 +177,7 @@ class PostActionsController: def blacklist_post_from_popout(self) -> None: post, idx = self.get_preview_post() if post: + from PySide6.QtWidgets import QMessageBox reply = QMessageBox.question( self._app, "Blacklist Post", f"Blacklist post #{post.id}?\nThis post will be hidden from results.", diff --git a/booru_viewer/gui/search_controller.py b/booru_viewer/gui/search_controller.py index 1e10ba8..0ed9db3 100644 --- a/booru_viewer/gui/search_controller.py +++ b/booru_viewer/gui/search_controller.py @@ -6,10 +6,6 @@ import asyncio import logging from typing import TYPE_CHECKING -from PySide6.QtCore import QTimer -from PySide6.QtGui import QPixmap -from PySide6.QtWidgets import QApplication - from .search_state import SearchState if TYPE_CHECKING: @@ -293,6 +289,7 @@ class SearchController: self._app._next_page_btn.setVisible(not at_end) thumbs = self._app._grid.set_posts(len(posts)) self._app._grid.scroll_to_top() + from PySide6.QtCore import QTimer QTimer.singleShot(100, self.clear_loading) from ..core.config import saved_dir @@ -410,6 +407,7 @@ class SearchController: def on_scroll_range_changed(self, _min: int, max_val: int) -> None: """Scrollbar range changed (resize/splitter) -- check if viewport needs filling.""" if max_val == 0 and self._infinite_scroll and self._app._posts: + from PySide6.QtCore import QTimer QTimer.singleShot(100, self.check_viewport_fill) def check_viewport_fill(self) -> None: @@ -417,6 +415,7 @@ class SearchController: if not self._infinite_scroll or self._loading or self._search.infinite_exhausted: return self._app._grid.widget().updateGeometry() + from PySide6.QtWidgets import QApplication QApplication.processEvents() sb = self._app._grid.verticalScrollBar() if sb.maximum() == 0 and self._app._posts: @@ -434,6 +433,7 @@ class SearchController: ss.infinite_exhausted = True self._app._status.showMessage(f"{len(self._app._posts)} results (end)") else: + from PySide6.QtCore import QTimer QTimer.singleShot(100, self.check_viewport_fill) return if ss.infinite_last_page > self._current_page: @@ -501,6 +501,7 @@ class SearchController: self._app._run_async(_download) def on_thumb_done(self, index: int, path: str) -> None: + from PySide6.QtGui import QPixmap thumbs = self._app._grid._thumbs if 0 <= index < len(thumbs): pix = QPixmap(path) diff --git a/booru_viewer/gui/window_state.py b/booru_viewer/gui/window_state.py index 9c4f962..4e0407e 100644 --- a/booru_viewer/gui/window_state.py +++ b/booru_viewer/gui/window_state.py @@ -8,8 +8,6 @@ import os import subprocess from typing import TYPE_CHECKING -from PySide6.QtCore import QTimer - if TYPE_CHECKING: from .main_window import BooruApp @@ -252,6 +250,7 @@ class WindowStateController: return # Slight delay so the window is registered before we try to find # its address. The popout uses the same pattern. + from PySide6.QtCore import QTimer QTimer.singleShot( 50, lambda: self.hyprctl_apply_main_state(x, y, w, h, was_floating) )