mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-14 20:16:09 -05:00
[Client] Pin user list header length to the viewport width (#7158)
Some checks failed
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
Build Desktop / Configure (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 44 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Servatrice_Debian 12 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 26 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
Build Docker / Servatrice (arm) (push) Has been cancelled
Build Docker / Servatrice (x86) (push) Has been cancelled
Build Docker / Publish multi-platform Servatrice image (push) Has been cancelled
Some checks failed
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
Build Desktop / Configure (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 44 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Servatrice_Debian 12 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 26 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
Build Docker / Servatrice (arm) (push) Has been cancelled
Build Docker / Servatrice (x86) (push) Has been cancelled
Build Docker / Publish multi-platform Servatrice image (push) Has been cancelled
* [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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user