mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Add descriptive names to message bar levels (from Matthais Kuhn)
- Enum containing INFO, WARNING and CRITICAL
This commit is contained in:
parent
a9e1d07c32
commit
a0628bf6da
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user