Work-around unfocused item vew colours with Kantum

This commit is contained in:
Craig Drummond
2017-09-10 14:47:26 +01:00
committed by Craig Drummond
parent 7542b77672
commit 4ee7ee5609
3 changed files with 27 additions and 1 deletions

View File

@@ -136,6 +136,14 @@ public:
cg = QPalette::Inactive;
}
#ifdef Q_OS_LINUX
if (QPalette::Inactive==cg && option.state & QStyle::State_Enabled && parent() && qobject_cast<QWidget *>(parent())) {
QWidget *pw=static_cast<QWidget *>(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();

View File

@@ -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));

View File

@@ -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));