Use KMessageWidget also for new error messages

This commit is contained in:
Janek Bevendorff 2017-01-15 01:44:48 +01:00
parent b6ea06ba24
commit 41d5111684
No known key found for this signature in database
GPG Key ID: CFEC2F6850BFFA53
5 changed files with 23 additions and 23 deletions

View File

@ -328,8 +328,8 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
// write the database to the file // write the database to the file
m_writer.writeDatabase(&saveFile, db); m_writer.writeDatabase(&saveFile, db);
if (m_writer.hasError()) { if (m_writer.hasError()) {
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n" Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
+ m_writer.errorString()); .append(m_writer.errorString()), MessageWidget::Error);
return false; return false;
} }
@ -342,14 +342,14 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
return true; return true;
} }
else { else {
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n" Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
+ saveFile.errorString()); .append(saveFile.errorString()), MessageWidget::Error);
return false; return false;
} }
} }
else { else {
Q_EMIT messageTab(tr("Writing the database failed.\n") Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
.append("\n").append(saveFile.errorString()), MessageWidget::Error); .append(saveFile.errorString()), MessageWidget::Error);
return false; return false;
} }
} }
@ -494,7 +494,7 @@ void DatabaseTabWidget::exportToCsv()
CsvExporter csvExporter; CsvExporter csvExporter;
if (!csvExporter.exportDatabase(fileName, db)) { if (!csvExporter.exportDatabase(fileName, db)) {
Q_EMIT messageGlobal( Q_EMIT messageGlobal(
tr("Writing the CSV file failed.").append("\n\n") tr("Writing the CSV file failed.").append("\n")
.append(csvExporter.errorString()), MessageWidget::Error); .append(csvExporter.errorString()), MessageWidget::Error);
} }
} }

View File

@ -696,7 +696,7 @@ void DatabaseWidget::updateMasterKey(bool accepted)
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
if (!result) { if (!result) {
MessageBox::critical(this, tr("Error"), tr("Unable to calculate master key")); m_messageWidget->showMessage(tr("Unable to calculate master key"), MessageWidget::Error);
return; return;
} }
} }
@ -736,14 +736,14 @@ void DatabaseWidget::mergeDatabase(bool accepted)
{ {
if (accepted) { if (accepted) {
if (!m_db) { if (!m_db) {
MessageBox::critical(this, tr("Error"), tr("No current database.")); m_messageWidget->showMessage(tr("No current database."), MessageWidget::Error);
return; return;
} }
Database* srcDb = static_cast<DatabaseOpenWidget*>(sender())->database(); Database* srcDb = static_cast<DatabaseOpenWidget*>(sender())->database();
if (!srcDb) { if (!srcDb) {
MessageBox::critical(this, tr("Error"), tr("No source database, nothing to do.")); m_messageWidget->showMessage(tr("No source database, nothing to do."), MessageWidget::Error);
return; return;
} }
@ -1093,15 +1093,15 @@ void DatabaseWidget::reloadDatabaseFile()
} }
else { else {
MessageBox::critical(this, tr("Autoreload Failed"), m_messageWidget->showMessage(
tr("Could not parse or unlock the new database file while attempting" tr("Could not parse or unlock the new database file while attempting"
" to autoreload this database.")); " to autoreload this database."), MessageWidget::Error);
} }
} }
else { else {
MessageBox::critical(this, tr("Autoreload Failed"), m_messageWidget->showMessage(
tr("Could not open the new database file while attempting to autoreload" tr("Could not open the new database file while attempting to autoreload this database."),
" this database.")); MessageWidget::Error);
} }
// Rewatch the database file // Rewatch the database file

View File

@ -49,8 +49,8 @@ void KeePass1OpenWidget::openDatabase()
QFile file(m_filename); QFile file(m_filename);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") m_ui->messageWidget->showMessage( tr("Unable to open the database.").append("\n")
.append(file.errorString())); .append(file.errorString()), MessageWidget::Error);
return; return;
} }
if (m_db) { if (m_db) {

View File

@ -761,7 +761,7 @@ void MainWindow::repairDatabase()
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
return; return;
} }
QScopedPointer<QDialog> dialog(new QDialog(this)); QScopedPointer<QDialog> dialog(new QDialog(this));
DatabaseRepairWidget* dbRepairWidget = new DatabaseRepairWidget(dialog.data()); DatabaseRepairWidget* dbRepairWidget = new DatabaseRepairWidget(dialog.data());
connect(dbRepairWidget, SIGNAL(success()), dialog.data(), SLOT(accept())); connect(dbRepairWidget, SIGNAL(success()), dialog.data(), SLOT(accept()));
@ -776,8 +776,9 @@ void MainWindow::repairDatabase()
KeePass2Writer writer; KeePass2Writer writer;
writer.writeDatabase(saveFileName, dbRepairWidget->database()); writer.writeDatabase(saveFileName, dbRepairWidget->database());
if (writer.hasError()) { if (writer.hasError()) {
QMessageBox::critical(this, tr("Error"), displayGlobalMessage(
tr("Writing the database failed.").append("\n\n").append(writer.errorString())); tr("Writing the database failed.").append("\n").append(writer.errorString()),
MessageWidget::Error);
} }
} }
} }

View File

@ -704,8 +704,7 @@ void EditEntryWidget::openAttachment(const QModelIndex& index)
} }
if (!file->flush()) { if (!file->flush()) {
MessageBox::warning(this, tr("Error"), showMessage(tr("Unable to save the attachment:\n").append(file->errorString()), MessageWidget::Error);
tr("Unable to save the attachment:\n").append(file->errorString()));
return; return;
} }