19 #include <QStyleFactory>
21 #include <QStyleOption>
22 #include <QApplication>
26 : QProxyStyle( nullptr )
29 const QString appStyle = QApplication::style()->objectName();
30 if ( appStyle == QLatin1String(
"QgsAppStyle" ) )
32 setBaseStyle(
static_cast< QgsAppStyle *
>( QApplication::style() )->clone() );
34 else if ( !appStyle.isEmpty() )
36 if ( QStyle *style = QStyleFactory::create( appStyle ) )
37 setBaseStyle( style );
50 QgsAppStyle::QgsAppStyle(
const QString &base )
51 : QProxyStyle( nullptr )
54 if ( !mBaseStyle.isEmpty() )
56 if ( QStyle *style = QStyleFactory::create( mBaseStyle ) )
57 setBaseStyle( style );
60 setObjectName( QStringLiteral(
"QgsAppStyle" ) );
63 QPixmap QgsAppStyle::generatedIconPixmap( QIcon::Mode iconMode,
const QPixmap &pixmap,
const QStyleOption *opt )
const
69 if ( !pixmap.isNull() )
73 QImage im = pixmap.toImage().convertToFormat( QImage::Format_ARGB32 );
76 return QPixmap::fromImage( im );
87 return QProxyStyle::generatedIconPixmap( iconMode, pixmap, opt );
90 void QgsAppStyle::polish( QWidget *widget )
92 QProxyStyle::polish( widget );
93 #if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID)
94 if ( mBaseStyle.contains( QLatin1String(
"fusion" ), Qt::CaseInsensitive )
95 || mBaseStyle.contains( QLatin1String(
"adwaita" ), Qt::CaseInsensitive ) )
103 QPalette
pal = widget->palette();
104 pal.setColor( QPalette::Inactive, QPalette::Text,
pal.color( QPalette::Active, QPalette::Text ) );
105 pal.setColor( QPalette::Inactive, QPalette::Window,
pal.color( QPalette::Active, QPalette::Window ) );
106 pal.setColor( QPalette::Inactive, QPalette::WindowText,
pal.color( QPalette::Active, QPalette::WindowText ) );
107 pal.setColor( QPalette::Inactive, QPalette::Button,
pal.color( QPalette::Active, QPalette::Button ) );
108 pal.setColor( QPalette::Inactive, QPalette::ButtonText,
pal.color( QPalette::Active, QPalette::ButtonText ) );
109 widget->setPalette(
pal );
114 QProxyStyle *QgsAppStyle::clone()
116 return new QgsAppStyle( mBaseStyle );