From 4ee7ee5609f01f7ecd9d40de9ab4da618d967f00 Mon Sep 17 00:00:00 2001 From: Craig Drummond Date: Sun, 10 Sep 2017 14:47:26 +0100 Subject: [PATCH] Work-around unfocused item vew colours with Kantum --- support/pagewidget.cpp | 8 ++++++++ widgets/groupedview.cpp | 10 +++++++++- widgets/itemview.cpp | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/support/pagewidget.cpp b/support/pagewidget.cpp index c2c0feece..fc5d9350a 100644 --- a/support/pagewidget.cpp +++ b/support/pagewidget.cpp @@ -136,6 +136,14 @@ public: cg = QPalette::Inactive; } + #ifdef Q_OS_LINUX + if (QPalette::Inactive==cg && option.state & QStyle::State_Enabled && parent() && qobject_cast(parent())) { + QWidget *pw=static_cast(parent()); + if (pw->topLevelWidget() && pw->topLevelWidget()->isActiveWindow()) { + cg = QPalette::Normal; + } + } + #endif QStyleOptionViewItem opt(option); opt.showDecorationSelected = true; QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); diff --git a/widgets/groupedview.cpp b/widgets/groupedview.cpp index 0d7ef1b67..a9dd3c890 100644 --- a/widgets/groupedview.cpp +++ b/widgets/groupedview.cpp @@ -323,7 +323,15 @@ void GroupedViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o #ifdef Q_OS_WIN QColor textColor(option.palette.color(QPalette::Text)); #else - QColor textColor(option.palette.color(option.state&QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text)); + + bool active = option.state&QStyle::State_Active; + #ifdef Q_OS_LINUX + if (!active && view && view->topLevelWidget() && view->topLevelWidget()->isActiveWindow()) { + active=true; + } + #endif + + QColor textColor(option.palette.color(active ? QPalette::Active : QPalette::Inactive, option.state&QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text)); #endif QTextOption textOpt(Qt::AlignVCenter); QRect r(option.rect.adjusted(constBorder+4, constBorder, -(constBorder+4), -constBorder)); diff --git a/widgets/itemview.cpp b/widgets/itemview.cpp index 8d16b4eee..c4bc7ee6f 100644 --- a/widgets/itemview.cpp +++ b/widgets/itemview.cpp @@ -179,6 +179,11 @@ public: bool gtk=mouseOver && GtkStyle::isActive(); bool selected=option.state&QStyle::State_Selected; bool active=option.state&QStyle::State_Active; + #ifdef Q_OS_LINUX + if (!active && itemView() && itemView()->topLevelWidget() && itemView()->topLevelWidget()->isActiveWindow()) { + active=true; + } + #endif bool drawBgnd=true; bool iconMode = view && QListView::IconMode==view->viewMode(); QStyleOptionViewItem opt(option); @@ -436,6 +441,11 @@ public: bool rtl = QApplication::isRightToLeft(); bool selected=option.state&QStyle::State_Selected; bool active=option.state&QStyle::State_Active; + #ifdef Q_OS_LINUX + if (!active && itemView() && itemView()->topLevelWidget() && itemView()->topLevelWidget()->isActiveWindow()) { + active=true; + } + #endif bool mouseOver=underMouse && option.state&QStyle::State_MouseOver; #ifdef Q_OS_WIN QColor textColor(option.palette.color(active ? QPalette::Active : QPalette::Inactive, QPalette::Text));