|
19 | 19 | #include "qgsmessagebaritem.h"
|
20 | 20 | #include "qgsapplication.h"
|
21 | 21 | #include "qgsmessagelog.h"
|
| 22 | +#include "qgsmessageviewer.h" |
22 | 23 |
|
23 | 24 | #include <QWidget>
|
24 | 25 | #include <QPalette>
|
@@ -298,6 +299,32 @@ void QgsMessageBar::pushMessage( const QString &title, const QString &text, Qgis
|
298 | 299 | pushItem( item );
|
299 | 300 | }
|
300 | 301 |
|
| 302 | +void QgsMessageBar::pushMessage( const QString &title, const QString &text, const QString &showMore, Qgis::MessageLevel level, int duration ) |
| 303 | +{ |
| 304 | + QgsMessageViewer *mv = new QgsMessageViewer(); |
| 305 | + mv->setWindowTitle( title ); |
| 306 | + mv->setMessageAsPlainText( text + "\n\n" + showMore ); |
| 307 | + |
| 308 | + QToolButton *showMoreButton = new QToolButton(); |
| 309 | + QAction *act = new QAction( showMoreButton ); |
| 310 | + act->setText( tr( "Show more" ) ); |
| 311 | + showMoreButton->setStyleSheet( QStringLiteral( "background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" ) ); |
| 312 | + showMoreButton->setCursor( Qt::PointingHandCursor ); |
| 313 | + showMoreButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); |
| 314 | + showMoreButton->addAction( act ); |
| 315 | + showMoreButton->setDefaultAction( act ); |
| 316 | + connect( showMoreButton, &QToolButton::triggered, mv, &QDialog::exec ); |
| 317 | + connect( showMoreButton, &QToolButton::triggered, showMoreButton, &QObject::deleteLater ); |
| 318 | + |
| 319 | + QgsMessageBarItem *item = new QgsMessageBarItem( |
| 320 | + title, |
| 321 | + text, |
| 322 | + showMoreButton, |
| 323 | + level, |
| 324 | + duration ); |
| 325 | + pushItem( item ); |
| 326 | +} |
| 327 | + |
301 | 328 | QgsMessageBarItem *QgsMessageBar::createMessage( const QString &text, QWidget *parent )
|
302 | 329 | {
|
303 | 330 | QgsMessageBarItem *item = new QgsMessageBarItem( text, Qgis::Info, 0, parent );
|
|
0 commit comments