mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Allow message bar items to be dismissed from QgsMessageBarItem
This commit is contained in:
parent
0a02432b0c
commit
124f738188
@ -82,6 +82,17 @@ returns the duration in second of the message
|
|||||||
QString getStyleSheet();
|
QString getStyleSheet();
|
||||||
%Docstring
|
%Docstring
|
||||||
returns the styleSheet
|
returns the styleSheet
|
||||||
|
%End
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void dismiss();
|
||||||
|
%Docstring
|
||||||
|
Dismisses the item, removing it from the message bar and deleting
|
||||||
|
it. Calling this on items which have not been added to a message bar
|
||||||
|
has no effect.
|
||||||
|
|
||||||
|
.. versionadded:: 3.4
|
||||||
%End
|
%End
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -267,6 +267,9 @@ void QgsMessageBar::showItem( QgsMessageBarItem *item )
|
|||||||
void QgsMessageBar::pushItem( QgsMessageBarItem *item )
|
void QgsMessageBar::pushItem( QgsMessageBarItem *item )
|
||||||
{
|
{
|
||||||
resetCountdown();
|
resetCountdown();
|
||||||
|
|
||||||
|
item->mMessageBar = this;
|
||||||
|
|
||||||
// avoid duplicated widget
|
// avoid duplicated widget
|
||||||
popWidget( item );
|
popWidget( item );
|
||||||
showItem( item );
|
showItem( item );
|
||||||
|
@ -269,6 +269,14 @@ QgsMessageBarItem *QgsMessageBarItem::setDuration( int duration )
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsMessageBarItem::dismiss()
|
||||||
|
{
|
||||||
|
if ( !mMessageBar )
|
||||||
|
return;
|
||||||
|
|
||||||
|
mMessageBar->popWidget( this );
|
||||||
|
}
|
||||||
|
|
||||||
void QgsMessageBarItem::urlClicked( const QUrl &url )
|
void QgsMessageBarItem::urlClicked( const QUrl &url )
|
||||||
{
|
{
|
||||||
QFileInfo file( url.toLocalFile() );
|
QFileInfo file( url.toLocalFile() );
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
class QTextBrowser;
|
class QTextBrowser;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QgsMessageBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup gui
|
* \ingroup gui
|
||||||
@ -91,6 +92,17 @@ class GUI_EXPORT QgsMessageBarItem : public QWidget
|
|||||||
//! returns the styleSheet
|
//! returns the styleSheet
|
||||||
QString getStyleSheet() { return mStyleSheet; }
|
QString getStyleSheet() { return mStyleSheet; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dismisses the item, removing it from the message bar and deleting
|
||||||
|
* it. Calling this on items which have not been added to a message bar
|
||||||
|
* has no effect.
|
||||||
|
*
|
||||||
|
* \since QGIS 3.4
|
||||||
|
*/
|
||||||
|
void dismiss();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! emitted when the message level has changed
|
//! emitted when the message level has changed
|
||||||
void styleChanged( const QString &styleSheet );
|
void styleChanged( const QString &styleSheet );
|
||||||
@ -112,6 +124,9 @@ class GUI_EXPORT QgsMessageBarItem : public QWidget
|
|||||||
QLabel *mLblIcon = nullptr;
|
QLabel *mLblIcon = nullptr;
|
||||||
QString mStyleSheet;
|
QString mStyleSheet;
|
||||||
QTextBrowser *mTextBrowser = nullptr;
|
QTextBrowser *mTextBrowser = nullptr;
|
||||||
|
QgsMessageBar *mMessageBar = nullptr;
|
||||||
|
|
||||||
|
friend class QgsMessageBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // qgsmessagebaritem_H
|
#endif // qgsmessagebaritem_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user