From 478baf107623c3aa0c31c3256cfc3bc794b089b1 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 21 May 2013 23:13:45 -0700 Subject: Replace GError handling with a kMessageWidget based approach Instead of passing pointers to GError around we pass just pointers to error message texts around and use kMessageWidget to show those. Problem is that right now the close button on that doesn't do a thing - so the error stays around indefinitely. Oops. Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 18 ++++++++++++++---- qt-ui/mainwindow.h | 1 + qt-ui/mainwindow.ui | 3 +++ 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index deaab4715..12c803786 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -40,6 +40,7 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()) setWindowIcon(QIcon(":subsurface-icon")); connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); ui->globeMessage->hide(); + ui->mainErrorMessage->hide(); ui->globe->setMessageWidget(ui->globeMessage); ui->globeMessage->setCloseButtonVisible(false); ui->ProfileWidget->setFocusProxy(ui->ListWidget); @@ -79,14 +80,13 @@ void MainWindow::on_actionOpen_triggered() on_actionClose_triggered(); - GError *error = NULL; + char *error = NULL; parse_file(fileNamePtr.data(), &error); set_filename(fileNamePtr.data(), TRUE); if (error != NULL) { - QMessageBox::warning(this, "Error", error->message); - g_error_free(error); - error = NULL; + showError(error); + free(error); } process_dives(FALSE, FALSE); @@ -533,3 +533,13 @@ void MainWindow::file_save(void) save_dives(existing_filename); mark_divelist_changed(FALSE); } + +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(); +} diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 121b5c74d..a5b1a9b48 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -39,6 +39,7 @@ public: MainTab *information(); DiveListView *dive_list(); GlobeGPS *globe(); + void showError(QString message); private Q_SLOTS: diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 36f594d2d..658f22c41 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -95,6 +95,9 @@ + + + -- cgit v1.2.3-70-g09d2