Stop the rail destinations sliding to the middle when it collapses
The scroll body holds [nav, RECENTS header, RECENTS], and RECENTS carries the only stretch factor. Collapsing hides it, which leaves a fixed-height nav tree (app.py sets one per row count) and nothing that can expand — so the box layout centred what was left and the destinations dropped 297px down a 1048px window, with the same gap opening below them. A stretch spacer at the foot of the body takes the slack instead. It takes none of it while RECENTS is visible, because RECENTS carries stretch 1 against its 0, so the open rail is byte-for-byte what it was. This is what "thu gọn menu lại ra giữa" meant, reported three times. I read it as horizontal each time and measured x — which was 4px and correct throughout. The report was about the vertical axis and I never checked it. check_rail_align now measures the gap between the + button and the first destination in both states: 6px/6px now, 6px/223px with the spacer removed. 15/15 checkers pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
cb03bc1494
commit
ac29f519cc
@@ -285,6 +285,12 @@ class MainWindow(QMainWindow):
|
|||||||
self.nav_recents = self._new_nav_tree("navRecents")
|
self.nav_recents = self._new_nav_tree("navRecents")
|
||||||
self.nav_recents.itemClicked.connect(self._on_rail_recent)
|
self.nav_recents.itemClicked.connect(self._on_rail_recent)
|
||||||
sv.addWidget(self.nav_recents, 1)
|
sv.addWidget(self.nav_recents, 1)
|
||||||
|
# Collapsing hides RECENTS, and with it the only item carrying a stretch
|
||||||
|
# factor. A box layout with nothing left to expand centres what remains,
|
||||||
|
# so the destinations dropped ~300px down the rail — "thu gọn menu lại
|
||||||
|
# ra giữa". This spacer takes the slack instead, and takes none of it
|
||||||
|
# while RECENTS is visible (stretch 0 against its 1).
|
||||||
|
sv.addStretch(0)
|
||||||
self._nav_scroll.setWidget(scroll_body)
|
self._nav_scroll.setWidget(scroll_body)
|
||||||
nvl.addWidget(self._nav_scroll, 1)
|
nvl.addWidget(self._nav_scroll, 1)
|
||||||
# Bottom-pinned group: the places you visit occasionally, kept out of the
|
# Bottom-pinned group: the places you visit occasionally, kept out of the
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ def main() -> int:
|
|||||||
app.processEvents()
|
app.processEvents()
|
||||||
fails += compare(theme_name, rail, opened, closed)
|
fails += compare(theme_name, rail, opened, closed)
|
||||||
fails += column_widths_do_not_move_icons(win, app, theme_name)
|
fails += column_widths_do_not_move_icons(win, app, theme_name)
|
||||||
|
fails += rows_stay_under_the_header(win, app, theme_name)
|
||||||
|
|
||||||
print()
|
print()
|
||||||
for f in fails:
|
for f in fails:
|
||||||
@@ -150,6 +151,35 @@ def main() -> int:
|
|||||||
os._exit(1 if fails else 0)
|
os._exit(1 if fails else 0)
|
||||||
|
|
||||||
|
|
||||||
|
def rows_stay_under_the_header(win, app, theme_name):
|
||||||
|
"""The destinations start just below the + button in both states.
|
||||||
|
|
||||||
|
Collapsing hides RECENTS, the one item in the scroll body with a stretch
|
||||||
|
factor. With nothing left to expand, a box layout centres what remains, and
|
||||||
|
the whole group slid ~300px down the rail.
|
||||||
|
"""
|
||||||
|
from PySide6.QtCore import QPoint
|
||||||
|
|
||||||
|
rail = win._nav_wrap
|
||||||
|
gaps = {}
|
||||||
|
for state in ("open", "collapsed"):
|
||||||
|
if (state == "collapsed") != win._nav_collapsed:
|
||||||
|
win._toggle_nav()
|
||||||
|
app.processEvents()
|
||||||
|
btn = win.nav_new_chat
|
||||||
|
below = btn.mapTo(rail, QPoint(0, btn.height())).y()
|
||||||
|
top = win.nav.mapTo(rail, QPoint(0, 0)).y() + win.nav.visualItemRect(win.nav.topLevelItem(0)).top()
|
||||||
|
gaps[state] = top - below
|
||||||
|
if win._nav_collapsed:
|
||||||
|
win._toggle_nav()
|
||||||
|
app.processEvents()
|
||||||
|
print(f" gap under +: open={gaps['open']}px collapsed={gaps['collapsed']}px")
|
||||||
|
if abs(gaps["collapsed"] - gaps["open"]) > 4:
|
||||||
|
return [f"{theme_name}: the destinations sit {gaps['collapsed']}px below "
|
||||||
|
f"the + button when collapsed but {gaps['open']}px when open"]
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def column_widths_do_not_move_icons(win, app, theme_name):
|
def column_widths_do_not_move_icons(win, app, theme_name):
|
||||||
"""The icon must not care how wide the column is.
|
"""The icon must not care how wide the column is.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user