Skip to content

Commit

Permalink
Fix setStatusTip
Browse files Browse the repository at this point in the history
Fixes #30249
  • Loading branch information
m-kuhn committed Jun 18, 2019
1 parent 24e56a8 commit 242c9fc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/gui/auto_generated/qgsstatusbar.sip.in
Expand Up @@ -88,6 +88,15 @@ Removes any temporary message being shown.
.. seealso:: :py:func:`showMessage`
%End

void setParentStatusBar( QStatusBar *statusBar );
%Docstring
Sets the parent status bar.
Messages that are shown on the parent status bar will be intercepted
and shown on this status bar too.

.. versionadded:: 3.8
%End


protected:

Expand Down
1 change: 1 addition & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -3053,6 +3053,7 @@ void QgisApp::createStatusBar()
statusBar()->setFont( statusBarFont );

mStatusBar = new QgsStatusBar();
mStatusBar->setParentStatusBar( QMainWindow::statusBar() );
mStatusBar->setFont( statusBarFont );

statusBar()->addPermanentWidget( mStatusBar, 10 );
Expand Down
12 changes: 12 additions & 0 deletions src/gui/qgsstatusbar.cpp
Expand Up @@ -21,6 +21,7 @@
#include <QPalette>
#include <QTimer>
#include <QEvent>
#include <QStatusBar>

QgsStatusBar::QgsStatusBar( QWidget *parent )
: QWidget( parent )
Expand Down Expand Up @@ -91,6 +92,17 @@ void QgsStatusBar::clearMessage()
mLineEdit->setText( QString() );
}

void QgsStatusBar::setParentStatusBar( QStatusBar *statusBar )
{
if ( mParentStatusBar )
mParentStatusBar->disconnect( mShowMessageConnection );

mParentStatusBar = statusBar;

if ( mParentStatusBar )
mShowMessageConnection = connect( mParentStatusBar, &QStatusBar::messageChanged, this, [this]( const QString & message ) { showMessage( message ); } );
}

void QgsStatusBar::changeEvent( QEvent *event )
{
QWidget::changeEvent( event );
Expand Down
12 changes: 12 additions & 0 deletions src/gui/qgsstatusbar.h
Expand Up @@ -24,6 +24,7 @@

class QHBoxLayout;
class QLineEdit;
class QStatusBar;

/**
* \class QgsStatusBar
Expand Down Expand Up @@ -100,6 +101,15 @@ class GUI_EXPORT QgsStatusBar : public QWidget
*/
void clearMessage();

/**
* Sets the parent status bar.
* Messages that are shown on the parent status bar will be intercepted
* and shown on this status bar too.
*
* \since QGIS 3.8
*/
void setParentStatusBar( QStatusBar *statusBar );


protected:

Expand All @@ -110,6 +120,8 @@ class GUI_EXPORT QgsStatusBar : public QWidget
QHBoxLayout *mLayout = nullptr;
QLineEdit *mLineEdit = nullptr;
QTimer *mTempMessageTimer = nullptr;
QStatusBar *mParentStatusBar = nullptr;
QMetaObject::Connection mShowMessageConnection;

};

Expand Down

0 comments on commit 242c9fc

Please sign in to comment.