Skip to content

Commit

Permalink
calculate mTwoCharSize
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Feb 21, 2018
1 parent f17ba6b commit 5cfe278
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/qgsstatusbarcoordinateswidget.cpp
Expand Up @@ -33,6 +33,9 @@ QgsStatusBarCoordinatesWidget::QgsStatusBarCoordinatesWidget( QWidget *parent )
: QWidget( parent )
, mMousePrecisionDecimalPlaces( 0 )
{
// calculate the size of two chars
mTwoCharSize = fontMetrics().width( QStringLiteral( "OO" ) );

// add a label to show current position
mLabel = new QLabel( QString(), this );
mLabel->setObjectName( QStringLiteral( "mCoordsLabel" ) );
Expand Down Expand Up @@ -244,11 +247,12 @@ void QgsStatusBarCoordinatesWidget::showExtent()
ensureCoordinatesVisible();
}

void QgsStatusBarCoordinatesWidget::ensureCoordinatesVisible(){
void QgsStatusBarCoordinatesWidget::ensureCoordinatesVisible()
{

//ensure the label is big (and small) enough
int width = mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10;
if ( mLineEdit->minimumWidth() < width || ( mLineEdit->minimumWidth() - width ) > fontMetrics().width( QStringLiteral( "OO" ) ) )
if ( mLineEdit->minimumWidth() < width || ( mLineEdit->minimumWidth() - width ) > mTwoCharSize )
{
mLineEdit->setMinimumWidth( width );
mLineEdit->setMaximumWidth( width );
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsstatusbarcoordinateswidget.h
Expand Up @@ -72,6 +72,7 @@ class APP_EXPORT QgsStatusBarCoordinatesWidget : public QWidget
QValidator *mCoordsEditValidator = nullptr;
QTimer *mDizzyTimer = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;
int mTwoCharSize;

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

0 comments on commit 5cfe278

Please sign in to comment.