main_window: live-apply thumbnail size and flip layout

Thumbnail size change now resizes all existing thumbnails from their
source pixmap and reflows all three grids immediately. No restart
needed.

Flip layout change now swaps the splitter widget order live.

behavior change: thumbnail size and preview-on-left settings apply
instantly via Apply/Save instead of requiring a restart.
This commit is contained in:
pax 2026-04-11 22:26:31 -05:00
parent 9592830e67
commit 14033b57b5

View File

@ -1028,12 +1028,31 @@ class BooruApp(QMainWindow):
if lib_dir: if lib_dir:
from ..core.config import set_library_dir from ..core.config import set_library_dir
set_library_dir(Path(lib_dir)) set_library_dir(Path(lib_dir))
# Apply thumbnail size # Apply thumbnail size live — update the module constant, resize
# existing thumbnails, and reflow the grid.
from .grid import THUMB_SIZE from .grid import THUMB_SIZE
new_size = self._db.get_setting_int("thumbnail_size") new_size = self._db.get_setting_int("thumbnail_size")
if new_size and new_size != THUMB_SIZE: if new_size and new_size != THUMB_SIZE:
import booru_viewer.gui.grid as grid_mod import booru_viewer.gui.grid as grid_mod
grid_mod.THUMB_SIZE = new_size grid_mod.THUMB_SIZE = new_size
for grid in (self._grid, self._bookmarks_view._grid, self._library_view._grid):
for thumb in grid._thumbs:
thumb.setFixedSize(new_size, new_size)
if thumb._source_pixmap:
thumb._pixmap = thumb._source_pixmap.scaled(
new_size - 4, new_size - 4,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation,
)
thumb.update()
grid._flow._do_layout()
# Apply flip layout live
flip = self._db.get_setting_bool("flip_layout")
current_first = self._splitter.widget(0)
want_right_first = flip
right_is_first = current_first is self._right_splitter
if want_right_first != right_is_first:
self._splitter.insertWidget(0, self._right_splitter if flip else self._stack)
self._status.showMessage("Settings applied") self._status.showMessage("Settings applied")
# -- Fullscreen & Privacy -- # -- Fullscreen & Privacy --