Skip to content

Commit

Permalink
Fix build for Qt4 by disabling the hack for unfocused QTreeView
Browse files Browse the repository at this point in the history
  • Loading branch information
grulja committed May 11, 2020
1 parent 1f38313 commit 06cfac2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions style/adwaitahelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
#include <QPainterPath>
#include <QStyle>
#include <QWidget>

#if QT_VERSION > 0x050000
#include <QWindow>
#endif

#if ADWAITA_HAVE_X11
#include <QX11Info>
Expand Down Expand Up @@ -59,6 +62,7 @@ class Helper
virtual ~Helper()
{}

#if QT_VERSION > 0x050000
static bool isWindowActive(const QWidget *widget)
{
const QWindow *win = widget ? widget->window()->windowHandle() : nullptr;
Expand All @@ -67,6 +71,7 @@ class Helper
}
return false;
}
#endif

//*@name color utilities
//@{
Expand Down
5 changes: 4 additions & 1 deletion style/adwaitastyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ void Style::polish(QWidget *widget)
}
}

#if QT_VERSION > 0x050000
// HACK to avoid different text color in unfocused views
if (QAbstractItemView *view = qobject_cast<QAbstractItemView *>(widget)) {
QWindow *win = widget ? widget->window()->windowHandle() : nullptr;
Expand All @@ -427,6 +428,7 @@ void Style::polish(QWidget *widget)
}

}
#endif

if (!widget->parent() || !qobject_cast<QWidget *>(widget->parent()) || qobject_cast<QDialog *>(widget) || qobject_cast<QMainWindow *>(widget)) {
addEventFilter(widget);
Expand Down Expand Up @@ -4617,12 +4619,13 @@ bool Style::drawItemViewItemControl(const QStyleOption *option, QPainter *painte
#else
QStyleOptionViewItemV4 op(*vopt);
#endif
#if QT_VERSION > 0x050000
if (_helper->isWindowActive(widget)) {
QPalette palette = op.palette;
palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Active, QPalette::Text));
op.palette = palette;
}

#endif
ParentStyleClass::drawControl(CE_ItemViewItem, &op, painter, widget);

return true;
Expand Down

0 comments on commit 06cfac2

Please sign in to comment.