Skip to content
Permalink
Browse files

Only apply device pixel ratio in scaleIconSize for tested use

  • Loading branch information
nirvn committed Oct 16, 2020
1 parent 746ee31 commit c606cf8b6104cf0347970436aac2a58bb9ae6902
@@ -937,7 +937,7 @@ Set a single custom expression variable.
.. versionadded:: 3.0
%End

static int scaleIconSize( int standardSize );
static int scaleIconSize( int standardSize, bool applyDevicePixelRatio = false );
%Docstring
Scales an icon size to compensate for display pixel density, making the icon
size hi-dpi friendly, whilst still resulting in pixel-perfect sizes for low-dpi
@@ -721,7 +721,7 @@ void QgsLayerTreeModel::setLayerStyleOverrides( const QMap<QString, QString> &ov

int QgsLayerTreeModel::scaleIconSize( int standardSize )
{
return QgsApplication::scaleIconSize( standardSize );
return QgsApplication::scaleIconSize( standardSize, true );
}

void QgsLayerTreeModel::nodeWillAddChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo )
@@ -75,7 +75,6 @@

#include "layout/qgspagesizeregistry.h"

#include <QApplication>
#include <QDesktopWidget>
#include <QDir>
#include <QFile>
@@ -1822,12 +1821,12 @@ void QgsApplication::setCustomVariable( const QString &name, const QVariant &val
emit instance()->customVariablesChanged();
}

int QgsApplication::scaleIconSize( int standardSize )
int QgsApplication::scaleIconSize( int standardSize, bool applyDevicePixelRatio )
{
QFontMetrics fm( ( QFont() ) );
const double scale = 1.1 * standardSize / 24;
int scaledIconSize = static_cast< int >( std::floor( std::max( Qgis::UI_SCALE_FACTOR * fm.height() * scale, static_cast< double >( standardSize ) ) ) );
if ( QApplication::desktop() )
if ( applyDevicePixelRatio && QApplication::desktop() )
scaledIconSize *= QApplication::desktop()->devicePixelRatio();
return scaledIconSize;
}
@@ -880,7 +880,7 @@ class CORE_EXPORT QgsApplication : public QApplication
*
* \since QGIS 3.16
*/
static int scaleIconSize( int standardSize );
static int scaleIconSize( int standardSize, bool applyDevicePixelRatio = false );

/**
* The maximum number of concurrent connections per connections pool.

0 comments on commit c606cf8

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