mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
a25f54e3c2
Up to now, errors produced by threads were not directly shown in the MainWindow. Code running in the GUI thread had to manually show the errors. This can be simplified by using Qt's queued connection as message passing facility. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
42 lines
853 B
C++
42 lines
853 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::showError(QString message)
|
|
{
|
|
showNotification(message, KMessageWidget::Error);
|
|
}
|
|
|
|
void NotificationWidget::hideNotification()
|
|
{
|
|
animatedHide();
|
|
}
|
|
|
|
QString NotificationWidget::getNotificationText()
|
|
{
|
|
return text();
|
|
}
|
|
|
|
void NotificationWidget::setFuture(const QFuture<void> &future)
|
|
{
|
|
future_watcher.setFuture(future);
|
|
}
|
|
|
|
void NotificationWidget::finish()
|
|
{
|
|
hideNotification();
|
|
}
|