Skip to content

Commit

Permalink
Fix icon sizes on hidpi for SVG fill image selector
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and nirvn committed Mar 18, 2020
1 parent 2a77a6b commit b058ae5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/gui/symbology/qgssymbollayerwidget.cpp
Expand Up @@ -2318,7 +2318,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;

Expand Down Expand Up @@ -2690,6 +2690,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 );
Expand Down Expand Up @@ -2814,7 +2822,7 @@ void QgsSVGFillSymbolLayerWidget::insertIcons()
}

oldModel = mSvgListView->model();
QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView );
QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView, mIconSize );
mSvgListView->setModel( m );
delete oldModel;
}
Expand All @@ -2824,7 +2832,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;

Expand Down
3 changes: 3 additions & 0 deletions src/gui/symbology/qgssymbollayerwidget.h
Expand Up @@ -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;
};

//////////
Expand Down

0 comments on commit b058ae5

Please sign in to comment.