-
Notifications
You must be signed in to change notification settings - Fork 21
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
Make TableView rendering consistent with what Qt native does #84
base: dev
Are you sure you want to change the base?
Make TableView rendering consistent with what Qt native does #84
Conversation
|
Thanks, I'll have a you at your PR :) |
@@ -861,8 +861,31 @@ void QlementineStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption* opt | |||
const auto focus = | |||
widgetHasFocus && selection == SelectionState::Selected ? FocusState::Focused : FocusState::NotFocused; | |||
const auto active = getActiveState(itemState); | |||
const auto& color = listItemBackgroundColor(mouse, selection, focus, active, optItem->index, w); | |||
p->fillRect(rect, color); | |||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem*>(opt)) { |
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.
Please use auto
as much as possible 😊
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem*>(opt)) { | |
if (const auto *vopt = qstyleoption_cast<const QStyleOptionViewItem*>(opt)) { |
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.
Btw, why do you cast again opt
? It's already made a few lines above?
So the code in the else
statement will never be called... So you broke the styling made by Qlementine.
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) | ||
cg = QPalette::Inactive; |
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.
Please use brackets 😊
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) | |
cg = QPalette::Inactive; | |
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) { | |
cg = QPalette::Inactive; | |
} |
I made some small code style remarks. I'll build your branch later and check if anything is broken visually or not. And if it works, I'll merge it :) thanks again! |
I investigated what you did and I have some interrogations. |
Also, please follow the lib's coding style, use clang-format to format the files. (You may run |
Will update the PR in the next days, thanks for the feedback :) |
This Pull request changes a few things on rendering
ItemViews
andHeaderSections
:Qt::BackgroundRole
background color role for table view cells. It falls back to qlementine's own method if it cannot pull aQStyleOptionViewItem
from theoptItem
.fontMetrics
of theQStyleOption
. This means it honorsQt::FontRole
of the item model and makes auto-sizing of table cells and headers possible again.I am not sure if the changed size calculation breaks something, I for one could not see anything strange happening.
Why the change? It allows something like this:
