Blend pixel history widget background color with selection color

Before, if a row was selected, the color was completely replaced, which
makes the color preview column completely useless for that row.

This change also fixes some inconsistencies with how the selection hover
works on tree widgets; previously part of the row was not highlighted.
This commit is contained in:
William Pearson
2023-07-28 15:30:37 -07:00
committed by Baldur Karlsson
parent 71e886cecc
commit afb4d76dd2
2 changed files with 24 additions and 15 deletions
+19 -3
View File
@@ -1551,9 +1551,25 @@ void RDStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *opt, Q
group = QPalette::Inactive;
if(viewitem->state & QStyle::State_Selected)
p->fillRect(viewitem->rect, viewitem->palette.brush(group, QPalette::Highlight));
else if(viewitem->backgroundBrush.style() != Qt::NoBrush)
p->fillRect(viewitem->rect, viewitem->backgroundBrush);
{
if(viewitem->backgroundBrush.style() != Qt::NoBrush)
{
p->fillRect(viewitem->rect, viewitem->backgroundBrush);
// If we have a custom color, use the selection color at half opacity over the custom color
QColor col = viewitem->palette.color(group, QPalette::Highlight);
col.setAlphaF(0.5f);
p->fillRect(viewitem->rect, QBrush(col));
}
else
{
p->fillRect(viewitem->rect, viewitem->palette.brush(group, QPalette::Highlight));
}
}
else
{
if(viewitem->backgroundBrush.style() != Qt::NoBrush)
p->fillRect(viewitem->rect, viewitem->backgroundBrush);
}
return;
}
+5 -12
View File
@@ -771,18 +771,11 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
idx = idx.parent();
}
opt.rect = rect;
opt.rect.setWidth(depth * indentation());
opt.rect = allLinesRect;
opt.showDecorationSelected = true;
opt.backgroundBrush = index.data(Qt::BackgroundRole).value<QBrush>();
style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, this);
QBrush back = index.data(Qt::BackgroundRole).value<QBrush>();
if(!selectionModel()->isSelected(index) && back.style() != Qt::NoBrush)
{
painter->fillRect(allLinesRect, back);
}
if(m_VisibleBranches)
{
QTreeView::drawBranches(painter, rect, index);
@@ -821,12 +814,12 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
{
parent = parents.pop();
back = parent.data(RDTreeView::TreeLineColorRole).value<QBrush>();
QBrush line = parent.data(RDTreeView::TreeLineColorRole).value<QBrush>();
if(back.style() != Qt::NoBrush)
if(line.style() != Qt::NoBrush)
{
// draw a centred pen vertically down the middle of branchRect
painter->setPen(QPen(QBrush(back), m_treeColorLineWidth));
painter->setPen(QPen(line, m_treeColorLineWidth));
QPoint topCentre = QRect(branchRect).center();
QPoint bottomCentre = topCentre;