Skip to content
Permalink
Browse files

improvement in statusbar widget size handling

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 ee1f40827f630cc502e3c52ddc6fe66f85df33d9
Showing with 11 additions and 16 deletions.
  1. +0 −6 src/app/qgisapp.cpp
  2. +6 −10 src/app/qgsstatusbarcoordinateswidget.cpp
  3. +5 −0 src/app/qgsstatusbarscalewidget.cpp
@@ -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() );
}
}


@@ -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 );
@@ -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 );
}


@@ -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 );
}
@@ -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

0 comments on commit ee1f408

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