Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add descriptive names to message bar levels (from Matthais Kuhn)
- Enum containing INFO, WARNING and CRITICAL
  • Loading branch information
dakcarto committed Jan 12, 2013
1 parent a9e1d07 commit a0628bf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
11 changes: 9 additions & 2 deletions python/gui/qgsmessagebar.sip
Expand Up @@ -5,16 +5,23 @@ class QgsMessageBar: QFrame
%End

public:
enum MessageLevel
{
INFO = 0,
WARNING = 1,
CRITICAL = 2
};

QgsMessageBar( QWidget *parent = 0 );
~QgsMessageBar();

/*! display a widget on the bar after hiding the currently visible one
* and putting it in a stack
* @param widget widget to add
* @param level is 0 for information, 1 for warning, 2 for critical
* @param level is QgsMessageBar::INFO, WARNING or CRITICAL
* @param duration timeout duration of message in seconds, 0 value indicates no timeout
*/
void pushWidget( QWidget *widget /Transfer/, int level = 0, int duration = 0 );
void pushWidget( QWidget *widget /Transfer/, MessageLevel level = INFO, int duration = 0 );

/*! remove the passed widget from the bar (if previously added),
* then display the next one in the stack if any or hide the bar
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -3427,7 +3427,7 @@ bool QgisApp::addProject( QString projectFile )
macroMsg->layout()->addWidget( btnEnableMacros );

// display the macros notification widget
mInfoBar->pushWidget( macroMsg, 1 );
mInfoBar->pushWidget( macroMsg, QgsMessageBar::WARNING );
}
}
}
Expand Down Expand Up @@ -4034,7 +4034,7 @@ void QgisApp::labeling()
tr( "Please select a vector layer first." ) ,
QgsApplication::getThemeIcon( "/mIconWarn.png" ),
mInfoBar );
mInfoBar->pushWidget( msg, 1, 4 );
mInfoBar->pushWidget( msg, QgsMessageBar::WARNING, 4 );
return;
}

Expand Down Expand Up @@ -5759,7 +5759,7 @@ void QgisApp::duplicateLayers( QList<QgsMapLayer *> lyrList )
// display errors in message bar after duplication of layers
foreach ( QWidget * msgBar, msgBars )
{
mInfoBar->pushWidget( msgBar, 1 );
mInfoBar->pushWidget( msgBar, QgsMessageBar::WARNING );
}

}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsmessagebar.cpp
Expand Up @@ -228,22 +228,22 @@ void QgsMessageBar::pushItem( QgsMessageBarItem *item )
emit widgetAdded( item->widget() );
}

void QgsMessageBar::pushWidget( QWidget *widget, int level, int duration )
void QgsMessageBar::pushWidget( QWidget *widget, MessageLevel level, int duration )
{
resetCountdown();

QString stylesheet;
if ( level >= 2 )
if ( level >= CRITICAL )
{
stylesheet = "QgsMessageBar { background-color: #d65253; border: 1px solid #9b3d3d; } "
"QLabel { color: white; } ";
}
else if ( level == 1 )
else if ( level == WARNING )
{
stylesheet = "QgsMessageBar { background-color: #ffc800; border: 1px solid #e0aa00; } "
"QLabel { color: black; } ";
}
else if ( level <= 0 )
else if ( level <= INFO )
{
stylesheet = "QgsMessageBar { background-color: #e7f5fe; border: 1px solid #b9cfe4; } "
"QLabel { color: #2554a1; } ";
Expand Down
11 changes: 9 additions & 2 deletions src/gui/qgsmessagebar.h
Expand Up @@ -43,16 +43,23 @@ class GUI_EXPORT QgsMessageBar: public QFrame
Q_OBJECT

public:
enum MessageLevel
{
INFO = 0,
WARNING = 1,
CRITICAL = 2
};

QgsMessageBar( QWidget *parent = 0 );
~QgsMessageBar();

/*! display a widget on the bar after hiding the currently visible one
* and putting it in a stack
* @param widget widget to add
* @param level is 0 for information, 1 for warning, 2 for critical
* @param level is QgsMessageBar::INFO, WARNING or CRITICAL
* @param duration timeout duration of message in seconds, 0 value indicates no timeout
*/
void pushWidget( QWidget *widget, int level = 0, int duration = 0 );
void pushWidget( QWidget *widget, MessageLevel level = INFO, int duration = 0 );

/*! remove the passed widget from the bar (if previously added),
* then display the next one in the stack if any or hide the bar
Expand Down

0 comments on commit a0628bf

Please sign in to comment.