Show expired entries on DB unlock

* Show banner message about expired entries
* Add config option and expiration offset
* Only show expiry warning on first DB unlock
* Default to on with 3-day offset from expiration
This commit is contained in:
Balazs Gyurak 2022-01-22 18:20:41 +00:00 committed by Jonathan White
parent 3c824cb500
commit 6897787d8f
9 changed files with 145 additions and 1 deletions

View file

@ -1119,7 +1119,29 @@ void DatabaseWidget::loadDatabase(bool accepted)
replaceDatabase(openWidget->database());
switchToMainView();
processAutoOpen();
restoreGroupEntryFocus(m_groupBeforeLock, m_entryBeforeLock);
// Only show expired entries if first unlock and option is enabled
if (m_groupBeforeLock.isNull() && config()->get(Config::GUI_ShowExpiredEntriesOnDatabaseUnlock).toBool()) {
int expirationOffset = config()->get(Config::GUI_ShowExpiredEntriesOnDatabaseUnlockOffsetDays).toInt();
QList<Entry*> expiredEntries;
for (auto entry : m_db->rootGroup()->entriesRecursive()) {
if (entry->willExpireInDays(expirationOffset) && !entry->excludeFromReports() && !entry->isRecycled()) {
expiredEntries << entry;
}
}
if (!expiredEntries.isEmpty()) {
m_entryView->displaySearch(expiredEntries);
m_entryView->setFirstEntryActive();
m_searchingLabel->setText(expirationOffset == 0
? tr("Expired entries")
: tr("Entries expiring within %1 days").arg(expirationOffset));
m_searchingLabel->setVisible(true);
}
}
m_groupBeforeLock = QUuid();
m_entryBeforeLock = QUuid();
m_saveAttempts = 0;