Skip to content

Commit

Permalink
Add a platform-specific size hint for QgsColorButtonV2 (refs #11060)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 25, 2014
1 parent 31c055d commit 8766cd1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/gui/qgscolorbuttonv2.cpp
Expand Up @@ -69,6 +69,16 @@ QgsColorButtonV2::~QgsColorButtonV2()
{
}

QSize QgsColorButtonV2::sizeHint() const
{
//make sure height of button looks good under different platforms
#ifdef Q_WS_WIN
return QSize( 120, 22 );
#else
return QSize( 120, 28 );
#endif
}

const QPixmap& QgsColorButtonV2::transparentBackground()
{
static QPixmap transpBkgrd;
Expand Down Expand Up @@ -524,7 +534,12 @@ void QgsColorButtonV2::setButtonBackground( const QColor color )
initStyleOption( &opt );
QRect buttonSize = QApplication::style()->subControlRect( QStyle::CC_ToolButton, &opt, QStyle::SC_ToolButton,
this );
mIconSize = QSize( buttonSize.width() - 10, buttonSize.height() - 10 );
//make sure height of icon looks good under different platforms
#ifdef Q_WS_WIN
mIconSize = QSize( buttonSize.width() - 10, height() - 14 );
#else
mIconSize = QSize( buttonSize.width() - 10, height() - 12 );
#endif
}
//create an icon pixmap
QPixmap pixmap( mIconSize );
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgscolorbuttonv2.h
Expand Up @@ -53,6 +53,8 @@ class GUI_EXPORT QgsColorButtonV2: public QToolButton

virtual ~QgsColorButtonV2();

virtual QSize sizeHint() const;

/**Return the currently selected color.
* @returns currently selected color
* @see setColor
Expand Down

0 comments on commit 8766cd1

Please sign in to comment.