Add support for warning messages.

This commit is contained in:
craig.p.drummond
2013-10-08 17:58:58 +00:00
committed by craig.p.drummond
parent f5c6887ca9
commit aeeccd3d4e
2 changed files with 8 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ MessageWidget::~MessageWidget()
#endif
#endif
void MessageWidget::setMessage(const QString &msg, bool isError)
void MessageWidget::setMessage(const QString &msg, MessageType type, bool showCloseButton)
{
if (msg.isEmpty() && isVisible()) {
setVisible(false);
@@ -56,7 +56,8 @@ void MessageWidget::setMessage(const QString &msg, bool isError)
setToolTip(msg);
}
setText(text);
setMessageType(isError ? Error : Information);
setMessageType(type);
setCloseButtonVisible(showCloseButton);
#if defined NO_ANIMATED_SHOW
setVisible(true);
#else

View File

@@ -40,10 +40,12 @@ class MessageWidget : public KMsgWidget
{
Q_OBJECT
public:
MessageWidget(QWidget *parent);
virtual ~MessageWidget();
void setError(const QString &msg) { setMessage(msg, true); }
void setInformation(const QString &msg) { setMessage(msg, false); }
void setError(const QString &msg, bool showCloseButton=true) { setMessage(msg, Error, showCloseButton); }
void setInformation(const QString &msg, bool showCloseButton=true) { setMessage(msg, Information, showCloseButton); }
void setWarning(const QString &msg, bool showCloseButton=true) { setMessage(msg, Warning, showCloseButton); }
void setVisible(bool v);
bool isActive() const { return active; }
@@ -51,7 +53,7 @@ Q_SIGNALS:
void visible(bool);
private:
void setMessage(const QString &msg, bool isError);
void setMessage(const QString &msg, MessageType type, bool showCloseButton);
private:
bool active;