Skip to content

Commit a0628bf

Browse files
committedJan 12, 2013
Add descriptive names to message bar levels (from Matthais Kuhn)
- Enum containing INFO, WARNING and CRITICAL
1 parent a9e1d07 commit a0628bf

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed
 

‎python/gui/qgsmessagebar.sip

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ class QgsMessageBar: QFrame
55
%End
66

77
public:
8+
enum MessageLevel
9+
{
10+
INFO = 0,
11+
WARNING = 1,
12+
CRITICAL = 2
13+
};
14+
815
QgsMessageBar( QWidget *parent = 0 );
916
~QgsMessageBar();
1017

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

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

‎src/app/qgisapp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3427,7 +3427,7 @@ bool QgisApp::addProject( QString projectFile )
34273427
macroMsg->layout()->addWidget( btnEnableMacros );
34283428

34293429
// display the macros notification widget
3430-
mInfoBar->pushWidget( macroMsg, 1 );
3430+
mInfoBar->pushWidget( macroMsg, QgsMessageBar::WARNING );
34313431
}
34323432
}
34333433
}
@@ -4034,7 +4034,7 @@ void QgisApp::labeling()
40344034
tr( "Please select a vector layer first." ) ,
40354035
QgsApplication::getThemeIcon( "/mIconWarn.png" ),
40364036
mInfoBar );
4037-
mInfoBar->pushWidget( msg, 1, 4 );
4037+
mInfoBar->pushWidget( msg, QgsMessageBar::WARNING, 4 );
40384038
return;
40394039
}
40404040

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

57655765
}

‎src/gui/qgsmessagebar.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,22 +228,22 @@ void QgsMessageBar::pushItem( QgsMessageBarItem *item )
228228
emit widgetAdded( item->widget() );
229229
}
230230

231-
void QgsMessageBar::pushWidget( QWidget *widget, int level, int duration )
231+
void QgsMessageBar::pushWidget( QWidget *widget, MessageLevel level, int duration )
232232
{
233233
resetCountdown();
234234

235235
QString stylesheet;
236-
if ( level >= 2 )
236+
if ( level >= CRITICAL )
237237
{
238238
stylesheet = "QgsMessageBar { background-color: #d65253; border: 1px solid #9b3d3d; } "
239239
"QLabel { color: white; } ";
240240
}
241-
else if ( level == 1 )
241+
else if ( level == WARNING )
242242
{
243243
stylesheet = "QgsMessageBar { background-color: #ffc800; border: 1px solid #e0aa00; } "
244244
"QLabel { color: black; } ";
245245
}
246-
else if ( level <= 0 )
246+
else if ( level <= INFO )
247247
{
248248
stylesheet = "QgsMessageBar { background-color: #e7f5fe; border: 1px solid #b9cfe4; } "
249249
"QLabel { color: #2554a1; } ";

‎src/gui/qgsmessagebar.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,23 @@ class GUI_EXPORT QgsMessageBar: public QFrame
4343
Q_OBJECT
4444

4545
public:
46+
enum MessageLevel
47+
{
48+
INFO = 0,
49+
WARNING = 1,
50+
CRITICAL = 2
51+
};
52+
4653
QgsMessageBar( QWidget *parent = 0 );
4754
~QgsMessageBar();
4855

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.