aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/notificationwidget.cpp
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-02-26 16:07:39 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-27 06:31:06 +0100
commit59ab849854bec7f61a527c4b6e5a1f063c57abb8 (patch)
tree9edc9025f935ab46d55c9eb72f0b38a47ac119fa /qt-ui/notificationwidget.cpp
parente6482bbdc8a1359d51c70aaf847d3aac7895b960 (diff)
downloadsubsurface-59ab849854bec7f61a527c4b6e5a1f063c57abb8.tar.gz
Creating a Notification widget in the Main Window.
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>
Diffstat (limited to 'qt-ui/notificationwidget.cpp')
-rw-r--r--qt-ui/notificationwidget.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/qt-ui/notificationwidget.cpp b/qt-ui/notificationwidget.cpp
new file mode 100644
index 000000000..44e2eed1b
--- /dev/null
+++ b/qt-ui/notificationwidget.cpp
@@ -0,0 +1,37 @@
+#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;
+}