Skip to content

Commit

Permalink
Fix some more inconsistent status bar fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 26, 2018
1 parent b150554 commit 7f484ab
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 deletions.
6 changes: 6 additions & 0 deletions python/gui/auto_generated/qgsstatusbar.sip.in
Expand Up @@ -88,6 +88,12 @@ Removes any temporary message being shown.
.. seealso:: :py:func:`showMessage`
%End


protected:

virtual void changeEvent( QEvent *event );


};


Expand Down
12 changes: 7 additions & 5 deletions src/app/qgisapp.cpp
Expand Up @@ -3000,7 +3000,13 @@ void QgisApp::createStatusBar()
//remove borders from children under Windows
statusBar()->setStyleSheet( QStringLiteral( "QStatusBar::item {border: none;}" ) );

// Drop the font size in the status bar by a couple of points
QFont statusBarFont = font();
statusBarFont.setPointSize( statusBarFont.pointSize() - 2 );
statusBar()->setFont( statusBarFont );

mStatusBar = new QgsStatusBar();
mStatusBar->setFont( statusBarFont );

statusBar()->addPermanentWidget( mStatusBar, 10 );

Expand All @@ -3017,13 +3023,9 @@ void QgisApp::createStatusBar()
connect( mMapCanvas, &QgsMapCanvas::mapCanvasRefreshed, this, &QgisApp::canvasRefreshFinished );

mTaskManagerWidget = new QgsTaskManagerStatusBarWidget( QgsApplication::taskManager(), mStatusBar );
mTaskManagerWidget->setFont( statusBarFont );
mStatusBar->addPermanentWidget( mTaskManagerWidget, 0 );

// 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" ) );
Expand Down
11 changes: 11 additions & 0 deletions src/gui/qgsstatusbar.cpp
Expand Up @@ -20,6 +20,7 @@
#include <QLineEdit>
#include <QPalette>
#include <QTimer>
#include <QEvent>

QgsStatusBar::QgsStatusBar( QWidget *parent )
: QWidget( parent )
Expand Down Expand Up @@ -89,3 +90,13 @@ void QgsStatusBar::clearMessage()
{
mLineEdit->setText( QString() );
}

void QgsStatusBar::changeEvent( QEvent *event )
{
QWidget::changeEvent( event );

if ( event->type() == QEvent::FontChange )
{
mLineEdit->setFont( font() );
}
}
5 changes: 5 additions & 0 deletions src/gui/qgsstatusbar.h
Expand Up @@ -100,6 +100,11 @@ class GUI_EXPORT QgsStatusBar : public QWidget
*/
void clearMessage();


protected:

void changeEvent( QEvent *event ) override;

private:

QHBoxLayout *mLayout = nullptr;
Expand Down
12 changes: 11 additions & 1 deletion src/gui/qgstaskmanagerwidget.cpp
Expand Up @@ -609,11 +609,21 @@ QgsTaskManagerStatusBarWidget::QgsTaskManagerStatusBarWidget( QgsTaskManager *ma

QSize QgsTaskManagerStatusBarWidget::sizeHint() const
{
int width = static_cast< int >( fontMetrics().width( 'X' ) * 10 * Qgis::UI_SCALE_FACTOR );
int width = static_cast< int >( fontMetrics().width( 'X' ) * 20 * Qgis::UI_SCALE_FACTOR );
int height = QToolButton::sizeHint().height();
return QSize( width, height );
}

void QgsTaskManagerStatusBarWidget::changeEvent( QEvent *event )
{
QToolButton::changeEvent( event );

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

void QgsTaskManagerStatusBarWidget::toggleDisplay()
{
if ( mFloatingWidget->isVisible() )
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgstaskmanagerwidget.h
Expand Up @@ -113,6 +113,10 @@ class GUI_EXPORT QgsTaskManagerStatusBarWidget : public QToolButton

QSize sizeHint() const override;

protected:

void changeEvent( QEvent *event ) override;

private slots:

void toggleDisplay();
Expand Down

0 comments on commit 7f484ab

Please sign in to comment.