diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 39f3595e5b..712cab6a03 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -1128,13 +1128,13 @@ void DatabaseWidget::loadDatabase(bool accepted) // 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(); + if (expirationOffset <= 0) { + m_nextSearchLabelText = tr("Expired entries"); + } else { + m_nextSearchLabelText = + tr("Entries expiring within %1 day(s)", "", expirationOffset).arg(expirationOffset); + } requestSearch(QString("is:expired-%1").arg(expirationOffset)); - QTimer::singleShot(150, this, [=] { - m_searchingLabel->setText( - expirationOffset == 0 - ? tr("Expired entries") - : tr("Entries expiring within %1 day(s)", "", expirationOffset).arg(expirationOffset)); - }); } m_groupBeforeLock = QUuid(); @@ -1426,7 +1426,10 @@ void DatabaseWidget::search(const QString& searchtext) m_lastSearchText = searchtext; // Display a label detailing our search results - if (!searchResult.isEmpty()) { + if (!m_nextSearchLabelText.isEmpty()) { + m_searchingLabel->setText(m_nextSearchLabelText); + m_nextSearchLabelText.clear(); + } else if (!searchResult.isEmpty()) { m_searchingLabel->setText(tr("Search Results (%1)").arg(searchResult.size())); } else { m_searchingLabel->setText(tr("No Results")); @@ -1545,6 +1548,7 @@ void DatabaseWidget::endSearch() m_searchingLabel->setText(tr("Searching…")); m_lastSearchText.clear(); + m_nextSearchLabelText.clear(); // Tell the search widget to clear emit clearSearch(); diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index ede5a5fbf4..57108dfbf6 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -302,6 +302,7 @@ private slots: // Search state QScopedPointer m_entrySearcher; QString m_lastSearchText; + QString m_nextSearchLabelText; bool m_searchLimitGroup; // Autoreload diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index c00e3a10b3..c1b339f33e 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -111,6 +111,8 @@ void TestGui::init() config()->set(Config::Security_QuickUnlock, false); // Disable atomic saves to prevent transient errors on some platforms config()->set(Config::UseAtomicSaves, false); + // Disable showing expired entries on unlock + config()->set(Config::GUI_ShowExpiredEntriesOnDatabaseUnlock, false); // Copy the test database file to the temporary file auto origFilePath = QDir(KEEPASSX_TEST_DATA_DIR).absoluteFilePath("NewDatabase.kdbx");