subsurface/desktop-widgets/notificationwidget.cpp
Berthold Stoeger 1704e08012 Make future_watcher a subobject of NotificationWidget
This was a raw pointer. No point in doing error-prone manual
memory management.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31 14:47:26 +01:00

37 lines
745 B
C++

// SPDX-License-Identifier: GPL-2.0
#include "notificationwidget.h"
NotificationWidget::NotificationWidget(QWidget *parent) : KMessageWidget(parent)
{
connect(&future_watcher, SIGNAL(finished()), this, SLOT(finish()));
}
void NotificationWidget::showNotification(QString message, KMessageWidget::MessageType type)
{
if (message.isEmpty())
return;
setText(message);
setCloseButtonVisible(true);
setMessageType(type);
animatedShow();
}
void NotificationWidget::hideNotification()
{
animatedHide();
}
QString NotificationWidget::getNotificationText()
{
return text();
}
void NotificationWidget::setFuture(const QFuture<void> &future)
{
future_watcher.setFuture(future);
}
void NotificationWidget::finish()
{
hideNotification();
}