Fix pluralization of confirmation prompts

This commit is contained in:
Edward Jones 2018-03-13 20:03:59 +00:00
parent e66adfbf68
commit 963a7802d1
2 changed files with 25 additions and 28 deletions

View File

@ -479,23 +479,21 @@ void DatabaseWidget::deleteEntries()
bool inRecycleBin = Tools::hasChild(m_db->metadata()->recycleBin(), selectedEntries.first()); bool inRecycleBin = Tools::hasChild(m_db->metadata()->recycleBin(), selectedEntries.first());
if (inRecycleBin || !m_db->metadata()->recycleBinEnabled()) { if (inRecycleBin || !m_db->metadata()->recycleBinEnabled()) {
QMessageBox::StandardButton result; QString prompt;
if (selected.size() == 1) { if (selected.size() == 1) {
result = MessageBox::question( prompt = tr("Do you really want to delete the entry \"%1\" for good?")
this, tr("Delete entry?"), .arg(selectedEntries.first()->title().toHtmlEscaped());
tr("Do you really want to delete the entry \"%1\" for good?")
.arg(selectedEntries.first()->title().toHtmlEscaped()),
QMessageBox::Yes | QMessageBox::No);
} }
else { else {
result = MessageBox::question( prompt = tr("Do you really want to delete %n entry(s) for good?", "", selected.size());
this, tr("Delete entries?"),
tr("Do you really want to delete %1 entries for good?")
.arg(selected.size()),
QMessageBox::Yes | QMessageBox::No);
} }
QMessageBox::StandardButton result = MessageBox::question(
this,
tr("Delete entry(s)?", "", selected.size()),
prompt,
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) { if (result == QMessageBox::Yes) {
for (Entry* entry : asConst(selectedEntries)) { for (Entry* entry : asConst(selectedEntries)) {
delete entry; delete entry;
@ -504,21 +502,19 @@ void DatabaseWidget::deleteEntries()
} }
} }
else { else {
QMessageBox::StandardButton result; QString prompt;
if (selected.size() == 1) { if (selected.size() == 1) {
result = MessageBox::question( prompt = tr("Do you really want to move entry \"%1\" to the recycle bin?")
this, tr("Move entry to recycle bin?"), .arg(selectedEntries.first()->title().toHtmlEscaped());
tr("Do you really want to move entry \"%1\" to the recycle bin?") } else {
.arg(selectedEntries.first()->title().toHtmlEscaped()), prompt = tr("Do you really want to move %n entry(s) to the recycle bin?", "", selected.size());
QMessageBox::Yes | QMessageBox::No);
} }
else {
result = MessageBox::question( QMessageBox::StandardButton result = MessageBox::question(
this, tr("Move entries to recycle bin?"), this,
tr("Do you really want to move %n entry(s) to the recycle bin?", 0, selected.size()), tr("Move entry(s) to recycle bin?", "", selected.size()),
prompt,
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
}
if (result == QMessageBox::No) { if (result == QMessageBox::No) {
return; return;

View File

@ -305,9 +305,10 @@ void EditWidgetIcons::removeCustomIcon()
int iconUseCount = entriesWithSameIcon.size() + groupsWithSameIcon.size(); int iconUseCount = entriesWithSameIcon.size() + groupsWithSameIcon.size();
if (iconUseCount > 0) { if (iconUseCount > 0) {
QMessageBox::StandardButton ans = MessageBox::question(this, tr("Confirm Delete"), QMessageBox::StandardButton ans = MessageBox::question(this, tr("Confirm Delete"),
tr("This icon is used by %1 entries, and will be replaced " tr("This icon is used by %n entry(s), and will be replaced "
"by the default icon. Are you sure you want to delete it?") "by the default icon. Are you sure you want to delete it?",
.arg(iconUseCount), QMessageBox::Yes | QMessageBox::No); "", iconUseCount),
QMessageBox::Yes | QMessageBox::No);
if (ans == QMessageBox::No) { if (ans == QMessageBox::No) {
// Early out, nothing is changed // Early out, nothing is changed