22 #include <QHBoxLayout>
31 , mDuration( duration )
33 , mUserIcon( QIcon() )
44 , mDuration( duration )
46 , mUserIcon( QIcon() )
57 , mDuration( duration )
59 , mUserIcon( QIcon() )
70 , mDuration( duration )
72 , mUserIcon( QIcon() )
82 void QgsMessageBarItem::writeContent()
86 mLayout =
new QHBoxLayout(
this );
87 mLayout->setContentsMargins( 0, 0, 0, 0 );
95 mLblIcon =
new QLabel(
this );
96 mLayout->addWidget( mLblIcon );
99 if ( !mUserIcon.isNull() )
105 QString msgIcon(
"/mIconInfo.png" );
109 msgIcon = QString(
"/mIconCritical.png" );
112 msgIcon = QString(
"/mIconWarn.png" );
115 msgIcon = QString(
"/mIconSuccess.png" );
122 mLblIcon->setPixmap( icon.pixmap( 24 ) );
125 if ( mTitle.isEmpty() && mText.isEmpty() )
127 if ( mTextEdit != 0 )
135 if ( mTextEdit == 0 )
137 mTextEdit =
new QTextEdit(
this );
138 mTextEdit->setObjectName(
"textEdit" );
139 mTextEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum );
140 mTextEdit->setReadOnly(
true );
141 mTextEdit->setFrameShape( QFrame::NoFrame );
144 mTextEdit->setStyleSheet(
"QTextEdit { background-color: rgba(0,0,0,0); margin-top: 0.25em; max-height: 1.75em; min-height: 1.75em; } "
145 "QScrollBar { background-color: rgba(0,0,0,0); } "
146 "QScrollBar::add-page,QScrollBar::sub-page,QScrollBar::handle { background-color: rgba(0,0,0,0); color: rgba(0,0,0,0); } "
147 "QScrollBar::up-arrow,QScrollBar::down-arrow { color: rgb(0,0,0); } " );
148 mLayout->addWidget( mTextEdit );
150 QString content = mText;
151 if ( !mTitle.isEmpty() )
154 QString t = mTitle.trimmed();
155 if ( !content.isEmpty() && !t.endsWith(
":" ) && !t.endsWith(
": " ) )
157 content.prepend( QString(
"<b>" ) + t +
" </b>" );
159 mTextEdit->setText( content );
165 QLayoutItem *item = mLayout->itemAt( 2 );
166 if ( !item || item->widget() != mWidget )
168 mLayout->addWidget( mWidget );
175 mStyleSheet =
"QgsMessageBar { background-color: #dff0d8; border: 1px solid #8e998a; } "
176 "QLabel,QTextEdit { color: black; } ";
180 mStyleSheet =
"QgsMessageBar { background-color: #d65253; border: 1px solid #9b3d3d; } "
181 "QLabel,QTextEdit { color: white; } ";
185 mStyleSheet =
"QgsMessageBar { background-color: #ffc800; border: 1px solid #e0aa00; } "
186 "QLabel,QTextEdit { color: black; } ";
190 mStyleSheet =
"QgsMessageBar { background-color: #e7f5fe; border: 1px solid #b9cfe4; } "
191 "QLabel,QTextEdit { color: #2554a1; } ";
193 mStyleSheet +=
"QLabel#mItemCount { font-style: italic; }";
223 item = mLayout->itemAt( 2 );
224 if ( item->widget() == mWidget )
226 delete item->widget();