Blame adwaita-qt-views-do-not-set-colors-to-views-with-custom-colors.patch

2d1601f
diff --git a/style/adwaitastyle.cpp b/style/adwaitastyle.cpp
f0d2b6e
index c50078f..7c3e1c2 100644
2d1601f
--- a/style/adwaitastyle.cpp
2d1601f
+++ b/style/adwaitastyle.cpp
2d1601f
@@ -409,28 +409,19 @@ void Style::polish(QWidget *widget)
2d1601f
 
2d1601f
 #if QT_VERSION > 0x050000
2d1601f
     // HACK to avoid different text color in unfocused views
2d1601f
+    // This has a side effect that the view will never grey out, but it's still better then having
2d1601f
+    // views greyed out when the application is active
2d1601f
     if (QPointer<QAbstractItemView> view = qobject_cast<QAbstractItemView *>(widget)) {
2d1601f
-        QWindow *win = widget ? widget->window()->windowHandle() : nullptr;
2d1601f
-        if (win) {
2d1601f
-            connect(win, &QWindow::activeChanged, this, [=] () {
2d1601f
-                if (view.isNull()) {
2d1601f
-                    return;
2d1601f
-                }
2d1601f
-
2d1601f
-                QPalette pal = view->palette();
2d1601f
-                if (win->isActive()) {
2d1601f
-                    pal.setColor(QPalette::Inactive, QPalette::Text, pal.color(QPalette::Active, QPalette::Text));
2d1601f
-                } else {
2d1601f
-                    polish(pal);
2d1601f
-                }
2d1601f
-                view->setPalette(pal);
2d1601f
-            });
2d1601f
-
2d1601f
-            if (win->isActive()) {
2d1601f
-                QMetaObject::invokeMethod(win, "activeChanged", Qt::QueuedConnection);
2d1601f
-            }
2d1601f
+        QPalette pal = view->palette();
2d1601f
+        // TODO keep synced with the standard palette
2d1601f
+        const QColor activeTextColor = _dark ? QColor("#eeeeec") : QColor("#2e3436");
2d1601f
+        const QColor inactiveTextColor = _dark ? _helper->mix(QColor("#eeeeec"), _helper->darken(_helper->desaturate(QColor("#3d3846"), 1.0), 0.04)) :
2d1601f
+                                                 _helper->mix(QColor("#2e3436"), QColor("#f6f5f4"));
2d1601f
+        // No custom text color used, we can do our HACK
2d1601f
+        if (inactiveTextColor == pal.color(QPalette::Inactive, QPalette::Text) && activeTextColor == pal.color(QPalette::Active, QPalette::Text)) {
2d1601f
+            pal.setColor(QPalette::Inactive, QPalette::Text, pal.color(QPalette::Active, QPalette::Text));
2d1601f
+            view->setPalette(pal);
2d1601f
         }
2d1601f
-
2d1601f
     }
2d1601f
 #endif
2d1601f
 
2d1601f
@@ -4625,9 +4616,15 @@ bool Style::drawItemViewItemControl(const QStyleOption *option, QPainter *painte
2d1601f
 #endif
2d1601f
 #if QT_VERSION > 0x050000
2d1601f
     if (_helper->isWindowActive(widget)) {
2d1601f
+        const QColor activeTextColor = _dark ? QColor("#eeeeec") : QColor("#2e3436");
2d1601f
+        const QColor inactiveTextColor = _dark ? _helper->mix(QColor("#eeeeec"), _helper->darken(_helper->desaturate(QColor("#3d3846"), 1.0), 0.04)) :
2d1601f
+                                                 _helper->mix(QColor("#2e3436"), QColor("#f6f5f4"));
2d1601f
+        // No custom text color used, we can do our HACK
2d1601f
         QPalette palette = op.palette;
2d1601f
-        palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Active, QPalette::Text));
2d1601f
-        op.palette = palette;
2d1601f
+        if (inactiveTextColor == palette.color(QPalette::Inactive, QPalette::Text) && activeTextColor == palette.color(QPalette::Active, QPalette::Text)) {
2d1601f
+            palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Active, QPalette::Text));
2d1601f
+            op.palette = palette;
2d1601f
+        }
2d1601f
     }
2d1601f
 #endif
f0d2b6e
     ParentStyleClass::drawControl(CE_ItemViewItem, &op, painter, widget);