Skip to content

Commit 1ca3f4b

Browse files
committed
[themes] Allow customization of palette role colors
This fixes the following issues: - combo box drop down menu white top/bottom edges - color button header background color - white line at top of stacked dock area
1 parent 76941de commit 1ca3f4b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/core/qgsapplication.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "qgsrasterrendererregistry.h"
3737
#include "qgsrendererregistry.h"
3838
#include "qgssymbollayerregistry.h"
39+
#include "qgssymbollayerutils.h"
3940
#include "qgspluginlayerregistry.h"
4041
#include "qgsmessagelog.h"
4142
#include "qgsannotationregistry.h"
@@ -759,6 +760,28 @@ void QgsApplication::setUITheme( const QString &themeName )
759760
file.close();
760761

761762
qApp->setStyleSheet( styledata );
763+
764+
QFile palettefile( path + "/palette.txt" );
765+
QFileInfo paletteInfo( palettefile );
766+
if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
767+
{
768+
QPalette pal = qApp->palette();
769+
QTextStream in( &palettefile );
770+
while ( !in.atEnd() )
771+
{
772+
QString line = in.readLine();
773+
QStringList parts = line.split( ':' );
774+
if ( parts.count() == 2 )
775+
{
776+
int role = parts.at( 0 ).trimmed().toInt();
777+
QColor color = QgsSymbolLayerUtils::decodeColor( parts.at( 1 ).trimmed() );
778+
pal.setColor( static_cast< QPalette::ColorRole >( role ), color );
779+
}
780+
}
781+
palettefile.close();
782+
qApp->setPalette( pal );
783+
}
784+
762785
setThemeName( themeName );
763786
}
764787

0 commit comments

Comments
 (0)