Skip to content
Permalink
Browse files

calculate mTwoCharSize

  • Loading branch information
signedav committed Feb 21, 2018
1 parent f17ba6b commit 5cfe27848124444fbe63e9b3d0cfee90f2388e7b
Showing with 7 additions and 2 deletions.
  1. +6 −2 src/app/qgsstatusbarcoordinateswidget.cpp
  2. +1 −0 src/app/qgsstatusbarcoordinateswidget.h
@@ -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" ) );
@@ -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 );
@@ -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;

0 comments on commit 5cfe278

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