Skip to content

Commit f17ba6b

Browse files
committed
only decrease when larger than two signs
and increase always. but decrease again only when more than the size of "00" difference.
1 parent ffd1e4b commit f17ba6b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/app/qgsstatusbarcoordinateswidget.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,7 @@ void QgsStatusBarCoordinatesWidget::showMouseCoordinates( const QgsPointXY &p )
225225
mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( p, mMapCanvas->mapSettings().destinationCrs(),
226226
mMousePrecisionDecimalPlaces ) );
227227

228-
//ensure the label is big (and small) enough
229-
int width = mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10;
230-
if ( mLineEdit->minimumWidth() + 4 < width || mLineEdit->minimumWidth() - 4 > width )
231-
{
232-
mLineEdit->setMinimumWidth( width );
233-
mLineEdit->setMaximumWidth( width );
234-
}
228+
ensureCoordinatesVisible();
235229
}
236230

237231

@@ -247,11 +241,17 @@ void QgsStatusBarCoordinatesWidget::showExtent()
247241
mLabel->setText( tr( "Extents:" ) );
248242
mLineEdit->setText( myExtents.toString( true ) );
249243

244+
ensureCoordinatesVisible();
245+
}
246+
247+
void QgsStatusBarCoordinatesWidget::ensureCoordinatesVisible(){
248+
250249
//ensure the label is big (and small) enough
251250
int width = mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10;
252-
if ( mLineEdit->minimumWidth() + 4 < width || mLineEdit->minimumWidth() - 4 > width )
251+
if ( mLineEdit->minimumWidth() < width || ( mLineEdit->minimumWidth() - width ) > fontMetrics().width( QStringLiteral( "OO" ) ) )
253252
{
254253
mLineEdit->setMinimumWidth( width );
255254
mLineEdit->setMaximumWidth( width );
256255
}
257256
}
257+

src/app/qgsstatusbarcoordinateswidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class APP_EXPORT QgsStatusBarCoordinatesWidget : public QWidget
5959
void validateCoordinates();
6060
void dizzy();
6161
void showExtent();
62+
void ensureCoordinatesVisible();
6263

6364
private:
6465
void refreshMapCanvas();

0 commit comments

Comments
 (0)