Skip to content

Commit ee1f408

Browse files
committedDec 13, 2017
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
1 parent 28a61e1 commit ee1f408

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9113,12 +9113,6 @@ void QgisApp::saveLastMousePosition( const QgsPointXY &p )
91139113
void QgisApp::showScale( double scale )
91149114
{
91159115
mScaleWidget->setScale( scale );
9116-
9117-
// Not sure if the lines below do anything meaningful /Homann
9118-
if ( mScaleWidget->width() > mScaleWidget->minimumWidth() )
9119-
{
9120-
mScaleWidget->setMinimumWidth( mScaleWidget->width() );
9121-
}
91229116
}
91239117

91249118

‎src/app/qgsstatusbarcoordinateswidget.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ QgsStatusBarCoordinatesWidget::QgsStatusBarCoordinatesWidget( QWidget *parent )
4646

4747
mLineEdit = new QLineEdit( this );
4848
mLineEdit->setMinimumWidth( 10 );
49-
mLineEdit->setMaximumWidth( 300 );
5049
//mLineEdit->setMaximumHeight( 20 );
5150
mLineEdit->setContentsMargins( 0, 0, 0, 0 );
5251
mLineEdit->setAlignment( Qt::AlignCenter );
@@ -226,10 +225,9 @@ void QgsStatusBarCoordinatesWidget::showMouseCoordinates( const QgsPointXY &p )
226225
mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( p, mMapCanvas->mapSettings().destinationCrs(),
227226
mMousePrecisionDecimalPlaces ) );
228227

229-
if ( mLineEdit->width() > mLineEdit->minimumWidth() )
230-
{
231-
mLineEdit->setMinimumWidth( mLineEdit->width() );
232-
}
228+
//ensure the label is big (and small) enough
229+
mLineEdit->setMinimumWidth( mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10 );
230+
mLineEdit->setMaximumWidth( mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10 );
233231
}
234232

235233

@@ -244,9 +242,7 @@ void QgsStatusBarCoordinatesWidget::showExtent()
244242
QgsRectangle myExtents = mMapCanvas->extent();
245243
mLabel->setText( tr( "Extents:" ) );
246244
mLineEdit->setText( myExtents.toString( true ) );
247-
//ensure the label is big enough
248-
if ( mLineEdit->width() > mLineEdit->minimumWidth() )
249-
{
250-
mLineEdit->setMinimumWidth( mLineEdit->width() );
251-
}
245+
//ensure the label is big (and small) enough
246+
mLineEdit->setMinimumWidth( mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10 );
247+
mLineEdit->setMaximumWidth( mLineEdit->fontMetrics().width( mLineEdit->text() ) + 10 );
252248
}

‎src/app/qgsstatusbarscalewidget.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ void QgsStatusBarScaleWidget::setScale( double scale )
7878
mScale->blockSignals( true );
7979
mScale->setScale( scale );
8080
mScale->blockSignals( false );
81+
82+
if ( mScale->width() > mScale->minimumWidth() )
83+
{
84+
mScale->setMinimumWidth( mScale->width() );
85+
}
8186
}
8287

8388
bool QgsStatusBarScaleWidget::isLocked() const

0 commit comments

Comments
 (0)
Please sign in to comment.