-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library sidebar: expand items to full width to maximize click-responsive area #11708
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
The first attempt was simple but the resize function was called way too often. I consider it helpful but after all it's a hack to compensate for a Qt issue IMO, so I will not fight for getting this merged. Check the first commit only, the 2nd one adds lots of debug output to catch events etc. |
522ecb1
to
6e74192
Compare
Btw I wasted some hours just to discover a QTimer quirk: already queued I'll provide a fix soonish. |
6e74192
to
37b9e54
Compare
This PR is marked as stale because it has been open 90 days with no activity. |
This PR is marked as stale because it has been open 90 days with no activity. |
37b9e54
to
5e25e33
Compare
8ebeda8
to
e177f7c
Compare
e177f7c
to
d650bda
Compare
If polished this and rebased onto main. |
A small UX helper. Works fine without glitches.
Issue
Currently, the sidebar header expands to the width of the widest item.
If the sidebar is wider than that, there's some space right next to items that is not responsive to clicks. This is somewhat frustration as it is perceived inconsistent with the state when e.g. Playlist are expanded and the entire 'Tracks' row responds to clicks.
Desired:
Unfortunately, there's no combination of
header()->setStretchLastSection(true);
header()->setSectionResizeMode(QHeaderView::ResizeMode);
to achieve that.
at least not when set in the constructor. If set later on, e.g. on
QResizeEvent
, it works as desired, though only with collapsed rows. go figure...Probably a Qt issue, or just a use case they didn't know/care about.
Fix
The header, and thereby the rows, are (maybe) adjusted on every
Resize
,LayoutRequest
,FontChange
&Polish
event, when expanding/collapsing items and when item text is changed (eg. playlist renamed, track count changed):setStretchLastSection(false)
to show horizontal scrollbars, ie. no ellipsis in item labelssetStretchLastSection(true)
if sidebar is wider than the widest itemTo avoid unnecessary and redundant adjustments (1), adjust requests are queued and delayed by 50 ms (2) so that only the last queued request is processed.
This is implemented along the drag'n'drop timer events with a lightweight QBasicTimer, so I think this is a compact solution.
(1) this applies in particular to skin creation/first show and manual resizing, eg. while dragging the sidebar splitter, where many events may be sent in quick succession
(2) 50 ms seem to be a good compromise between fast GUI update and long enough wait time for potential follow-up events to reduce adjust requests.
Update can be seen only when expanding from width with h-scrollbars to one without.