Skip to content

Commit

Permalink
Fix locator widget's width on hi-dpi screens
Browse files Browse the repository at this point in the history
It was too short to see the whole placeholder text...
  • Loading branch information
wonder-sk committed May 18, 2017
1 parent e505ebc commit bba6313
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gui/locator/qgslocatorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ QgsLocatorWidget::QgsLocatorWidget( QWidget *parent )
mLineEdit->setShowClearButton( true );
mLineEdit->setPlaceholderText( tr( "Type to locate (Ctrl+K)" ) );

resize( 200, 30 );
int placeholderMinWidth = mLineEdit->fontMetrics().width( mLineEdit->placeholderText() );
int minWidth = qMax( 200, ( int )( placeholderMinWidth * 1.3 ) );
resize( minWidth, 30 );
QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
setSizePolicy( sizePolicy );
setMinimumSize( QSize( 200, 0 ) );
setMinimumSize( QSize( minWidth, 0 ) );

QHBoxLayout *layout = new QHBoxLayout();
layout->setMargin( 0 );
Expand Down

0 comments on commit bba6313

Please sign in to comment.