Skip to content
Permalink
Browse files

Fix data defined button icon size on hidpi screens

  • Loading branch information
nyalldawson committed Nov 27, 2017
1 parent 60a56c3 commit 149e331d2c440904677163baa842383e0e56de00
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/gui/qgspropertyoverridebutton.cpp
@@ -38,10 +38,14 @@ QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent,
{
setFocusPolicy( Qt::StrongFocus );

// set default tool button icon properties
setFixedSize( 30, 26 );
// icon size is a bit bigger than text, but minimum size of 24 so that we get pixel-aligned rendering on low-dpi screens
int iconSize = std::floor( std::max( Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 1.1, 24.0 ) );

// button width is 1.25 * icon size, height 1.1 * icon size. But we round to ensure even pixel sizes for equal margins
setFixedSize( 2 * static_cast< int >( 1.25 * iconSize / 2.0 ), 2 * static_cast< int >( iconSize * 1.1 / 2.0 ) );
setStyleSheet( QStringLiteral( "QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) );
setIconSize( QSize( 24, 24 ) );

setIconSize( QSize( iconSize, iconSize ) );
setPopupMode( QToolButton::InstantPopup );

connect( this, &QgsPropertyOverrideButton::activated, this, &QgsPropertyOverrideButton::updateSiblingWidgets );

0 comments on commit 149e331

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