|
19 | 19 | #include <QStyle>
|
20 | 20 | #include <QStyleOption>
|
21 | 21 | #include <QApplication>
|
| 22 | +#include <QWindow> |
22 | 23 |
|
23 | 24 | QgsProxyStyle::QgsProxyStyle( QWidget *parent )
|
24 | 25 | : QProxyStyle( nullptr ) // no base style yet - it transfers ownership, so we need a NEW QStyle object for the base style
|
@@ -85,6 +86,27 @@ QPixmap QgsAppStyle::generatedIconPixmap( QIcon::Mode iconMode, const QPixmap &p
|
85 | 86 | return QProxyStyle::generatedIconPixmap( iconMode, pixmap, opt );
|
86 | 87 | }
|
87 | 88 |
|
| 89 | +void QgsAppStyle::polish( QWidget *widget ) |
| 90 | +{ |
| 91 | + QProxyStyle::polish( widget ); |
| 92 | + |
| 93 | +#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) |
| 94 | + // fix broken inactive window coloring applying to unfocused docks or list/tree widgets |
| 95 | + // see eg https://github.com/FedoraQt/adwaita-qt/issues/126 |
| 96 | + // the detection used by themes to determine if a widget belongs to an activated window is fragile, which |
| 97 | + // results in unfocused list/tree views or widget children being shown in the "deactivated window" palette coloring. |
| 98 | + // Gnome (adwaita) defaults to a coloring which makes widgets looks disabled in this inactive state. |
| 99 | + // So the best we can do here is force disable the inactive palette coloring to prevent this unwanted behavior. |
| 100 | + QPalette pal = widget->palette(); |
| 101 | + pal.setColor( QPalette::Inactive, QPalette::Text, pal.color( QPalette::Active, QPalette::Text ) ); |
| 102 | + pal.setColor( QPalette::Inactive, QPalette::Window, pal.color( QPalette::Active, QPalette::Window ) ); |
| 103 | + pal.setColor( QPalette::Inactive, QPalette::WindowText, pal.color( QPalette::Active, QPalette::WindowText ) ); |
| 104 | + pal.setColor( QPalette::Inactive, QPalette::Button, pal.color( QPalette::Active, QPalette::Button ) ); |
| 105 | + pal.setColor( QPalette::Inactive, QPalette::ButtonText, pal.color( QPalette::Active, QPalette::ButtonText ) ); |
| 106 | + widget->setPalette( pal ); |
| 107 | +#endif |
| 108 | +} |
| 109 | + |
88 | 110 | QProxyStyle *QgsAppStyle::clone()
|
89 | 111 | {
|
90 | 112 | return new QgsAppStyle( mBaseStyle );
|
|
0 commit comments