-
-
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
Track Info Dialog: Improve keyboard usability & resize behavior #13818
base: main
Are you sure you want to change the base?
Track Info Dialog: Improve keyboard usability & resize behavior #13818
Conversation
This makes these two labels have the same alignment and pixel position (relative to their input control) as all the other labels in the dialog.
All other similar fields in the dialog are selectable, so this seems to just have been an oversight.
…uts for navigating between tracks
…zing Also fix the sizePolicy of other widgets, such that the "Comments" field gets all available remaining vertical space.
…ler than contents
This is needed to avoid breaking keyboard navigation in a few cases.
The menu is already automatically opened by QPushButton::pressed, no need to do it twice. This caused problems when Enter is used to open the color picker popup.
This PR is marked as stale because it has been open 90 days with no activity. |
Co-authored-by: ronso0 <ronso0@mixxx.org>
Spreadsheets applications implement a similar behavior, so IMO this shouldn't confuse users too much. It's also already implemented in Qt for QPushButton, and mostly intended for power users that are used to other data entry applications.
I think that the differing behavior for |
I can reproduce that behavior (the color button gets taller as the dialog gets wider) for DlgTrackInfoMulti, but not for DlgTrackInfo (using Qt 6.7.3). I'll investigate, should probably be an easy fix. |
I came back to this, and right away I remembered why I left last time: Yes, WMultiLineTextEdit is very helpful for the sizeHint and Up/Down to move focus. But that's about it IMHO (didn't look into WStarRating in detail, yet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments..
if (isReadOnly()) { | ||
option.state |= QStyle::State_ReadOnly; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
just for sake of complete reimplemetation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WMultiLineTextEdit
reuses the rendering primitives from QLineEdit
(instead of QPlainTextEdit
) to get focus highlighting when focus is inside the control.
The default styles for QLineEdit
provide a styling for the read-only state (when QLineEdit::isReadOnly() == true
), and as a user, I would expect WMultiLineTextEdit::isReadOnly()
to behave similarly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so this is indeed
just for sake of complete reimplemetation
because we don't have read-only multi-lineedits (now).
} | ||
|
||
bool WMultiLineTextEdit::event(QEvent* e) { | ||
switch (e->type()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple if (type == QEvent:Paint)
would suffice, less LOC
Or why not override paintEvent()?
|
||
if (!m_upDownChangesFocus || !(isUp || isDown) || | ||
isAutoRepeat || anyModifiersPressed) { | ||
QPlainTextEdit::keyPressEvent(event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I'd be more comfortable with QPlainTextEdit::keyPressEvent(event); return;
here right after every condition that's not met, even if it's more LOC.
Probably starting with modifiers, then event->key() != Qt::Key_Up && event->key() != Qt::Key_Down
, then auto-repeat, then do the fun stuff.
I know all this performs really fast, but still.
Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both alternatives are equally readable, so I don't have a specific preference. I'll rewrite the code as proposed 👍
(As a sidenote, performance should not be a deciding factor here, as this is in no way a hot path).
IIUC, your concerns are related to |
My point is that my POC is 30 LOC (withou debug stuff), and it's not unrelated, it's isolated in edit my new POC 0aa786d also handles the 'no item focused' case, so with that only |
I see your point. I don't have a very strong opinion on this, so I'll refactor the code as proposed. I'll extend your POC to also handle the labels, though, as these can receive keyboard focus when clicked using the mouse, and for consistency (For context, my own usage pattern when I don't see which control currently has the focus is to press |
Why do the labels need to get keyboard focus? |
It's the reverse: The labels can get keyboard focus by clicking on them with the mouse (which is necessary to make it possible to copy their contents to the clipboard). They can't currently be focused via the keyboard, but it should be possible to move focus away from them using the keyboard through the same methods as for the other controls. |
bcb4f4a
to
6cbed55
Compare
Hmm this is supposed to be configured by the TextInteractionFlags. But apparently setting those sets the focus policy to ClickFocus. Interesting is that NoFocus set in ui doesn't make a difference (lable can get focus) but if set in c++ the selected text is not cleared when I select text of another label. Qt.. 🤷♂️ Anyhow, the build is broken currently due to some } and ; missing. Please fixup and force-push, we'd love every commit to be buildable (to ease later git bisect). And Down press now jumps twice because of Will take a look at the code this weekend I think. |
As suggested by ronso0 during code review.
…r via focusField).
6cbed55
to
1ad41c1
Compare
This PR bundles a number of keyboard usability improvements and general polish for the track info dialog.
It combines a number of small changes that are functionally independent and could be split off into their own PRs if necessary, but would likely produce merge conflicts due to most of them affecting the same set of files.
In short, the track info dialog and all of its controls (except for the cover art image) are now easily accessible and usable via the keyboard, tab order matches visual order and small screens/large font sizes are handled more gracefully.
The visual look is only changed minimally (the border style of the comments field now matches the other text fields & the "Import metadata" buttons display an ellipsis when collapsed below their minimum text width & a few pixel-level alignments, see below for details).
(As a sidenote, the changes from #13632 have been integrated).
Summary
The Git history has been rewritten to group related commits together into the following changesets (presented in the chronological order of their Git history):
Add "Last Played" field (2 commits)
Because, why not? This was the only piece of metadata that was available as a column but not shown in the track info dialog. There's space in the layout for it, so let's just add it.
Will be shown as
-
when not present in the track's metadata.General Cleanup (6 commits)
These should all (hopefully) be uncontentious:
QGroupBox
es speaking names instead of auto-generated onesupdateTrackMetatdataFields
dlgtrackinfo.h
.Edit star rating via keyboard (5 commits)
The star rating widget was focusable, but it was not possible to use the keyboard to actually change the rating.
0
,1
, ...,9
key now sets the rating. The result will be clamped to the range0..maxStarCount
(Reason: The existing code internally allows for amaxStarCount
other than5
).+
orRight
key increments the rating.-
orLeft
key increments the rating.As a sidenote, editing the star rating cells in the library table view was suffienctly different to be split into the separate PR #13717.
Improve track list navigation (3 commits)
Navigation within a list of tracks has been improved by adding keyboard shortcuts (
Alt+Left
/Alt+Right
1 2) and conditionally enabling/disabling the prev/next buttons. Focus is kept within the currently focused editor when moving to another track, but any "on focus" behaviours (like selecting all text in a QLineEdit) for the current control are re-triggered.Future work: It is currently not explained (or visually indicated) to the user that navigating to the previous/next track cancels changes made to the current track (like
Escape
orCancel
would do).Resize behaviour (5 commits)
Avoid the minimum size of
WMultiLineTextEdit
(the "Comments" field) jumping to a larger size when the dialog is resized by the user.Text edit widgets: Show the start of the contained text (e.g. the album title) by default instead of the end when the text's length exceeds the widgets width.
Allow the
Import metadata from MusicBrainz
andRe-import metadata from file
to be collapsed to smaller widths by displaying an ellipsis (...
).Keyboard navigation using
Up
/Down
(6 commits)Add
Up
/Down
as an alternative toTab
/Shift+Tab
for moving focus within the track info dialog to make the keyboard experience a bit more seamless.Exception: For the "Comments" control, focus only moves out of the text editor when the cursor is at the very start or end of the content when you start to hold down the corresponding arrow key, i.e. when you are at the start of the "Comments" field and hold down
Down
to move the cursor to the very end, focus does not leave the "Comments" field until you release theDown
key and then press it again.Exception: For the BPM spinner on the second tab,
Up
andDown
retain their original behavior (Note: haven't found a good way to differentiate between the different user intentions here)Edit color picker via keyboard (3 commits)
The color picker popover could be triggered, but not controlled, via the keyboard.
Space
orEnter
on the color picker button triggers the popover and moves focus into the popover.Tab
/Shift+Tab
andUp
/Down
/Left
/Right
can be used to navigate within the color picker popover when it is open.Esc
closes the color picker popover without making a selection.Enter
orSpace
selects the focused color and closes the color picker popover.Tooltip for cover art image (1 commit)
Added a compact tooltip to the cover art image to indicate the available interactions (left click/right click).
Merge & additional cleanup (2 commits)
mixxxdj/mixxx:main
and resolve merge conflicts caused by Track Info dialogs: move metatdata buttons below color picker #13632.meatdata_buttons_layout
->metadata_buttons_layout
wcolorpicker.cpp
Footnotes
Sidenote:
Alt+Left
/Right
was choosen becauseCtrl+Left
/Right
andLeft
/Right
already have a meaning within the text edit widgets. ↩Sidenote:
Alt+Up
/Down
can be added if desired. ↩