Skip to content
Permalink
Browse files

Fix some button sizes on hidpi displays

  • Loading branch information
nyalldawson committed Jul 7, 2017
1 parent e091510 commit eb8f91a55677b2e9118210871ab27ca847364ec2
Showing with 11 additions and 10 deletions.
  1. +1 −1 python/gui/qgscolorbutton.sip
  2. +6 −3 src/gui/qgscolorbutton.cpp
  3. +1 −1 src/gui/qgscolorbutton.h
  4. +3 −5 src/gui/qgsfontbutton.cpp
@@ -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
@@ -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()
@@ -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
@@ -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()

0 comments on commit eb8f91a

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