Views: do not set color to views which don't use our palette
This commit is contained in:
parent
4706f4547c
commit
2d1601fe38
@ -0,0 +1,71 @@
|
|||||||
|
From e5dfd0be75b31dc3b823de0c4bd320b9a6995b89 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Grulich <jgrulich@redhat.com>
|
||||||
|
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<QAbstractItemView> view = qobject_cast<QAbstractItemView *>(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);
|
@ -1,12 +1,14 @@
|
|||||||
Name: adwaita-qt
|
Name: adwaita-qt
|
||||||
Version: 1.1.3
|
Version: 1.1.3
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
Summary: Adwaita theme for Qt-based applications
|
Summary: Adwaita theme for Qt-based applications
|
||||||
|
|
||||||
Url: https://github.com/FedoraQt/adwaita-qt
|
Url: https://github.com/FedoraQt/adwaita-qt
|
||||||
Source0: https://github.com/FedoraQt/adwaita-qt/archive/%{version}/adwaita-qt-%{version}.tar.gz
|
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: cmake
|
||||||
BuildRequires: qt4-devel
|
BuildRequires: qt4-devel
|
||||||
|
|
||||||
@ -74,6 +76,9 @@ make install/fast DESTDIR=%{buildroot} -C "%{_target_platform}-qt5"
|
|||||||
%files
|
%files
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue May 20 2020 Jan Grulich <jgrulich@redhat.com> - 1.1.3-2
|
||||||
|
- Views: do not set color to views which don't use our palette
|
||||||
|
|
||||||
* Fri May 15 2020 Jan Grulich <jgrulich@redhat.com> - 1.1.3-1
|
* Fri May 15 2020 Jan Grulich <jgrulich@redhat.com> - 1.1.3-1
|
||||||
- 1.1.3
|
- 1.1.3
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user