mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-09-21 13:24:47 -04:00
Fix incorrect "Restore Entry" option shown for non-recycle bin items in search results (#12198)
--------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
parent
dd023ca157
commit
05150e2483
3 changed files with 20 additions and 2 deletions
|
@ -2700,6 +2700,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()) {
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
bool canDeleteCurrentGroup() const;
|
||||
bool isGroupSelected() const;
|
||||
bool isRecycleBinSelected() const;
|
||||
bool hasRecycledSelectedEntries() const;
|
||||
int numberOfSelectedEntries() const;
|
||||
int currentEntryIndex() const;
|
||||
|
||||
|
|
|
@ -955,8 +955,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()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue