17#include "moc_qgsproxystyle.cpp"
20#include <QStyleFactory>
22#include <QStyleOption>
23#include <QApplication>
27 : QProxyStyle( nullptr )
30 const QString appStyle = QApplication::style()->objectName();
31 if ( appStyle == QLatin1String(
"QgsAppStyle" ) )
33 setBaseStyle(
static_cast< QgsAppStyle *
>( QApplication::style() )->clone() );
35 else if ( !appStyle.isEmpty() )
37 if ( QStyle *style = QStyleFactory::create( appStyle ) )
38 setBaseStyle( style );
51QgsAppStyle::QgsAppStyle(
const QString &base )
52 : QProxyStyle( nullptr )
55 if ( !mBaseStyle.isEmpty() )
57 if ( QStyle *style = QStyleFactory::create( mBaseStyle ) )
58 setBaseStyle( style );
61 setObjectName( QStringLiteral(
"QgsAppStyle" ) );
64QPixmap QgsAppStyle::generatedIconPixmap( QIcon::Mode iconMode,
const QPixmap &pixmap,
const QStyleOption *opt )
const
70 if ( !pixmap.isNull() )
74 QImage im = pixmap.toImage().convertToFormat( QImage::Format_ARGB32 );
77 return QPixmap::fromImage( im );
88 return QProxyStyle::generatedIconPixmap( iconMode, pixmap, opt );
91void QgsAppStyle::polish( QWidget *widget )
93 QProxyStyle::polish( widget );
94#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID)
95 if ( mBaseStyle.contains( QLatin1String(
"fusion" ), Qt::CaseInsensitive )
96 || mBaseStyle.contains( QLatin1String(
"adwaita" ), Qt::CaseInsensitive ) )
104 QPalette
pal = widget->palette();
105 pal.setColor( QPalette::Inactive, QPalette::Text,
pal.color( QPalette::Active, QPalette::Text ) );
106 pal.setColor( QPalette::Inactive, QPalette::Window,
pal.color( QPalette::Active, QPalette::Window ) );
107 pal.setColor( QPalette::Inactive, QPalette::WindowText,
pal.color( QPalette::Active, QPalette::WindowText ) );
108 pal.setColor( QPalette::Inactive, QPalette::Button,
pal.color( QPalette::Active, QPalette::Button ) );
109 pal.setColor( QPalette::Inactive, QPalette::ButtonText,
pal.color( QPalette::Active, QPalette::ButtonText ) );
110 widget->setPalette(
pal );
115QProxyStyle *QgsAppStyle::clone()
117 return new QgsAppStyle( mBaseStyle );
static void adjustHueSaturation(QImage &image, double saturation, const QColor &colorizeColor=QColor(), double colorizeStrength=1.0, QgsFeedback *feedback=nullptr)
Alter the hue or saturation of a QImage.
static void multiplyOpacity(QImage &image, double factor, QgsFeedback *feedback=nullptr)
Multiplies opacity of image pixel values by a factor.
QgsProxyStyle(QWidget *parent)
Constructor for QgsProxyStyle.