Skip to content
Permalink
Browse files

Followup 2ec0513, fix incorrect styling of some GUI elements

  • Loading branch information
nyalldawson committed Dec 31, 2018
1 parent 84d155e commit 0d5219413679a8fd1cb86e4714b7f88d1dc6cc69
Showing with 26 additions and 4 deletions.
  1. +16 −4 src/gui/qgsproxystyle.cpp
  2. +10 −0 src/gui/qgsproxystyle.h
@@ -24,8 +24,12 @@ QgsProxyStyle::QgsProxyStyle( QWidget *parent )
: QProxyStyle( nullptr ) // no base style yet - it transfers ownership, so we need a NEW QStyle object for the base style
{
// get application style
QString appStyle = QApplication::style()->objectName();
if ( !appStyle.isEmpty() )
const QString appStyle = QApplication::style()->objectName();
if ( appStyle == QLatin1String( "QgsAppStyle" ) )
{
setBaseStyle( static_cast< QgsAppStyle * >( QApplication::style() )->clone() );
}
else if ( !appStyle.isEmpty() )
{
if ( QStyle *style = QStyleFactory::create( appStyle ) )
setBaseStyle( style );
@@ -43,12 +47,15 @@ QgsProxyStyle::QgsProxyStyle( QWidget *parent )

QgsAppStyle::QgsAppStyle( const QString &base )
: QProxyStyle( nullptr ) // no base style yet - it transfers ownership, so we need a NEW QStyle object for the base style
, mBaseStyle( base )
{
if ( !base.isEmpty() )
if ( !mBaseStyle.isEmpty() )
{
if ( QStyle *style = QStyleFactory::create( base ) )
if ( QStyle *style = QStyleFactory::create( mBaseStyle ) )
setBaseStyle( style );
}

setObjectName( QStringLiteral( "QgsAppStyle" ) );
}

QPixmap QgsAppStyle::generatedIconPixmap( QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt ) const
@@ -74,4 +81,9 @@ QPixmap QgsAppStyle::generatedIconPixmap( QIcon::Mode iconMode, const QPixmap &p
return QProxyStyle::generatedIconPixmap( iconMode, pixmap, opt );
}

QProxyStyle *QgsAppStyle::clone()
{
return new QgsAppStyle( mBaseStyle );
}

///@endcond
@@ -57,6 +57,16 @@ class GUI_EXPORT QgsAppStyle : public QProxyStyle
explicit QgsAppStyle( const QString &base );
QPixmap generatedIconPixmap( QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt ) const override;

/**
* Returns a new QgsAppStyle instance, with the same base style as this instance.
*
* Caller takes ownership of the returned object.
*/
QProxyStyle *clone() SIP_FACTORY;

private:

QString mBaseStyle;
};

#endif

0 comments on commit 0d52194

Please sign in to comment.
You can’t perform that action at this time.