diff --git a/adwaita-qt-views-do-not-set-colors-to-views-with-custom-colors.patch b/adwaita-qt-views-do-not-set-colors-to-views-with-custom-colors.patch new file mode 100644 index 0000000..8c118af --- /dev/null +++ b/adwaita-qt-views-do-not-set-colors-to-views-with-custom-colors.patch @@ -0,0 +1,71 @@ +From e5dfd0be75b31dc3b823de0c4bd320b9a6995b89 Mon Sep 17 00:00:00 2001 +From: Jan Grulich +Date: Mon, 18 May 2020 12:53:04 +0200 +Subject: [PATCH] Views: do not set color to views which don't use our palette + +--- + style/adwaitastyle.cpp | 41 +++++++++++++++++++---------------------- + 1 file changed, 19 insertions(+), 22 deletions(-) + +diff --git a/style/adwaitastyle.cpp b/style/adwaitastyle.cpp +index c50078f3..7c3e1c28 100644 +--- a/style/adwaitastyle.cpp ++++ b/style/adwaitastyle.cpp +@@ -409,28 +409,19 @@ void Style::polish(QWidget *widget) + + #if QT_VERSION > 0x050000 + // HACK to avoid different text color in unfocused views ++ // This has a side effect that the view will never grey out, but it's still better then having ++ // views greyed out when the application is active + if (QPointer view = qobject_cast(widget)) { +- QWindow *win = widget ? widget->window()->windowHandle() : nullptr; +- if (win) { +- connect(win, &QWindow::activeChanged, this, [=] () { +- if (view.isNull()) { +- return; +- } +- +- QPalette pal = view->palette(); +- if (win->isActive()) { +- pal.setColor(QPalette::Inactive, QPalette::Text, pal.color(QPalette::Active, QPalette::Text)); +- } else { +- polish(pal); +- } +- view->setPalette(pal); +- }); +- +- if (win->isActive()) { +- QMetaObject::invokeMethod(win, "activeChanged", Qt::QueuedConnection); +- } ++ QPalette pal = view->palette(); ++ // TODO keep synced with the standard palette ++ const QColor activeTextColor = _dark ? QColor("#eeeeec") : QColor("#2e3436"); ++ const QColor inactiveTextColor = _dark ? _helper->mix(QColor("#eeeeec"), _helper->darken(_helper->desaturate(QColor("#3d3846"), 1.0), 0.04)) : ++ _helper->mix(QColor("#2e3436"), QColor("#f6f5f4")); ++ // No custom text color used, we can do our HACK ++ if (inactiveTextColor == pal.color(QPalette::Inactive, QPalette::Text) && activeTextColor == pal.color(QPalette::Active, QPalette::Text)) { ++ pal.setColor(QPalette::Inactive, QPalette::Text, pal.color(QPalette::Active, QPalette::Text)); ++ view->setPalette(pal); + } +- + } + #endif + +@@ -4625,9 +4616,15 @@ bool Style::drawItemViewItemControl(const QStyleOption *option, QPainter *painte + #endif + #if QT_VERSION > 0x050000 + if (_helper->isWindowActive(widget)) { ++ const QColor activeTextColor = _dark ? QColor("#eeeeec") : QColor("#2e3436"); ++ const QColor inactiveTextColor = _dark ? _helper->mix(QColor("#eeeeec"), _helper->darken(_helper->desaturate(QColor("#3d3846"), 1.0), 0.04)) : ++ _helper->mix(QColor("#2e3436"), QColor("#f6f5f4")); ++ // No custom text color used, we can do our HACK + QPalette palette = op.palette; +- palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Active, QPalette::Text)); +- op.palette = palette; ++ if (inactiveTextColor == palette.color(QPalette::Inactive, QPalette::Text) && activeTextColor == palette.color(QPalette::Active, QPalette::Text)) { ++ palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Active, QPalette::Text)); ++ op.palette = palette; ++ } + } + #endif + ParentStyleClass::drawControl(CE_ItemViewItem, &op, painter, widget); diff --git a/adwaita-qt.spec b/adwaita-qt.spec index 68286e3..dc6f983 100644 --- a/adwaita-qt.spec +++ b/adwaita-qt.spec @@ -1,12 +1,14 @@ Name: adwaita-qt Version: 1.1.3 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Summary: Adwaita theme for Qt-based applications Url: https://github.com/FedoraQt/adwaita-qt Source0: https://github.com/FedoraQt/adwaita-qt/archive/%{version}/adwaita-qt-%{version}.tar.gz +Patch0: adwaita-qt-views-do-not-set-colors-to-views-with-custom-colors.patch + BuildRequires: cmake BuildRequires: qt4-devel @@ -74,6 +76,9 @@ make install/fast DESTDIR=%{buildroot} -C "%{_target_platform}-qt5" %files %changelog +* Tue May 20 2020 Jan Grulich - 1.1.3-2 +- Views: do not set color to views which don't use our palette + * Fri May 15 2020 Jan Grulich - 1.1.3-1 - 1.1.3