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
m_writer.writeDatabase(&saveFile, db);
if (m_writer.hasError()) {
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
+ m_writer.errorString());
Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
.append(m_writer.errorString()), MessageWidget::Error);
return false;
}
@ -342,14 +342,14 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
return true;
}
else {
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
+ saveFile.errorString());
Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
.append(saveFile.errorString()), MessageWidget::Error);
return false;
}
}
else {
Q_EMIT messageTab(tr("Writing the database failed.\n")
.append("\n").append(saveFile.errorString()), MessageWidget::Error);
Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
.append(saveFile.errorString()), MessageWidget::Error);
return false;
}
}
@ -494,7 +494,7 @@ void DatabaseTabWidget::exportToCsv()
CsvExporter csvExporter;
if (!csvExporter.exportDatabase(fileName, db)) {
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);
}
}

View File

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

View File

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

View File

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