mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
59ab849854
The main error message bar can be used to show exporting information and other notification. So a new Notification handler object is created in the main window <NotificationWidget> that inherits <KMessageWidget> that shows different type of notifications, ex. (Warning, Error and information) Also this class contains a QFutureWatcher object that is set to handle the QFuture variable returned from the exporting thread. this will allow the UI to be updated when the thread finishes execution. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
37 lines
755 B
C++
37 lines
755 B
C++
#include "notificationwidget.h"
|
|
|
|
NotificationWidget::NotificationWidget(QWidget *parent) : KMessageWidget(parent)
|
|
{
|
|
future_watcher = new QFutureWatcher<void>();
|
|
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();
|
|
}
|
|
|
|
void NotificationWidget::setFuture(const QFuture<void> &future)
|
|
{
|
|
future_watcher->setFuture(future);
|
|
}
|
|
|
|
void NotificationWidget::finish()
|
|
{
|
|
hideNotification();
|
|
}
|
|
|
|
NotificationWidget::~NotificationWidget()
|
|
{
|
|
delete future_watcher;
|
|
}
|