Skip to content

Commit

Permalink
Add GUI_Export, Reorder widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Aug 15, 2013
1 parent 3fdeb03 commit 05a41e3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 41 deletions.
72 changes: 32 additions & 40 deletions src/gui/qgsmessagebaritem.cpp
Expand Up @@ -94,6 +94,35 @@ void QgsMessageBarItem::writeContent()
mLblIcon = 0;
}

// ICON
if ( mLblIcon == 0 )
{
mLblIcon = new QLabel( this );
mLayout->addWidget( mLblIcon );
}
QIcon icon;
if ( !mUserIcon.isNull() )
{
icon = mUserIcon;
}
else
{
QString msgIcon( "/mIconInfo.png" );
switch ( mLevel )
{
case QgsMessageBar::CRITICAL:
msgIcon = QString( "/mIconCritical.png" );
break;
case QgsMessageBar::WARNING:
msgIcon = QString( "/mIconWarn.png" );
break;
default:
break;
}
icon = QgsApplication::getThemeIcon( msgIcon );
}
mLblIcon->setPixmap( icon.pixmap( 24 ) );

// TITLE AND TEXT
if ( mTitle.isEmpty() && mText.isEmpty() )
{
Expand Down Expand Up @@ -133,47 +162,13 @@ void QgsMessageBarItem::writeContent()
// WIDGET
if ( mWidget != 0 )
{
int idx = 0;
if ( mTextEdit != 0 )
idx = 1;

QLayoutItem *item = mLayout->itemAt( idx );
QLayoutItem *item = mLayout->itemAt( 2 );
if ( !item || item->widget() != mWidget )
{
mLayout->insertWidget( idx, mWidget );
mLayout->addWidget( mWidget );
}
}

// ICON
if ( mLblIcon == 0 )
{
mLblIcon = new QLabel( this );
mLayout->addWidget( mLblIcon );
}
QIcon icon;
if ( !mUserIcon.isNull() )
{
icon = mUserIcon;
}
else
{
QString msgIcon( "/mIconInfo.png" );
switch ( mLevel )
{
case QgsMessageBar::CRITICAL:
msgIcon = QString( "/mIconCritical.png" );
break;
case QgsMessageBar::WARNING:
msgIcon = QString( "/mIconWarn.png" );
break;
default:
break;
}
icon = QgsApplication::getThemeIcon( msgIcon );
}
mLblIcon->setPixmap( icon.pixmap( 24 ) );


// STYLESHEET
if ( mLevel >= QgsMessageBar::CRITICAL )
{
Expand Down Expand Up @@ -220,10 +215,7 @@ QgsMessageBarItem *QgsMessageBarItem::setWidget( QWidget *widget )
if ( mWidget != 0 )
{
QLayoutItem *item;
int idx = 0;
if ( mTextEdit != 0 )
idx = 1;
item = mLayout->itemAt( idx );
item = mLayout->itemAt( 2 );
if ( item->widget() == mWidget )
{
delete item->widget();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmessagebaritem.h
Expand Up @@ -26,7 +26,7 @@
#include <QHBoxLayout>


class QgsMessageBarItem : public QWidget
class GUI_EXPORT QgsMessageBarItem : public QWidget
{
Q_OBJECT
public:
Expand Down

0 comments on commit 05a41e3

Please sign in to comment.