Skip to content

Commit

Permalink
[layer tree] Avoid blurry icons on devices with a pixel ratio != 1
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Oct 15, 2020
1 parent 303e6c8 commit 76cfbab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -13,6 +13,8 @@
* *
***************************************************************************/

#include <QApplication>
#include <QDesktopWidget>
#include <QMimeData>
#include <QTextStream>

Expand Down Expand Up @@ -723,7 +725,10 @@ int QgsLayerTreeModel::scaleIconSize( int standardSize )
{
QFontMetrics fm( ( QFont() ) );
const double scale = 1.1 * standardSize / 24;
return static_cast< int >( std::floor( std::max( Qgis::UI_SCALE_FACTOR * fm.height() * scale, static_cast< double >( standardSize ) ) ) );
int scaledIconSize = static_cast< int >( std::floor( std::max( Qgis::UI_SCALE_FACTOR * fm.height() * scale, static_cast< double >( standardSize ) ) ) );
if ( QApplication::desktop() )
scaledIconSize *= QApplication::desktop()->devicePixelRatio();
return scaledIconSize;
}

void QgsLayerTreeModel::nodeWillAddChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo )
Expand Down

0 comments on commit 76cfbab

Please sign in to comment.