Skip to content

Commit

Permalink
Fix broken status bar font size logic
Browse files Browse the repository at this point in the history
The logic which was put in place to drop the status bar font size
by a couple of points was being overridden by style sheet settings.

Fix this and ensure that all right-located status bar widgets
correctly use the smaller font size. Also tweak locator width a little.
  • Loading branch information
nyalldawson committed Oct 25, 2018
1 parent ac44bf2 commit ce0f8e3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/app/qgisapp.cpp
Expand Up @@ -3019,29 +3019,28 @@ void QgisApp::createStatusBar()
mTaskManagerWidget = new QgsTaskManagerStatusBarWidget( QgsApplication::taskManager(), mStatusBar );
mStatusBar->addPermanentWidget( mTaskManagerWidget, 0 );

// Bumped the font up one point size since 8 was too
// small on some platforms. A point size of 9 still provides
// plenty of display space on 1024x768 resolutions
QFont myFont( QStringLiteral( "Arial" ), 9 );
statusBar()->setFont( myFont );
// Drop the font size in the status bar by a couple of points
QFont statusBarFont = font();
statusBarFont.setPointSize( statusBarFont.pointSize() - 2 );
statusBar()->setFont( statusBarFont );

//coords status bar widget
mCoordsEdit = new QgsStatusBarCoordinatesWidget( mStatusBar );
mCoordsEdit->setObjectName( QStringLiteral( "mCoordsEdit" ) );
mCoordsEdit->setMapCanvas( mMapCanvas );
mCoordsEdit->setFont( myFont );
mCoordsEdit->setFont( statusBarFont );
mStatusBar->addPermanentWidget( mCoordsEdit, 0 );

mScaleWidget = new QgsStatusBarScaleWidget( mMapCanvas, mStatusBar );
mScaleWidget->setObjectName( QStringLiteral( "mScaleWidget" ) );
mScaleWidget->setFont( myFont );
mScaleWidget->setFont( statusBarFont );
connect( mScaleWidget, &QgsStatusBarScaleWidget::scaleLockChanged, mMapCanvas, &QgsMapCanvas::setScaleLocked );
mStatusBar->addPermanentWidget( mScaleWidget, 0 );

// zoom widget
mMagnifierWidget = new QgsStatusBarMagnifierWidget( mStatusBar );
mMagnifierWidget->setObjectName( QStringLiteral( "mMagnifierWidget" ) );
mMagnifierWidget->setFont( myFont );
mMagnifierWidget->setFont( statusBarFont );
connect( mMapCanvas, &QgsMapCanvas::magnificationChanged, mMagnifierWidget, &QgsStatusBarMagnifierWidget::updateMagnification );
connect( mMagnifierWidget, &QgsStatusBarMagnifierWidget::magnificationChanged, mMapCanvas, &QgsMapCanvas::setMagnificationFactor );
mMagnifierWidget->updateMagnification( QSettings().value( QStringLiteral( "/qgis/magnifier_factor_default" ), 1.0 ).toDouble() );
Expand All @@ -3050,7 +3049,7 @@ void QgisApp::createStatusBar()
// add a widget to show/set current rotation
mRotationLabel = new QLabel( QString(), mStatusBar );
mRotationLabel->setObjectName( QStringLiteral( "mRotationLabel" ) );
mRotationLabel->setFont( myFont );
mRotationLabel->setFont( statusBarFont );
mRotationLabel->setMinimumWidth( 10 );
//mRotationLabel->setMaximumHeight( 20 );
mRotationLabel->setMargin( 3 );
Expand All @@ -3069,7 +3068,7 @@ void QgisApp::createStatusBar()
mRotationEdit->setRange( -360.0, 360.0 );
mRotationEdit->setWrapping( true );
mRotationEdit->setSingleStep( 5.0 );
mRotationEdit->setFont( myFont );
mRotationEdit->setFont( statusBarFont );
mRotationEdit->setSuffix( tr( " °" ) );
mRotationEdit->setWhatsThis( tr( "Shows the current map clockwise rotation "
"in degrees. It also allows editing to set "
Expand All @@ -3084,7 +3083,7 @@ void QgisApp::createStatusBar()
mRenderSuppressionCBox = new QCheckBox( tr( "Render" ), mStatusBar );
mRenderSuppressionCBox->setObjectName( QStringLiteral( "mRenderSuppressionCBox" ) );
mRenderSuppressionCBox->setChecked( true );
mRenderSuppressionCBox->setFont( myFont );
mRenderSuppressionCBox->setFont( statusBarFont );
mRenderSuppressionCBox->setWhatsThis( tr( "When checked, the map layers "
"are rendered in response to map navigation commands and other "
"events. When not checked, no rendering is done. This allows you "
Expand All @@ -3096,6 +3095,7 @@ void QgisApp::createStatusBar()
// sculpted on OS X and the icon is never displayed [gsherman]
mOnTheFlyProjectionStatusButton = new QToolButton( mStatusBar );
mOnTheFlyProjectionStatusButton->setAutoRaise( true );
mOnTheFlyProjectionStatusButton->setFont( statusBarFont );
mOnTheFlyProjectionStatusButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
mOnTheFlyProjectionStatusButton->setObjectName( QStringLiteral( "mOntheFlyProjectionStatusButton" ) );
// Maintain uniform widget height in status bar by setting button height same as labels
Expand Down
6 changes: 6 additions & 0 deletions src/gui/editorwidgets/qgsdoublespinbox.cpp
Expand Up @@ -62,6 +62,12 @@ void QgsDoubleSpinBox::setExpressionsEnabled( const bool enabled )
void QgsDoubleSpinBox::changeEvent( QEvent *event )
{
QDoubleSpinBox::changeEvent( event );

if ( event->type() == QEvent::FontChange )
{
lineEdit()->setFont( font() );
}

mLineEdit->setShowClearButton( shouldShowClearForValue( value() ) );
}

Expand Down
6 changes: 6 additions & 0 deletions src/gui/editorwidgets/qgsspinbox.cpp
Expand Up @@ -60,6 +60,12 @@ void QgsSpinBox::setExpressionsEnabled( const bool enabled )
void QgsSpinBox::changeEvent( QEvent *event )
{
QSpinBox::changeEvent( event );

if ( event->type() == QEvent::FontChange )
{
lineEdit()->setFont( font() );
}

mLineEdit->setShowClearButton( shouldShowClearForValue( value() ) );
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/locator/qgslocatorwidget.cpp
Expand Up @@ -42,7 +42,7 @@ QgsLocatorWidget::QgsLocatorWidget( QWidget *parent )
#endif

int placeholderMinWidth = mLineEdit->fontMetrics().width( mLineEdit->placeholderText() );
int minWidth = std::max( 200, ( int )( placeholderMinWidth * 1.6 ) );
int minWidth = std::max( 200, static_cast< int >( placeholderMinWidth * 1.8 ) );
resize( minWidth, 30 );
QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
sizePolicy.setHorizontalStretch( 0 );
Expand Down

0 comments on commit ce0f8e3

Please sign in to comment.