-
-
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
fix glitch in Star rating #12582
fix glitch in Star rating #12582
Conversation
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.
Thank you for taking care for this long standing bug. I need to do also manual tests.
Back to draft, I discovered other small issues. |
01f4f02
to
ed9de2b
Compare
Okay, this is now a roundhouse kick as it fixes the mentioned issues for all star ratings (decks, Track Info, library). And it's horizontally centered if the parent is wider that the rating. And, no need to rush, this can easily go to 2.4.1 |
For WStarRating testing purpose I amend a TEST commit that makes the deck rating in LateNight a bit wider. |
src/library/stardelegate.cpp
Outdated
@@ -54,8 +54,9 @@ QWidget* StarDelegate::createEditor(QWidget* parent, | |||
void StarDelegate::setEditorData(QWidget* editor, | |||
const QModelIndex& index) const { | |||
StarRating starRating = index.data().value<StarRating>(); | |||
int stars = index.model()->data(index, Qt::ToolTipRole).toInt(); |
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.
Why not using starRating.starCount()
?
I am afraid that the tooltip may change and breaker the code here.
If there is a reason, please add a comment.
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.
Hmm, so i didn't fully understand the StarRating class. index.model()->data(Qt::EditRole | Qt::TooltipRol | Qt::UserRole + 2)
should all return the QVariant(rawValue.toInt()). But it's always 0.
Anyway, you're right, starCount()
is it.
0834a4e
to
065d8b5
Compare
That's not working reliably, probably due varying order of events? Like, on right click, sometimes the editor receives a LeaveEvent, sometimes it doesn't (for the same cell, tracks view unchanged). |
move duplicate starAtPosition() to shared class StarRating
to simplify maintenance a bit. Catch QEvent::ContextMenu, too, to reliably reset the rating on right-click.
no need for this to be static. Less lines, easier to grasp.
a helper for visual consistency, the editor isn't actually be focused.
065d8b5
to
5045d2f
Compare
Yup, with
This has grown beyond a quick fix, so no stress to squeeze this into 2.4.0 |
5045d2f
to
bff3f2a
Compare
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.
Works perfectly and LGTM. Thank you very much for fixing alsohttps://github.com//issues/7304 form 2014
Ups, the TEST commit went again in. Sorry. |
Great, thanks for testing! The test commit, forgot to request changes myself, I'll probably go with the Draft state next time. |
(even though it works for other editors, the latter requires a hack if the editor is also selected)
(if parent is wider than the rating, e.g. stretched library column)
Bonus:
(if parent is wider, else still left-aligned and can be truncated)
Fixes apply to both WStarRating (decks, Track Info) and the library's StarDelegate/StarEditor.
I moved redundant code to StarRating, and some more small improvements along the way.
star-rating-fix.webm
Fixes #12576 #7304