File tree Expand file tree Collapse file tree 4 files changed +37
-0
lines changed
python/gui/auto_generated Expand file tree Collapse file tree 4 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,17 @@ returns the duration in second of the message
8282 QString getStyleSheet();
8383%Docstring
8484returns the styleSheet
85+ %End
86+
87+ public slots:
88+
89+ void dismiss();
90+ %Docstring
91+ Dismisses the item, removing it from the message bar and deleting
92+ it. Calling this on items which have not been added to a message bar
93+ has no effect.
94+
95+ .. versionadded:: 3.4
8596%End
8697
8798 signals:
Original file line number Diff line number Diff line change @@ -267,6 +267,9 @@ void QgsMessageBar::showItem( QgsMessageBarItem *item )
267267void QgsMessageBar::pushItem ( QgsMessageBarItem *item )
268268{
269269 resetCountdown ();
270+
271+ item->mMessageBar = this ;
272+
270273 // avoid duplicated widget
271274 popWidget ( item );
272275 showItem ( item );
Original file line number Diff line number Diff line change @@ -269,6 +269,14 @@ QgsMessageBarItem *QgsMessageBarItem::setDuration( int duration )
269269 return this ;
270270}
271271
272+ void QgsMessageBarItem::dismiss ()
273+ {
274+ if ( !mMessageBar )
275+ return ;
276+
277+ mMessageBar ->popWidget ( this );
278+ }
279+
272280void QgsMessageBarItem::urlClicked ( const QUrl &url )
273281{
274282 QFileInfo file ( url.toLocalFile () );
Original file line number Diff line number Diff line change 2727
2828class QTextBrowser ;
2929class QLabel ;
30+ class QgsMessageBar ;
3031
3132/* *
3233 * \ingroup gui
@@ -91,6 +92,17 @@ class GUI_EXPORT QgsMessageBarItem : public QWidget
9192 // ! returns the styleSheet
9293 QString getStyleSheet () { return mStyleSheet ; }
9394
95+ public slots:
96+
97+ /* *
98+ * Dismisses the item, removing it from the message bar and deleting
99+ * it. Calling this on items which have not been added to a message bar
100+ * has no effect.
101+ *
102+ * \since QGIS 3.4
103+ */
104+ void dismiss ();
105+
94106 signals:
95107 // ! emitted when the message level has changed
96108 void styleChanged ( const QString &styleSheet );
@@ -112,6 +124,9 @@ class GUI_EXPORT QgsMessageBarItem : public QWidget
112124 QLabel *mLblIcon = nullptr ;
113125 QString mStyleSheet ;
114126 QTextBrowser *mTextBrowser = nullptr ;
127+ QgsMessageBar *mMessageBar = nullptr ;
128+
129+ friend class QgsMessageBar ;
115130};
116131
117132#endif // qgsmessagebaritem_H
You can’t perform that action at this time.
0 commit comments