Make TableView rendering consistent with what Qt native does#84
Make TableView rendering consistent with what Qt native does#84dunkelstern wants to merge 2 commits into
Conversation
|
|
Thanks, I'll have a you at your PR :) |
| 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.
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.
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.
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 :) |
|
Hello @dunkelstern any news? |
|
@dunkelstern any news? |



This Pull request changes a few things on rendering
ItemViewsandHeaderSections:Qt::BackgroundRolebackground color role for table view cells. It falls back to qlementine's own method if it cannot pull aQStyleOptionViewItemfrom theoptItem.fontMetricsof theQStyleOption. This means it honorsQt::FontRoleof 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:
