diff options
-rw-r--r-- | desktop-widgets/downloadfromdivecomputer.cpp | 3 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 15 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.h | 5 | ||||
-rw-r--r-- | desktop-widgets/notificationwidget.cpp | 5 | ||||
-rw-r--r-- | desktop-widgets/notificationwidget.h | 3 |
5 files changed, 11 insertions, 20 deletions
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index fce287665..ac4fc320f 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -222,9 +222,6 @@ void DownloadFromDCWidget::updateState(states state) else if (state == ERROR) { timer->stop(); - // Show messages that worker thread produced. - MainWindow::instance()->showErrors(); - QMessageBox::critical(this, TITLE_OR_TEXT(tr("Error"), thread.error), QMessageBox::Ok); markChildrenAsEnabled(); progress_bar_text = ""; diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 26c67a261..7fa12c524 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -91,21 +91,9 @@ MainWindow *MainWindow::m_Instance = NULL; extern "C" void showErrorFromC() { - // Show errors only if we are running in the GUI thread. - // If we're not in the GUI thread, let errors accumulate. - if (QThread::currentThread() != QCoreApplication::instance()->thread()) - return; - MainWindow *mainwindow = MainWindow::instance(); if (mainwindow) - mainwindow->showErrors(); -} - -void MainWindow::showErrors() -{ - const char *error = get_error_string(); - if (!empty_string(error)) - getNotificationWidget()->showNotification(error, KMessageWidget::Error); + emit mainwindow->showError(get_error_string()); } MainWindow::MainWindow() : QMainWindow(), @@ -219,6 +207,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); connect(this, SIGNAL(startDiveSiteEdit()), this, SLOT(on_actionDiveSiteEdit_triggered())); connect(information(), SIGNAL(diveSiteChanged(struct dive_site *)), mapWidget, SLOT(centerOnDiveSite(struct dive_site *))); + connect(this, &MainWindow::showError, ui.mainErrorMessage, &NotificationWidget::showError, Qt::AutoConnection); wtu = new WindowTitleUpdate(); connect(WindowTitleUpdate::instance(), SIGNAL(updateTitle()), this, SLOT(setAutomaticTitle())); diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h index 18b03cb61..09b1fd9da 100644 --- a/desktop-widgets/mainwindow.h +++ b/desktop-widgets/mainwindow.h @@ -88,10 +88,6 @@ public: void enableDisableCloudActions(); void setCheckedActionFilterTags(bool checked); - // Shows errors that have accumulated. - // Must be called from GUI thread. - void showErrors(); - private slots: /* file menu action */ @@ -159,6 +155,7 @@ protected: signals: void startDiveSiteEdit(); + void showError(QString message); public slots: diff --git a/desktop-widgets/notificationwidget.cpp b/desktop-widgets/notificationwidget.cpp index e0227010c..7c156ee5c 100644 --- a/desktop-widgets/notificationwidget.cpp +++ b/desktop-widgets/notificationwidget.cpp @@ -16,6 +16,11 @@ void NotificationWidget::showNotification(QString message, KMessageWidget::Messa animatedShow(); } +void NotificationWidget::showError(QString message) +{ + showNotification(message, KMessageWidget::Error); +} + void NotificationWidget::hideNotification() { animatedHide(); diff --git a/desktop-widgets/notificationwidget.h b/desktop-widgets/notificationwidget.h index 70d94b8d6..93fc62605 100644 --- a/desktop-widgets/notificationwidget.h +++ b/desktop-widgets/notificationwidget.h @@ -21,6 +21,9 @@ public: void hideNotification(); QString getNotificationText(); +public +slots: + void showError(QString message); private: QFutureWatcher<void> future_watcher; |