Skip to content
Permalink
Browse files

Fix icon sizes on hidpi for SVG fill image selector

  • Loading branch information
nyalldawson committed Mar 17, 2020
1 parent 433d401 commit eab16883caab6755bda34ecb0e0299c30b7820d7
Showing with 14 additions and 3 deletions.
  1. +11 −3 src/gui/symbology/qgssymbollayerwidget.cpp
  2. +3 −0 src/gui/symbology/qgssymbollayerwidget.h
@@ -2336,7 +2336,7 @@ void QgsSvgMarkerSymbolLayerWidget::populateIcons( const QModelIndex &idx )
QString path = idx.data( Qt::UserRole + 1 ).toString();

QAbstractItemModel *oldModel = viewImages->model();
QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( viewImages, path );
QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( viewImages, path, mIconSize );
viewImages->setModel( m );
delete oldModel;

@@ -2708,6 +2708,14 @@ QgsSVGFillSymbolLayerWidget::QgsSVGFillSymbolLayerWidget( QgsVectorLayer *vl, QW
mSvgStrokeWidthUnitWidget->setUnits( QgsUnitTypes::RenderUnitList() << QgsUnitTypes::RenderMillimeters << QgsUnitTypes::RenderMetersInMapUnits << QgsUnitTypes::RenderMapUnits << QgsUnitTypes::RenderPixels
<< QgsUnitTypes::RenderPoints << QgsUnitTypes::RenderInches );
mSvgTreeView->setHeaderHidden( true );

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
mIconSize = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 4 ) ) );
#else
mIconSize = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 4 ) ) );
#endif
mSvgListView->setGridSize( QSize( mIconSize * 1.2, mIconSize * 1.2 ) );

insertIcons();

mRotationSpinBox->setClearValue( 0.0 );
@@ -2832,7 +2840,7 @@ void QgsSVGFillSymbolLayerWidget::insertIcons()
}

oldModel = mSvgListView->model();
QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView );
QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView, mIconSize );
mSvgListView->setModel( m );
delete oldModel;
}
@@ -2842,7 +2850,7 @@ void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex &idx )
QString path = idx.data( Qt::UserRole + 1 ).toString();

QAbstractItemModel *oldModel = mSvgListView->model();
QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView, path );
QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView, path, mIconSize );
mSvgListView->setModel( m );
delete oldModel;

@@ -793,6 +793,9 @@ class GUI_EXPORT QgsSVGFillSymbolLayerWidget : public QgsSymbolLayerWidget, priv
void mStrokeWidthSpinBox_valueChanged( double d );
void mTextureWidthUnitWidget_changed();
void mSvgStrokeWidthUnitWidget_changed();

private:
int mIconSize = 30;
};

//////////

0 comments on commit eab1688

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