Skip to content

Commit

Permalink
Translations and code format
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Jan 12, 2025
1 parent 33fcf75 commit e1720c2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
12 changes: 12 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2805,6 +2805,18 @@ Disable safe saves and try again?</source>
<source>Unlock to reload</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cannot save because the</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>database file &quot;%1&quot; was modified externally</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditEntryWidget</name>
Expand Down
40 changes: 20 additions & 20 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2213,17 +2213,18 @@ void DatabaseWidget::reloadDatabaseFile(bool triggeredBySave)
if (triggeredBySave || m_db->isModified() || m_db->hasNonDataChanges()) {
// Ask how to proceed
auto prefix = triggeredBySave ? tr("Cannot save because the") : tr("The");
auto result = MessageBox::question(
this,
tr("Reload database"),
QString("%1 %2.\n%3\n\n%4.\n%5.\n%6.").arg(
prefix, tr("database file \"%1\" was modified externally").arg(displayFileName()),
tr("How to proceed with your unsaved changes?"),
tr("Merge all changes together"),
tr("Discard your changes"),
tr("Ignore the changes in the file on disk")),
MessageBox::Merge | MessageBox::Discard | MessageBox::Ignore | MessageBox::Cancel,
MessageBox::Merge);
auto result =
MessageBox::question(this,
tr("Reload database"),
QString("%1 %2.\n%3\n\n%4.\n%5.\n%6.")
.arg(prefix,
tr("database file \"%1\" was modified externally").arg(displayFileName()),
tr("How to proceed with your unsaved changes?"),
tr("Merge all changes together"),
tr("Discard your changes"),
tr("Ignore the changes in the file on disk")),
MessageBox::Merge | MessageBox::Discard | MessageBox::Ignore | MessageBox::Cancel,
MessageBox::Merge);

if (result == MessageBox::Cancel) {
reloadAbort();
Expand All @@ -2249,15 +2250,14 @@ void DatabaseWidget::reloadDatabaseFile(bool triggeredBySave)
// the user needs to provide credentials
auto dbWidget = new DatabaseWidget(std::move(db));
auto openDialog = new DatabaseOpenDialog(this);
QObject::connect(openDialog, &QObject::destroyed, [=](QObject*) { dbWidget->deleteLater(); });
QObject::connect(
openDialog, &DatabaseOpenDialog::dialogFinished, this, [=](bool accepted, DatabaseWidget* dbWidget) {
if (accepted) {
reloadContinue(openDialog->database(), merge);
} else {
reloadAbort();
}
});
connect(openDialog, &QObject::destroyed, [=](QObject*) { dbWidget->deleteLater(); });
connect(openDialog, &DatabaseOpenDialog::dialogFinished, this, [=](bool accepted, DatabaseWidget*) {
if (accepted) {
reloadContinue(openDialog->database(), merge);
} else {
reloadAbort();
}
});
openDialog->setAttribute(Qt::WA_DeleteOnClose); // free the memory on close
openDialog->addDatabaseTab(dbWidget);
openDialog->setActiveDatabaseTab(dbWidget);
Expand Down

0 comments on commit e1720c2

Please sign in to comment.