[Client] Pin user list header length to the viewport width (#7158)
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions

* [Client] Pin user list header length to the viewport width

The header stretch mode kept a resize section property, so after any
column grew past the viewport the list carried an invisible horizontal
pan range that scrolled rows sideways without visual feedback

Drop the leftover property so displayed length always equals viewport
width and horizontal panning is impossible

* Show columns 1 and 2

Took 12 minutes

Took 2 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-08-25 06:33:57 +02:00 committed by GitHub
parent 2b7b4e8168
commit e589429bd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -613,7 +613,12 @@ UserListWidget::UserListWidget(TabSupervisor *_tabSupervisor,
userTree->hideColumn(3);
connect(userTree, &QTreeWidget::itemActivated, this, &UserListWidget::userClicked);
userTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
userTree->header()->setStretchLastSection(true);
// QTreeWidget enables stretchLastSection by default. Left on, the hidden
// last section absorbs viewport resizes, the Stretch sections never
// redistribute, and the header keeps a stale length past the viewport —
// an invisible horizontal pan range under ScrollBarAlwaysOff. Disable it
// so the explicit resize modes in applyDisplayMode() own the geometry.
userTree->header()->setStretchLastSection(false);
// Always create timers so callers never segfault on a null deref;
// showPopupForUser / hidePopup already guard against a null userInfoPopup.
@ -930,13 +935,24 @@ void UserListWidget::applyDisplayMode()
{
const bool styled = SettingsCache::instance().appearance().getStyleUserList();
// Both modes must keep the header length at the viewport width: with
// ScrollBarAlwaysOff a nonzero horizontal range is invisible but still
// pans via trackpad gestures, which reads as janky random drift.
if (styled) {
userTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
userTree->hideColumn(1);
userTree->hideColumn(2);
userTree->hideColumn(3);
} else {
userTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
// Bounded widths instead of ResizeToContents: content sizing measures
// the FULL text width while the delegate elides afterwards, so long
// names widened the header past the viewport. Fixed icon columns plus
// a stretched name column keep the range at zero, eliding trims.
userTree->header()->setSectionResizeMode(0, QHeaderView::Fixed);
userTree->header()->resizeSection(0, 24);
userTree->header()->setSectionResizeMode(1, QHeaderView::Fixed);
userTree->header()->resizeSection(1, 22);
userTree->header()->setSectionResizeMode(2, QHeaderView::Stretch);
userTree->showColumn(1);
userTree->showColumn(2);
userTree->hideColumn(3);