Skip to content
Permalink
Browse files

Prevent status bar coordinate widget from shrinking too small

  • Loading branch information
nyalldawson committed Mar 2, 2018
1 parent 6f47b25 commit 0823de0fab8a97e65f3f90ceb8caf1271e607ac9
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 0823de0

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