summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelogexportdialog.cpp6
-rw-r--r--qt-ui/mainwindow.cpp12
-rw-r--r--qt-ui/mainwindow.h2
-rw-r--r--qt-ui/mainwindow.ui6
-rw-r--r--qt-ui/notificationwidget.cpp37
-rw-r--r--qt-ui/notificationwidget.h31
6 files changed, 84 insertions, 10 deletions
diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 43c41550f..ff8317062 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -9,6 +9,7 @@
#include "subsurfacewebservices.h"
#include "worldmap-save.h"
#include "save-html.h"
+#include "mainwindow.h"
#define GET_UNIT(name, field, f, t) \
v = settings.value(QString(name)); \
@@ -312,8 +313,11 @@ void DiveLogExportDialog::on_buttonBox_accepted()
settings.setValue("LastDir", fileInfo.dir().path());
settings.endGroup();
// the non XSLT exports are called directly above, the XSLT based ons are called here
- if (!stylesheet.isEmpty())
+ if (!stylesheet.isEmpty()) {
future = QtConcurrent::run(export_dives_xslt, filename.toUtf8(), ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8());
+ MainWindow::instance()->getNotificationWidget()->showNotification("Exporting...", KMessageWidget::Information);
+ MainWindow::instance()->getNotificationWidget()->setFuture(future);
+ }
}
}
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 8dcb59c90..de98eb08f 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1308,12 +1308,12 @@ int MainWindow::file_save(void)
void MainWindow::showError(QString message)
{
- if (message.isEmpty())
- return;
- ui.mainErrorMessage->setText(message);
- ui.mainErrorMessage->setCloseButtonVisible(true);
- ui.mainErrorMessage->setMessageType(KMessageWidget::Error);
- ui.mainErrorMessage->animatedShow();
+ ui.mainErrorMessage->showNotification(message, KMessageWidget::Error);
+}
+
+NotificationWidget *MainWindow::getNotificationWidget()
+{
+ return ui.mainErrorMessage;
}
void MainWindow::setTitle(enum MainWindowTitleFormat format)
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 7514a0938..06b180a39 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -13,6 +13,7 @@
#include <QUuid>
#include "ui_mainwindow.h"
+#include "notificationwidget.h"
struct DiveList;
class QSortFilterProxyModel;
@@ -92,6 +93,7 @@ public:
void setApplicationState(const QByteArray& state);
void showV2Dialog();
QUndoStack *undoStack;
+ NotificationWidget *getNotificationWidget();
private
slots:
/* file menu action */
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index 41a85bf8a..82f7bcd7f 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -40,7 +40,7 @@
</widget>
</item>
<item>
- <widget class="KMessageWidget" name="mainErrorMessage" native="true"/>
+ <widget class="NotificationWidget" name="mainErrorMessage" native="true"/>
</item>
</layout>
</widget>
@@ -699,9 +699,9 @@
</widget>
<customwidgets>
<customwidget>
- <class>KMessageWidget</class>
+ <class>NotificationWidget</class>
<extends>QWidget</extends>
- <header>kmessagewidget.h</header>
+ <header>notificationwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
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;
+}
diff --git a/qt-ui/notificationwidget.h b/qt-ui/notificationwidget.h
new file mode 100644
index 000000000..7a3f93b4d
--- /dev/null
+++ b/qt-ui/notificationwidget.h
@@ -0,0 +1,31 @@
+#ifndef NOTIFICATIONWIDGET_H
+#define NOTIFICATIONWIDGET_H
+
+#include <QWidget>
+#include <QFutureWatcher>
+
+#include <kmessagewidget.h>
+
+namespace Ui {
+ class NotificationWidget;
+}
+
+class NotificationWidget : public KMessageWidget {
+ Q_OBJECT
+
+public:
+ explicit NotificationWidget(QWidget *parent = 0);
+ void setFuture(const QFuture<void> &future);
+ void showNotification(QString message, KMessageWidget::MessageType type);
+ void hideNotification();
+ ~NotificationWidget();
+
+private:
+ QFutureWatcher<void> *future_watcher;
+
+private
+slots:
+ void finish();
+};
+
+#endif // NOTIFICATIONWIDGET_H