]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistwidget.cpp
KItemListWidget: make unfocused alternate background slightly lighter
[dolphin.git] / src / kitemviews / kitemlistwidget.cpp
index cfaf89175260a80670b57da4ad1a150dfe5aa4ef..fb985ba23c67f4cdb9fc419887806e2c2f795129 100644 (file)
@@ -105,7 +105,17 @@ void KItemListWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
     Q_UNUSED(option)
 
     if (m_alternateBackground) {
-        const QColor backgroundColor = m_styleOption.palette.color(QPalette::AlternateBase);
+        QColor backgroundColor = m_styleOption.palette.color(QPalette::AlternateBase);
+        if (!widget->hasFocus()) {
+            QColor baseColor = m_styleOption.palette.color(QPalette::Base);
+            if (baseColor.lightnessF() > 0.5) {
+                // theme seems light
+                backgroundColor = backgroundColor.lighter(101);
+            } else {
+                // theme seems dark
+                backgroundColor = backgroundColor.darker(101);
+            }
+        }
         const QRectF backgroundRect(0, 0, size().width(), size().height());
         painter->fillRect(backgroundRect, backgroundColor);
     }