From 34150730518e4d307d618d025505b2a0d1afb97a Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 20 May 2016 16:49:32 +0200 Subject: [PATCH] Display an error message when opening the database fails. Closes #462 --- src/gui/DatabaseOpenWidget.cpp | 3 ++- src/gui/DatabaseRepairWidget.cpp | 3 ++- src/gui/DatabaseTabWidget.cpp | 5 ++--- src/gui/KeePass1OpenWidget.cpp | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index beb8d54c67..a4b22074f5 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -100,7 +100,8 @@ void DatabaseOpenWidget::openDatabase() QFile file(m_filename); if (!file.open(QIODevice::ReadOnly)) { - // TODO: error message + MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") + .append(file.errorString())); return; } if (m_db) { diff --git a/src/gui/DatabaseRepairWidget.cpp b/src/gui/DatabaseRepairWidget.cpp index f1b760f990..e48e0f1f6a 100644 --- a/src/gui/DatabaseRepairWidget.cpp +++ b/src/gui/DatabaseRepairWidget.cpp @@ -60,7 +60,8 @@ void DatabaseRepairWidget::openDatabase() QFile file(m_filename); if (!file.open(QIODevice::ReadOnly)) { - // TODO: error message + MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") + .append(file.errorString())); Q_EMIT editFinished(false); return; } diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 69b4f7e729..78a3a12a1c 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -132,11 +132,10 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw, // test if we can read/write or read the file QFile file(fileName); - // TODO: error handling if (!file.open(QIODevice::ReadWrite)) { if (!file.open(QIODevice::ReadOnly)) { - // can't open - // TODO: error message + MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") + .append(file.errorString())); return; } else { diff --git a/src/gui/KeePass1OpenWidget.cpp b/src/gui/KeePass1OpenWidget.cpp index 96ddf13f29..4f70a97877 100644 --- a/src/gui/KeePass1OpenWidget.cpp +++ b/src/gui/KeePass1OpenWidget.cpp @@ -49,7 +49,8 @@ void KeePass1OpenWidget::openDatabase() QFile file(m_filename); if (!file.open(QIODevice::ReadOnly)) { - // TODO: error message + MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") + .append(file.errorString())); return; } if (m_db) {