19
#include "MessageWidget.h"
21
#include <QDesktopServices>
25
const int MessageWidget::DefaultAutoHideTimeout = 6000;
26
const int MessageWidget::LongAutoHideTimeout = 15000;
27
const int MessageWidget::DisableAutoHide = -1;
29
MessageWidget::MessageWidget(QWidget* parent)
30
: KMessageWidget(parent)
31
, m_autoHideTimer(new QTimer(this))
32
, m_autoHideTimeout(DefaultAutoHideTimeout)
34
m_autoHideTimer->setSingleShot(true);
35
connect(m_autoHideTimer, SIGNAL(timeout()), this, SLOT(animatedHide()));
36
connect(this, SIGNAL(hideAnimationFinished()), m_autoHideTimer, SLOT(stop()));
39
void MessageWidget::setAnimate(bool state)
44
int MessageWidget::autoHideTimeout() const
46
return m_autoHideTimeout;
49
void MessageWidget::showMessage(const QString& text, MessageWidget::MessageType type)
51
showMessage(text, type, m_autoHideTimeout);
54
void MessageWidget::showMessage(const QString& text, KMessageWidget::MessageType type, int autoHideTimeout)
59
emit showAnimationStarted();
64
emit showAnimationFinished();
67
if (autoHideTimeout > 0) {
68
m_autoHideTimer->start(autoHideTimeout);
70
m_autoHideTimer->stop();
74
void MessageWidget::hideMessage()
76
emit hideAnimationStarted();
81
emit hideAnimationFinished();
84
m_autoHideTimer->stop();
87
void MessageWidget::setAutoHideTimeout(int autoHideTimeout)
89
m_autoHideTimeout = autoHideTimeout;
90
if (autoHideTimeout <= 0) {
91
m_autoHideTimer->stop();
101
void MessageWidget::openHttpUrl(const QString& link)
103
if (link.startsWith("http://") || link.startsWith("https://")) {
104
QDesktopServices::openUrl(QUrl(link));