nodeview: added light gradient to node item
This commit is contained in:
@@ -261,8 +261,25 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
Color node_color = Config::Current()[QStringLiteral("NodeCatColor%1")
|
||||
.arg(node_->Category().first())].value<Color>();
|
||||
|
||||
QLinearGradient grad;
|
||||
|
||||
grad.setStart(0, rect().top());
|
||||
grad.setFinalStop(0, rect().bottom());
|
||||
|
||||
QColor node_color_as_qcolor = node_color.toQColor();
|
||||
|
||||
{
|
||||
// Generate lighter color for gradient
|
||||
qreal hue, sat, lightness;
|
||||
node_color_as_qcolor.getHslF(&hue, &sat, &lightness);
|
||||
lightness = qMin(1.0, lightness + 0.2);
|
||||
grad.setColorAt(0.0, QColor::fromHslF(hue, sat, lightness));
|
||||
}
|
||||
|
||||
grad.setColorAt(1.0, node_color_as_qcolor);
|
||||
|
||||
painter->setPen(Qt::black);
|
||||
painter->setBrush(node_color.toQColor());
|
||||
painter->setBrush(grad);
|
||||
|
||||
painter->drawRect(title_bar_rect_);
|
||||
|
||||
@@ -308,7 +325,7 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
}
|
||||
|
||||
// Determine the text color (automatically calculate from node background color)
|
||||
if (node_color.GetRoughLuminance() > 0.66) {
|
||||
if (node_color.GetRoughLuminance() > 0.5) {
|
||||
painter->setPen(Qt::black);
|
||||
} else {
|
||||
painter->setPen(Qt::white);
|
||||
|
||||
Reference in New Issue
Block a user