Skip to content

Commit 8766cd1

Browse files
committed
Add a platform-specific size hint for QgsColorButtonV2 (refs #11060)
1 parent 31c055d commit 8766cd1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/gui/qgscolorbuttonv2.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ QgsColorButtonV2::~QgsColorButtonV2()
6969
{
7070
}
7171

72+
QSize QgsColorButtonV2::sizeHint() const
73+
{
74+
//make sure height of button looks good under different platforms
75+
#ifdef Q_WS_WIN
76+
return QSize( 120, 22 );
77+
#else
78+
return QSize( 120, 28 );
79+
#endif
80+
}
81+
7282
const QPixmap& QgsColorButtonV2::transparentBackground()
7383
{
7484
static QPixmap transpBkgrd;
@@ -524,7 +534,12 @@ void QgsColorButtonV2::setButtonBackground( const QColor color )
524534
initStyleOption( &opt );
525535
QRect buttonSize = QApplication::style()->subControlRect( QStyle::CC_ToolButton, &opt, QStyle::SC_ToolButton,
526536
this );
527-
mIconSize = QSize( buttonSize.width() - 10, buttonSize.height() - 10 );
537+
//make sure height of icon looks good under different platforms
538+
#ifdef Q_WS_WIN
539+
mIconSize = QSize( buttonSize.width() - 10, height() - 14 );
540+
#else
541+
mIconSize = QSize( buttonSize.width() - 10, height() - 12 );
542+
#endif
528543
}
529544
//create an icon pixmap
530545
QPixmap pixmap( mIconSize );

src/gui/qgscolorbuttonv2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class GUI_EXPORT QgsColorButtonV2: public QToolButton
5353

5454
virtual ~QgsColorButtonV2();
5555

56+
virtual QSize sizeHint() const;
57+
5658
/**Return the currently selected color.
5759
* @returns currently selected color
5860
* @see setColor

0 commit comments

Comments
 (0)