change: deck split shows exactly the pinned panels (no leftover column)
Pinning 2 of 3 panels previously showed a 3rd "leftover" tab-column, which read as all-three-pinned and was confusing. Now the split view shows exactly the pinned panels (pin 2 -> 2 columns, pin 3 -> 3). Adds an always-available View > Side-by-side panels submenu of checkable toggles as the way to pin a panel while already in split view (the right-click-tab gesture only works in tabbed mode). Tests assert exactly-N-columns and the menu-pin path; the win fixture now resets deck state so tests don't depend on persisted layout. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,11 @@ def win(app):
|
||||
w = MainWindow()
|
||||
except Exception as e: # GL/mpv/display unavailable, etc.
|
||||
pytest.skip(f"MainWindow could not be constructed here: {e}")
|
||||
# Deterministic deck state regardless of any persisted side-by-side layout
|
||||
# (construction restores deck_pinned from QSettings).
|
||||
for _p in w._deck_panels:
|
||||
_p._pinned = False
|
||||
w._refresh_deck_layout()
|
||||
yield w
|
||||
w.close()
|
||||
w.deleteLater()
|
||||
@@ -63,10 +68,42 @@ def test_deck_stack_exists(win):
|
||||
assert win._deck_stack.currentWidget() is win._control_deck
|
||||
|
||||
|
||||
def test_pinning_two_panels_switches_to_split(win):
|
||||
def _split_columns(win):
|
||||
"""Widgets of the splitter actually mounted in the layout (not findChild,
|
||||
which can return a stale deleteLater'd splitter)."""
|
||||
from PyQt6.QtWidgets import QSplitter
|
||||
item = win._deck_split_layout.itemAt(0)
|
||||
spl = item.widget() if item else None
|
||||
assert isinstance(spl, QSplitter)
|
||||
return [spl.widget(i) for i in range(spl.count())]
|
||||
|
||||
|
||||
def test_pinning_two_panels_shows_exactly_two_columns(win):
|
||||
# Pin two panels directly (avoid the toggle handler so no QSettings write
|
||||
# leaks into other test windows) and refresh.
|
||||
from PyQt6.QtWidgets import QTabWidget
|
||||
win._tab_export._pinned = True
|
||||
win._tab_crop._pinned = True
|
||||
win._refresh_deck_layout()
|
||||
assert win._deck_stack.currentWidget() is win._deck_split_container
|
||||
cols = _split_columns(win)
|
||||
assert len(cols) == 2 # only the pinned ones
|
||||
assert not any(isinstance(c, QTabWidget) for c in cols) # no leftover tab-column
|
||||
|
||||
|
||||
def test_side_by_side_menu_pins_third_panel(win):
|
||||
# In split mode the View ▸ Side-by-side menu is the way to pin a 3rd panel
|
||||
# (there's no tab bar to right-click). Suppress the QSettings save via the
|
||||
# _deck_loading guard so this doesn't leak into other windows.
|
||||
win._tab_export._pinned = True
|
||||
win._tab_scan._pinned = True
|
||||
win._refresh_deck_layout()
|
||||
assert len(_split_columns(win)) == 2
|
||||
act = next(a for a, p in win._deck_pin_actions if p is win._tab_crop)
|
||||
win._deck_loading = True # suppress _save_deck_layout
|
||||
try:
|
||||
act.trigger() # simulate clicking the menu item
|
||||
finally:
|
||||
win._deck_loading = False
|
||||
assert win._tab_crop._pinned is True
|
||||
assert len(_split_columns(win)) == 3
|
||||
|
||||
Reference in New Issue
Block a user