From 726dbc004d9e7e0af47eea077bf5ed19d24a8adb Mon Sep 17 00:00:00 2001 From: Ziah Jyothi <1549806+ziah@users.noreply.github.com> Date: Tue, 30 Jul 2019 23:44:34 -0400 Subject: [PATCH] Add setting for search results timeout (#3411) * Fix #3400 * Allow enabling/disabling search timeout * Allow setting search timeout in minutes --- src/core/Config.cpp | 2 + src/gui/ApplicationSettingsWidget.cpp | 8 +++ src/gui/ApplicationSettingsWidgetSecurity.ui | 51 +++++++++++++++++--- src/gui/SearchWidget.cpp | 9 +++- 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/core/Config.cpp b/src/core/Config.cpp index 741a10d75..681f87be4 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -197,6 +197,8 @@ void Config::init(const QString& fileName) m_defaults.insert("FaviconDownloadTimeout", 10); m_defaults.insert("security/clearclipboard", true); m_defaults.insert("security/clearclipboardtimeout", 10); + m_defaults.insert("security/clearsearch", true); + m_defaults.insert("security/clearsearchtimeout", 5); m_defaults.insert("security/lockdatabaseidle", false); m_defaults.insert("security/lockdatabaseidlesec", 240); m_defaults.insert("security/lockdatabaseminimize", false); diff --git a/src/gui/ApplicationSettingsWidget.cpp b/src/gui/ApplicationSettingsWidget.cpp index 89c585fcb..22dea6a19 100644 --- a/src/gui/ApplicationSettingsWidget.cpp +++ b/src/gui/ApplicationSettingsWidget.cpp @@ -87,6 +87,8 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent) connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)), m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool))); + connect(m_secUi->clearSearchCheckBox, SIGNAL(toggled(bool)), + m_secUi->clearSearchSpinBox, SLOT(setEnabled(bool))); connect(m_secUi->lockDatabaseIdleCheckBox, SIGNAL(toggled(bool)), m_secUi->lockDatabaseIdleSpinBox, SLOT(setEnabled(bool))); connect(m_secUi->touchIDResetCheckBox, SIGNAL(toggled(bool)), @@ -215,6 +217,9 @@ void ApplicationSettingsWidget::loadSettings() m_secUi->clearClipboardCheckBox->setChecked(config()->get("security/clearclipboard").toBool()); m_secUi->clearClipboardSpinBox->setValue(config()->get("security/clearclipboardtimeout").toInt()); + m_secUi->clearSearchCheckBox->setChecked(config()->get("security/clearsearch").toBool()); + m_secUi->clearSearchSpinBox->setValue(config()->get("security/clearsearchtimeout").toInt()); + m_secUi->lockDatabaseIdleCheckBox->setChecked(config()->get("security/lockdatabaseidle").toBool()); m_secUi->lockDatabaseIdleSpinBox->setValue(config()->get("security/lockdatabaseidlesec").toInt()); m_secUi->lockDatabaseMinimizeCheckBox->setChecked(config()->get("security/lockdatabaseminimize").toBool()); @@ -299,6 +304,9 @@ void ApplicationSettingsWidget::saveSettings() config()->set("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked()); config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value()); + config()->set("security/clearsearch", m_secUi->clearSearchCheckBox->isChecked()); + config()->set("security/clearsearchtimeout", m_secUi->clearSearchSpinBox->value()); + config()->set("security/lockdatabaseidle", m_secUi->lockDatabaseIdleCheckBox->isChecked()); config()->set("security/lockdatabaseidlesec", m_secUi->lockDatabaseIdleSpinBox->value()); config()->set("security/lockdatabaseminimize", m_secUi->lockDatabaseMinimizeCheckBox->isChecked()); diff --git a/src/gui/ApplicationSettingsWidgetSecurity.ui b/src/gui/ApplicationSettingsWidgetSecurity.ui index bf5cce2d3..209c156b3 100644 --- a/src/gui/ApplicationSettingsWidgetSecurity.ui +++ b/src/gui/ApplicationSettingsWidgetSecurity.ui @@ -7,7 +7,7 @@ 0 0 595 - 478 + 541 @@ -61,6 +61,41 @@ + + + + Clear search query after + + + + + + + false + + + + 0 + 0 + + + + min + + + 1 + + + 1440 + + + 5 + + + 10 + + + @@ -99,6 +134,13 @@ + + + + Forget TouchID after inactivity of + + + @@ -121,13 +163,6 @@ - - - - Forget TouchID after inactivity of - - - diff --git a/src/gui/SearchWidget.cpp b/src/gui/SearchWidget.cpp index 4b910f4c7..8d33998cc 100644 --- a/src/gui/SearchWidget.cpp +++ b/src/gui/SearchWidget.cpp @@ -116,8 +116,13 @@ bool SearchWidget::eventFilter(QObject* obj, QEvent* event) } } } else if (event->type() == QEvent::FocusOut) { - // Auto-clear search after 5 minutes - m_clearSearchTimer->start(300000); + if (config()->get("security/clearsearch").toBool()) { + int timeout = config()->get("security/clearsearchtimeout").toInt(); + if (timeout > 0) { + // Auto-clear search after set timeout (5 minutes by default) + m_clearSearchTimer->start(timeout * 60000); // 60 sec * 1000 ms + } + } } else if (event->type() == QEvent::FocusIn) { m_clearSearchTimer->stop(); }