2017-04-27 20:26:05 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-02-26 16:07:39 +02:00
|
|
|
#include "notificationwidget.h"
|
|
|
|
|
|
|
|
NotificationWidget::NotificationWidget(QWidget *parent) : KMessageWidget(parent)
|
|
|
|
{
|
2018-01-28 21:50:25 +01:00
|
|
|
connect(&future_watcher, SIGNAL(finished()), this, SLOT(finish()));
|
2015-02-26 16:07:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationWidget::showNotification(QString message, KMessageWidget::MessageType type)
|
|
|
|
{
|
|
|
|
if (message.isEmpty())
|
|
|
|
return;
|
|
|
|
setText(message);
|
|
|
|
setCloseButtonVisible(true);
|
|
|
|
setMessageType(type);
|
|
|
|
animatedShow();
|
|
|
|
}
|
|
|
|
|
2018-01-28 22:08:30 +01:00
|
|
|
void NotificationWidget::showError(QString message)
|
|
|
|
{
|
|
|
|
showNotification(message, KMessageWidget::Error);
|
|
|
|
}
|
|
|
|
|
2015-02-26 16:07:39 +02:00
|
|
|
void NotificationWidget::hideNotification()
|
|
|
|
{
|
|
|
|
animatedHide();
|
|
|
|
}
|
|
|
|
|
2015-06-14 14:18:51 -07:00
|
|
|
QString NotificationWidget::getNotificationText()
|
|
|
|
{
|
|
|
|
return text();
|
|
|
|
}
|
|
|
|
|
2015-02-26 16:07:39 +02:00
|
|
|
void NotificationWidget::setFuture(const QFuture<void> &future)
|
|
|
|
{
|
2018-01-28 21:50:25 +01:00
|
|
|
future_watcher.setFuture(future);
|
2015-02-26 16:07:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationWidget::finish()
|
|
|
|
{
|
|
|
|
hideNotification();
|
|
|
|
}
|