Add setting for search results timeout (#3411)

* Fix #3400
* Allow enabling/disabling search timeout
* Allow setting search timeout in minutes
This commit is contained in:
Ziah Jyothi 2019-07-30 23:44:34 -04:00 committed by Jonathan White
parent 6ae27fa47b
commit 726dbc004d
4 changed files with 60 additions and 10 deletions

View File

@ -197,6 +197,8 @@ void Config::init(const QString& fileName)
m_defaults.insert("FaviconDownloadTimeout", 10); m_defaults.insert("FaviconDownloadTimeout", 10);
m_defaults.insert("security/clearclipboard", true); m_defaults.insert("security/clearclipboard", true);
m_defaults.insert("security/clearclipboardtimeout", 10); 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/lockdatabaseidle", false);
m_defaults.insert("security/lockdatabaseidlesec", 240); m_defaults.insert("security/lockdatabaseidlesec", 240);
m_defaults.insert("security/lockdatabaseminimize", false); m_defaults.insert("security/lockdatabaseminimize", false);

View File

@ -87,6 +87,8 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)), connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)),
m_secUi->clearClipboardSpinBox, SLOT(setEnabled(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)), connect(m_secUi->lockDatabaseIdleCheckBox, SIGNAL(toggled(bool)),
m_secUi->lockDatabaseIdleSpinBox, SLOT(setEnabled(bool))); m_secUi->lockDatabaseIdleSpinBox, SLOT(setEnabled(bool)));
connect(m_secUi->touchIDResetCheckBox, SIGNAL(toggled(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->clearClipboardCheckBox->setChecked(config()->get("security/clearclipboard").toBool());
m_secUi->clearClipboardSpinBox->setValue(config()->get("security/clearclipboardtimeout").toInt()); 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->lockDatabaseIdleCheckBox->setChecked(config()->get("security/lockdatabaseidle").toBool());
m_secUi->lockDatabaseIdleSpinBox->setValue(config()->get("security/lockdatabaseidlesec").toInt()); m_secUi->lockDatabaseIdleSpinBox->setValue(config()->get("security/lockdatabaseidlesec").toInt());
m_secUi->lockDatabaseMinimizeCheckBox->setChecked(config()->get("security/lockdatabaseminimize").toBool()); 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/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked());
config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value()); 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/lockdatabaseidle", m_secUi->lockDatabaseIdleCheckBox->isChecked());
config()->set("security/lockdatabaseidlesec", m_secUi->lockDatabaseIdleSpinBox->value()); config()->set("security/lockdatabaseidlesec", m_secUi->lockDatabaseIdleSpinBox->value());
config()->set("security/lockdatabaseminimize", m_secUi->lockDatabaseMinimizeCheckBox->isChecked()); config()->set("security/lockdatabaseminimize", m_secUi->lockDatabaseMinimizeCheckBox->isChecked());

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>595</width> <width>595</width>
<height>478</height> <height>541</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -61,6 +61,41 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QCheckBox" name="clearSearchCheckBox">
<property name="text">
<string>Clear search query after</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="clearSearchSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string comment="Minutes"> min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1440</number>
</property>
<property name="value">
<number>5</number>
</property>
<property name="displayIntegerBase">
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QCheckBox" name="lockDatabaseIdleCheckBox"> <widget class="QCheckBox" name="lockDatabaseIdleCheckBox">
<property name="sizePolicy"> <property name="sizePolicy">
@ -99,6 +134,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QCheckBox" name="touchIDResetCheckBox">
<property name="text">
<string>Forget TouchID after inactivity of</string>
</property>
</widget>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QSpinBox" name="touchIDResetSpinBox"> <widget class="QSpinBox" name="touchIDResetSpinBox">
<property name="enabled"> <property name="enabled">
@ -121,13 +163,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QCheckBox" name="touchIDResetCheckBox">
<property name="text">
<string>Forget TouchID after inactivity of</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -116,8 +116,13 @@ bool SearchWidget::eventFilter(QObject* obj, QEvent* event)
} }
} }
} else if (event->type() == QEvent::FocusOut) { } else if (event->type() == QEvent::FocusOut) {
// Auto-clear search after 5 minutes if (config()->get("security/clearsearch").toBool()) {
m_clearSearchTimer->start(300000); 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) { } else if (event->type() == QEvent::FocusIn) {
m_clearSearchTimer->stop(); m_clearSearchTimer->stop();
} }