Skip to content

Commit

Permalink
Fix size of some color widgets on hidpi displays
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 25, 2017
1 parent aacc316 commit f121286
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/gui/qgscolorwidgets.cpp
Expand Up @@ -397,7 +397,8 @@ QgsColorWheel::~QgsColorWheel()

QSize QgsColorWheel::sizeHint() const
{
return QSize( 200, 200 );
int size = fontMetrics().width( QStringLiteral( "XXXXXXXXXXXXXXXXXXXXXX" ) );
return QSize( size, size );
}

void QgsColorWheel::paintEvent( QPaintEvent *event )
Expand Down Expand Up @@ -757,7 +758,8 @@ QgsColorBox::~QgsColorBox()

QSize QgsColorBox::sizeHint() const
{
return QSize( 200, 200 );
int size = fontMetrics().width( QStringLiteral( "XXXXXXXXXXXXXXXXXXXXXX" ) );
return QSize( size, size );
}

void QgsColorBox::paintEvent( QPaintEvent *event )
Expand Down Expand Up @@ -989,12 +991,12 @@ QSize QgsColorRampWidget::sizeHint() const
if ( mOrientation == QgsColorRampWidget::Horizontal )
{
//horizontal
return QSize( 200, 28 );
return QSize( fontMetrics().width( QStringLiteral( "XXXXXXXXXXXXXXXXXXXXXX" ) ), fontMetrics().height() * 1.3 );
}
else
{
//vertical
return QSize( 18, 200 );
return QSize( fontMetrics().height() * 1.3, fontMetrics().width( QStringLiteral( "XXXXXXXXXXXXXXXXXXXXXX" ) ) );
}
}

Expand Down Expand Up @@ -1596,7 +1598,7 @@ void QgsColorPreviewWidget::paintEvent( QPaintEvent *event )

QSize QgsColorPreviewWidget::sizeHint() const
{
return QSize( 200, 150 );
return QSize( fontMetrics().width( QStringLiteral( "XXXXXXXXXXXXXXXXXXXXXX" ) ), fontMetrics().width( QStringLiteral( "XXXXXXXXXXXXXXXXXXXXXX" ) ) * 0.75 );
}

void QgsColorPreviewWidget::setColor2( const QColor &color )
Expand Down

0 comments on commit f121286

Please sign in to comment.