File tree Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -5,16 +5,23 @@ class QgsMessageBar: QFrame
5
5
%End
6
6
7
7
public:
8
+ enum MessageLevel
9
+ {
10
+ INFO = 0,
11
+ WARNING = 1,
12
+ CRITICAL = 2
13
+ };
14
+
8
15
QgsMessageBar( QWidget *parent = 0 );
9
16
~QgsMessageBar();
10
17
11
18
/*! display a widget on the bar after hiding the currently visible one
12
19
* and putting it in a stack
13
20
* @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
15
22
* @param duration timeout duration of message in seconds, 0 value indicates no timeout
16
23
*/
17
- void pushWidget( QWidget *widget /Transfer/, int level = 0 , int duration = 0 );
24
+ void pushWidget( QWidget *widget /Transfer/, MessageLevel level = INFO , int duration = 0 );
18
25
19
26
/*! remove the passed widget from the bar (if previously added),
20
27
* then display the next one in the stack if any or hide the bar
Original file line number Diff line number Diff line change @@ -3427,7 +3427,7 @@ bool QgisApp::addProject( QString projectFile )
3427
3427
macroMsg->layout ()->addWidget ( btnEnableMacros );
3428
3428
3429
3429
// display the macros notification widget
3430
- mInfoBar ->pushWidget ( macroMsg, 1 );
3430
+ mInfoBar ->pushWidget ( macroMsg, QgsMessageBar::WARNING );
3431
3431
}
3432
3432
}
3433
3433
}
@@ -4034,7 +4034,7 @@ void QgisApp::labeling()
4034
4034
tr ( " Please select a vector layer first." ) ,
4035
4035
QgsApplication::getThemeIcon ( " /mIconWarn.png" ),
4036
4036
mInfoBar );
4037
- mInfoBar ->pushWidget ( msg, 1 , 4 );
4037
+ mInfoBar ->pushWidget ( msg, QgsMessageBar::WARNING , 4 );
4038
4038
return ;
4039
4039
}
4040
4040
@@ -5759,7 +5759,7 @@ void QgisApp::duplicateLayers( QList<QgsMapLayer *> lyrList )
5759
5759
// display errors in message bar after duplication of layers
5760
5760
foreach ( QWidget * msgBar, msgBars )
5761
5761
{
5762
- mInfoBar ->pushWidget ( msgBar, 1 );
5762
+ mInfoBar ->pushWidget ( msgBar, QgsMessageBar::WARNING );
5763
5763
}
5764
5764
5765
5765
}
Original file line number Diff line number Diff line change @@ -228,22 +228,22 @@ void QgsMessageBar::pushItem( QgsMessageBarItem *item )
228
228
emit widgetAdded ( item->widget () );
229
229
}
230
230
231
- void QgsMessageBar::pushWidget ( QWidget *widget, int level, int duration )
231
+ void QgsMessageBar::pushWidget ( QWidget *widget, MessageLevel level, int duration )
232
232
{
233
233
resetCountdown ();
234
234
235
235
QString stylesheet;
236
- if ( level >= 2 )
236
+ if ( level >= CRITICAL )
237
237
{
238
238
stylesheet = " QgsMessageBar { background-color: #d65253; border: 1px solid #9b3d3d; } "
239
239
" QLabel { color: white; } " ;
240
240
}
241
- else if ( level == 1 )
241
+ else if ( level == WARNING )
242
242
{
243
243
stylesheet = " QgsMessageBar { background-color: #ffc800; border: 1px solid #e0aa00; } "
244
244
" QLabel { color: black; } " ;
245
245
}
246
- else if ( level <= 0 )
246
+ else if ( level <= INFO )
247
247
{
248
248
stylesheet = " QgsMessageBar { background-color: #e7f5fe; border: 1px solid #b9cfe4; } "
249
249
" QLabel { color: #2554a1; } " ;
Original file line number Diff line number Diff line change @@ -43,16 +43,23 @@ class GUI_EXPORT QgsMessageBar: public QFrame
43
43
Q_OBJECT
44
44
45
45
public:
46
+ enum MessageLevel
47
+ {
48
+ INFO = 0 ,
49
+ WARNING = 1 ,
50
+ CRITICAL = 2
51
+ };
52
+
46
53
QgsMessageBar ( QWidget *parent = 0 );
47
54
~QgsMessageBar ();
48
55
49
56
/* ! display a widget on the bar after hiding the currently visible one
50
57
* and putting it in a stack
51
58
* @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
53
60
* @param duration timeout duration of message in seconds, 0 value indicates no timeout
54
61
*/
55
- void pushWidget ( QWidget *widget, int level = 0 , int duration = 0 );
62
+ void pushWidget ( QWidget *widget, MessageLevel level = INFO , int duration = 0 );
56
63
57
64
/* ! remove the passed widget from the bar (if previously added),
58
65
* then display the next one in the stack if any or hide the bar
You can’t perform that action at this time.
0 commit comments