Skip to content

Commit

Permalink
Fix too small symbol layer preview icon on hidpi displays
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 16, 2019
1 parent 3c0c253 commit 9014be0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/gui/symbology/qgssymbolselectordialog.cpp
Expand Up @@ -36,6 +36,7 @@
#include "qgssvgcache.h" #include "qgssvgcache.h"
#include "qgsimagecache.h" #include "qgsimagecache.h"
#include "qgsproject.h" #include "qgsproject.h"
#include "qgsguiutils.h"


#include <QColorDialog> #include <QColorDialog>
#include <QPainter> #include <QPainter>
Expand Down Expand Up @@ -147,11 +148,16 @@ class SymbolLayerItem : public QStandardItem


void updatePreview() void updatePreview()
{ {
if ( !mSize.isValid() )
{
const int size = QgsGuiUtils::scaleIconSize( 16 );
mSize = QSize( size, size );
}
QIcon icon; QIcon icon;
if ( mIsLayer ) if ( mIsLayer )
icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( mLayer, QgsUnitTypes::RenderMillimeters, QSize( 16, 16 ) ); //todo: make unit a parameter icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( mLayer, QgsUnitTypes::RenderMillimeters, mSize ); //todo: make unit a parameter
else else
icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSymbol, QSize( 16, 16 ) ); icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSymbol, mSize );
setIcon( icon ); setIcon( icon );


if ( parent() ) if ( parent() )
Expand Down Expand Up @@ -214,6 +220,7 @@ class SymbolLayerItem : public QStandardItem
QgsSymbolLayer *mLayer = nullptr; QgsSymbolLayer *mLayer = nullptr;
QgsSymbol *mSymbol = nullptr; QgsSymbol *mSymbol = nullptr;
bool mIsLayer; bool mIsLayer;
QSize mSize;
}; };


///@endcond ///@endcond
Expand Down

0 comments on commit 9014be0

Please sign in to comment.