Fix setStatusTip

Fixes #30249
This commit is contained in:
Matthias Kuhn 2019-06-17 18:44:59 +02:00
parent 24e56a810c
commit 242c9fcfba
4 changed files with 34 additions and 0 deletions

View File

@ -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:

View File

@ -3053,6 +3053,7 @@ void QgisApp::createStatusBar()
statusBar()->setFont( statusBarFont );
mStatusBar = new QgsStatusBar();
mStatusBar->setParentStatusBar( QMainWindow::statusBar() );
mStatusBar->setFont( statusBarFont );
statusBar()->addPermanentWidget( mStatusBar, 10 );

View File

@ -21,6 +21,7 @@
#include <QPalette>
#include <QTimer>
#include <QEvent>
#include <QStatusBar>
QgsStatusBar::QgsStatusBar( QWidget *parent )
: QWidget( parent )
@ -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 );

View File

@ -24,6 +24,7 @@
class QHBoxLayout;
class QLineEdit;
class QStatusBar;
/**
* \class QgsStatusBar
@ -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:
@ -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;
};