Skip to content

Commit

Permalink
Fix data defined button icon size on hidpi screens
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 27, 2017
1 parent 60a56c3 commit 149e331
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/gui/qgspropertyoverridebutton.cpp 100644 → 100755
Expand Up @@ -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 );
Expand Down

0 comments on commit 149e331

Please sign in to comment.