diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 0ed8c1d23..a405b1c2d 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -2543,6 +2543,22 @@ bool DatabaseWidget::isRecycleBinSelected() const return (group && group->isRecycled()) || (entry && entry->isRecycled()); } +bool DatabaseWidget::hasRecycledSelectedEntries() const +{ + if (!m_entryView) { + return false; + } + + // Check if any of the selected entries are actually recycled + for (auto* entry : m_entryView->selectedEntries()) { + if (entry && entry->isRecycled()) { + return true; + } + } + + return false; +} + void DatabaseWidget::emptyRecycleBin() { if (!isRecycleBinSelected()) { diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index d990419a2..e9a81f5ac 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -97,6 +97,7 @@ public: bool canDeleteCurrentGroup() const; bool isGroupSelected() const; bool isRecycleBinSelected() const; + bool hasRecycledSelectedEntries() const; int numberOfSelectedEntries() const; int currentEntryIndex() const; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index af3dddf58..145bb4b99 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -982,8 +982,9 @@ void MainWindow::updateMenuActionState() } else { m_ui->actionEntryDelete->setToolTip(tr("Delete Entry")); } - m_ui->actionEntryRestore->setVisible(multiEntrySelected && inRecycleBin); - m_ui->actionEntryRestore->setEnabled(multiEntrySelected && inRecycleBin); + bool hasRecycledEntries = (inDatabase && dbWidget && dbWidget->hasRecycledSelectedEntries()); + m_ui->actionEntryRestore->setVisible(multiEntrySelected && hasRecycledEntries); + m_ui->actionEntryRestore->setEnabled(multiEntrySelected && hasRecycledEntries); if (dbWidget) { m_ui->actionEntryRestore->setText(tr("Restore Entry(s)", "", dbWidget->numberOfSelectedEntries())); m_ui->actionEntryRestore->setToolTip(tr("Restore Entry(s)", "", dbWidget->numberOfSelectedEntries()));