Fix size of some color widgets on hidpi displays

This commit is contained in:
Nyall Dawson 2017-07-25 12:52:23 +10:00
parent aacc316eed
commit f121286e38

View File

@ -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 )
@ -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 )
@ -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" ) ) );
}
}
@ -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 )