Skip to content

Commit

Permalink
improvement in statusbar widget size handling
Browse files Browse the repository at this point in the history
only the scale line edit has the minimum size instead of the whole scale widget
coordinates line edit size is now dynamic depending on the coordinate value
  • Loading branch information
signedav committed Dec 13, 2017
1 parent 28a61e1 commit ee1f408
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
6 changes: 0 additions & 6 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9113,12 +9113,6 @@ void QgisApp::saveLastMousePosition( const QgsPointXY &p )
void QgisApp::showScale( double scale )
{
mScaleWidget->setScale( scale );

// Not sure if the lines below do anything meaningful /Homann
if ( mScaleWidget->width() > mScaleWidget->minimumWidth() )
{
mScaleWidget->setMinimumWidth( mScaleWidget->width() );
}
}


Expand Down
16 changes: 6 additions & 10 deletions src/app/qgsstatusbarcoordinateswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ QgsStatusBarCoordinatesWidget::QgsStatusBarCoordinatesWidget( QWidget *parent )

mLineEdit = new QLineEdit( this );
mLineEdit->setMinimumWidth( 10 );
mLineEdit->setMaximumWidth( 300 );
//mLineEdit->setMaximumHeight( 20 );
mLineEdit->setContentsMargins( 0, 0, 0, 0 );
mLineEdit->setAlignment( Qt::AlignCenter );
Expand Down Expand Up @@ -226,10 +225,9 @@ void QgsStatusBarCoordinatesWidget::showMouseCoordinates( const QgsPointXY &p )
mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( p, mMapCanvas->mapSettings().destinationCrs(),
mMousePrecisionDecimalPlaces ) );

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


Expand All @@ -244,9 +242,7 @@ void QgsStatusBarCoordinatesWidget::showExtent()
QgsRectangle myExtents = mMapCanvas->extent();
mLabel->setText( tr( "Extents:" ) );
mLineEdit->setText( myExtents.toString( true ) );
//ensure the label is big enough
if ( mLineEdit->width() > mLineEdit->minimumWidth() )
{
mLineEdit->setMinimumWidth( mLineEdit->width() );
}
//ensure the label is big (and small) enough
mLineEdit->setMinimumWidth( mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10 );
mLineEdit->setMaximumWidth( mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10 );
}
5 changes: 5 additions & 0 deletions src/app/qgsstatusbarscalewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ void QgsStatusBarScaleWidget::setScale( double scale )
mScale->blockSignals( true );
mScale->setScale( scale );
mScale->blockSignals( false );

if ( mScale->width() > mScale->minimumWidth() )
{
mScale->setMinimumWidth( mScale->width() );
}
}

bool QgsStatusBarScaleWidget::isLocked() const
Expand Down

0 comments on commit ee1f408

Please sign in to comment.