summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-21 23:13:45 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-21 23:39:49 -0700
commit478baf107623c3aa0c31c3256cfc3bc794b089b1 (patch)
tree090485f799a36090bf4a301ba8611f0b5686a44a /qt-ui
parent5aa8b52f82399bd4343a8213927c7e9694def1bc (diff)
downloadsubsurface-478baf107623c3aa0c31c3256cfc3bc794b089b1.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp18
-rw-r--r--qt-ui/mainwindow.h1
-rw-r--r--qt-ui/mainwindow.ui3
3 files changed, 18 insertions, 4 deletions
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 @@
</widget>
</widget>
</item>
+ <item>
+ <widget class="KMessageWidget" name="mainErrorMessage" native="true"/>
+ </item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">