Skip to content

Commit

Permalink
only decrease when larger than two signs
Browse files Browse the repository at this point in the history
and increase always. but decrease again only when more than the size of "00" difference.
  • Loading branch information
signedav committed Feb 21, 2018
1 parent ffd1e4b commit f17ba6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/app/qgsstatusbarcoordinateswidget.cpp
Expand Up @@ -225,13 +225,7 @@ void QgsStatusBarCoordinatesWidget::showMouseCoordinates( const QgsPointXY &p )
mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( p, mMapCanvas->mapSettings().destinationCrs(),
mMousePrecisionDecimalPlaces ) );

//ensure the label is big (and small) enough
int width = mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10;
if ( mLineEdit->minimumWidth() + 4 < width || mLineEdit->minimumWidth() - 4 > width )
{
mLineEdit->setMinimumWidth( width );
mLineEdit->setMaximumWidth( width );
}
ensureCoordinatesVisible();
}


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

ensureCoordinatesVisible();
}

void QgsStatusBarCoordinatesWidget::ensureCoordinatesVisible(){

//ensure the label is big (and small) enough
int width = mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10;
if ( mLineEdit->minimumWidth() + 4 < width || mLineEdit->minimumWidth() - 4 > width )
if ( mLineEdit->minimumWidth() < width || ( mLineEdit->minimumWidth() - width ) > fontMetrics().width( QStringLiteral( "OO" ) ) )
{
mLineEdit->setMinimumWidth( width );
mLineEdit->setMaximumWidth( width );
}
}

1 change: 1 addition & 0 deletions src/app/qgsstatusbarcoordinateswidget.h
Expand Up @@ -59,6 +59,7 @@ class APP_EXPORT QgsStatusBarCoordinatesWidget : public QWidget
void validateCoordinates();
void dizzy();
void showExtent();
void ensureCoordinatesVisible();

private:
void refreshMapCanvas();
Expand Down

0 comments on commit f17ba6b

Please sign in to comment.