Skip to content
Permalink
Browse files
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 a0628bf6daafb7a86e7cac0a6d87ed821240d7f2
Showing with 25 additions and 11 deletions.
  1. +9 −2 python/gui/qgsmessagebar.sip
  2. +3 −3 src/app/qgisapp.cpp
  3. +4 −4 src/gui/qgsmessagebar.cpp
  4. +9 −2 src/gui/qgsmessagebar.h
@@ -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
@@ -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 );
}
}
}
@@ -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;
}

@@ -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 );
}

}
@@ -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; } ";
@@ -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

0 comments on commit a0628bf

Please sign in to comment.