Skip to content

Commit 0823de0

Browse files
committed
Prevent status bar coordinate widget from shrinking too small
1 parent 6f47b25 commit 0823de0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/app/qgsstatusbarcoordinateswidget.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ QgsStatusBarCoordinatesWidget::QgsStatusBarCoordinatesWidget( QWidget *parent )
3535
{
3636
// calculate the size of two chars
3737
mTwoCharSize = fontMetrics().width( QStringLiteral( "OO" ) );
38+
mMinimumWidth = mTwoCharSize * 4;
3839

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

253254
//ensure the label is big (and small) enough
254-
int width = mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10;
255+
int width = std::max( mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10, mMinimumWidth );
255256
if ( mLineEdit->minimumWidth() < width || ( mLineEdit->minimumWidth() - width ) > mTwoCharSize )
256257
{
257258
mLineEdit->setMinimumWidth( width );

src/app/qgsstatusbarcoordinateswidget.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class APP_EXPORT QgsStatusBarCoordinatesWidget : public QWidget
7272
QValidator *mCoordsEditValidator = nullptr;
7373
QTimer *mDizzyTimer = nullptr;
7474
QgsMapCanvas *mMapCanvas = nullptr;
75-
int mTwoCharSize;
75+
int mTwoCharSize = 0;
76+
int mMinimumWidth = 0;
7677

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

0 commit comments

Comments
 (0)