From 878995366aacf55bdff7e7fc9274073aca9d4c87 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 2 Sep 2016 12:00:12 +0200 Subject: [PATCH] Ask the user before moving an entry to the recycle bin. Closes #447 --- src/gui/DatabaseWidget.cpp | 20 +++++++++++++++----- tests/gui/TestGui.cpp | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 92720e660..257bcb65d 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -341,14 +341,24 @@ void DatabaseWidget::deleteEntries() } } else { - if (selected.size() > 1) { - QMessageBox::StandardButton result = MessageBox::question( + QMessageBox::StandardButton result; + + if (selected.size() == 1) { + result = MessageBox::question( + this, tr("Move entry to recycle bin?"), + tr("Do you really want to move entry \"%1\" to the recycle bin?") + .arg(selectedEntries.first()->title()), + QMessageBox::Yes | QMessageBox::No); + } + else { + result = MessageBox::question( this, tr("Move entries to recycle bin?"), tr("Do you really want to move %n entry(s) to the recycle bin?", 0, selected.size()), QMessageBox::Yes | QMessageBox::No); - if (result == QMessageBox::No) { - return; - } + } + + if (result == QMessageBox::No) { + return; } Q_FOREACH (Entry* entry, selectedEntries) { diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index 6aa49b836..8845c60e3 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -239,6 +239,7 @@ void TestGui::testSearch() QVERIFY(entryDeleteWidget->isEnabled()); QVERIFY(!m_db->metadata()->recycleBin()); + MessageBox::setNextAnswer(QMessageBox::Yes); QTest::mouseClick(entryDeleteWidget, Qt::LeftButton); QCOMPARE(entryView->model()->rowCount(), 3);