Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prevent status bar coordinate widget from shrinking too small
  • Loading branch information
nyalldawson committed Mar 2, 2018
1 parent 6f47b25 commit 0823de0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/app/qgsstatusbarcoordinateswidget.cpp
Expand Up @@ -35,6 +35,7 @@ QgsStatusBarCoordinatesWidget::QgsStatusBarCoordinatesWidget( QWidget *parent )
{
// calculate the size of two chars
mTwoCharSize = fontMetrics().width( QStringLiteral( "OO" ) );
mMinimumWidth = mTwoCharSize * 4;

// add a label to show current position
mLabel = new QLabel( QString(), this );
Expand Down Expand Up @@ -251,7 +252,7 @@ void QgsStatusBarCoordinatesWidget::ensureCoordinatesVisible()
{

//ensure the label is big (and small) enough
int width = mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10;
int width = std::max( mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10, mMinimumWidth );
if ( mLineEdit->minimumWidth() < width || ( mLineEdit->minimumWidth() - width ) > mTwoCharSize )
{
mLineEdit->setMinimumWidth( width );
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsstatusbarcoordinateswidget.h
Expand Up @@ -72,7 +72,8 @@ class APP_EXPORT QgsStatusBarCoordinatesWidget : public QWidget
QValidator *mCoordsEditValidator = nullptr;
QTimer *mDizzyTimer = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;
int mTwoCharSize;
int mTwoCharSize = 0;
int mMinimumWidth = 0;

//! The number of decimal places to use if not automatic
unsigned int mMousePrecisionDecimalPlaces;
Expand Down

0 comments on commit 0823de0

Please sign in to comment.