Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix some button sizes on hidpi displays
  • Loading branch information
nyalldawson committed Jul 7, 2017
1 parent e091510 commit eb8f91a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion python/gui/qgscolorbutton.sip
Expand Up @@ -44,7 +44,7 @@ class QgsColorButton : QToolButton
the button will use the global color scheme registry instead
%End

virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;

QColor color() const;
%Docstring
Expand Down
9 changes: 6 additions & 3 deletions src/gui/qgscolorbutton.cpp
Expand Up @@ -68,14 +68,17 @@ QgsColorButton::QgsColorButton( QWidget *parent, const QString &cdt, QgsColorSch
setPopupMode( QToolButton::MenuButtonPopup );
}

QSize QgsColorButton::sizeHint() const
QSize QgsColorButton::minimumSizeHint() const
{
//make sure height of button looks good under different platforms
QSize size;
#ifdef Q_OS_WIN
return QSize( 120, 22 );
size = QSize( 120, 22 );
#else
return QSize( 120, 28 );
size = QSize( 120, 28 );
#endif
int textHeight = fontMetrics().height() * 1.1;
return QSize( size.width(), qMax( size.height(), textHeight ) );
}

const QPixmap &QgsColorButton::transparentBackground()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgscolorbutton.h
Expand Up @@ -76,7 +76,7 @@ class GUI_EXPORT QgsColorButton : public QToolButton
*/
QgsColorButton( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &cdt = "", QgsColorSchemeRegistry *registry = nullptr );

virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;

/** Return the currently selected color.
* \returns currently selected color
Expand Down
8 changes: 3 additions & 5 deletions src/gui/qgsfontbutton.cpp
Expand Up @@ -51,11 +51,9 @@ QgsFontButton::QgsFontButton( QWidget *parent, const QString &dialogTitle )
QSize QgsFontButton::minimumSizeHint() const
{
//make sure height of button looks good under different platforms
#ifdef Q_OS_WIN
return QToolButton::minimumSizeHint();
#else
return QSize( 120, 28 );
#endif
QSize size = QToolButton::minimumSizeHint();
int fontHeight = fontMetrics().height() * 1.4;
return QSize( size.width(), qMax( size.height(), fontHeight ) );
}

void QgsFontButton::showSettingsDialog()
Expand Down

0 comments on commit eb8f91a

Please sign in to comment.