Skip to content
Permalink
Browse files

Prevent status bar coordinate widget from shrinking too small

(cherry-picked from 0823de0)
  • Loading branch information
nyalldawson committed Feb 27, 2018
1 parent 1101fc6 commit 9ae1e936844a30145ec1d98aafa12eb6d67031f8
Showing with 4 additions and 2 deletions.
  1. +2 −1 src/app/qgsstatusbarcoordinateswidget.cpp
  2. +2 −1 src/app/qgsstatusbarcoordinateswidget.h
@@ -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 );
@@ -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 );
@@ -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;

0 comments on commit 9ae1e93

Please sign in to comment.
You can’t perform that action at this time.