Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Restrict workaround to adwaita/fusion themes
  • Loading branch information
nyalldawson committed Jan 16, 2022
1 parent 89ec2b3 commit 5314826
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/gui/qgsproxystyle.cpp
Expand Up @@ -89,21 +89,24 @@ QPixmap QgsAppStyle::generatedIconPixmap( QIcon::Mode iconMode, const QPixmap &p
void QgsAppStyle::polish( QWidget *widget )
{
QProxyStyle::polish( widget );

#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID)
// fix broken inactive window coloring applying to unfocused docks or list/tree widgets
// see eg https://github.com/FedoraQt/adwaita-qt/issues/126
// the detection used by themes to determine if a widget belongs to an activated window is fragile, which
// results in unfocused list/tree views or widget children being shown in the "deactivated window" palette coloring.
// Gnome (adwaita) defaults to a coloring which makes widgets looks disabled in this inactive state.
// So the best we can do here is force disable the inactive palette coloring to prevent this unwanted behavior.
QPalette pal = widget->palette();
pal.setColor( QPalette::Inactive, QPalette::Text, pal.color( QPalette::Active, QPalette::Text ) );
pal.setColor( QPalette::Inactive, QPalette::Window, pal.color( QPalette::Active, QPalette::Window ) );
pal.setColor( QPalette::Inactive, QPalette::WindowText, pal.color( QPalette::Active, QPalette::WindowText ) );
pal.setColor( QPalette::Inactive, QPalette::Button, pal.color( QPalette::Active, QPalette::Button ) );
pal.setColor( QPalette::Inactive, QPalette::ButtonText, pal.color( QPalette::Active, QPalette::ButtonText ) );
widget->setPalette( pal );
if ( mBaseStyle.contains( QLatin1String( "fusion" ), Qt::CaseInsensitive )
|| mBaseStyle.contains( QLatin1String( "adwaita" ), Qt::CaseInsensitive ) )
{
// fix broken inactive window coloring applying to unfocused docks or list/tree widgets
// see eg https://github.com/FedoraQt/adwaita-qt/issues/126
// the detection used by themes to determine if a widget belongs to an activated window is fragile, which
// results in unfocused list/tree views or widget children being shown in the "deactivated window" palette coloring.
// Gnome (adwaita) defaults to a coloring which makes widgets looks disabled in this inactive state.
// So the best we can do here is force disable the inactive palette coloring to prevent this unwanted behavior.
QPalette pal = widget->palette();
pal.setColor( QPalette::Inactive, QPalette::Text, pal.color( QPalette::Active, QPalette::Text ) );
pal.setColor( QPalette::Inactive, QPalette::Window, pal.color( QPalette::Active, QPalette::Window ) );
pal.setColor( QPalette::Inactive, QPalette::WindowText, pal.color( QPalette::Active, QPalette::WindowText ) );
pal.setColor( QPalette::Inactive, QPalette::Button, pal.color( QPalette::Active, QPalette::Button ) );
pal.setColor( QPalette::Inactive, QPalette::ButtonText, pal.color( QPalette::Active, QPalette::ButtonText ) );
widget->setPalette( pal );
}
#endif
}

Expand Down

0 comments on commit 5314826

Please sign in to comment.