add search history setting
New setting "Record recent searches" (on by default). When disabled, searches are not recorded and the Recent section is hidden from the history dropdown. Saved searches are unaffected. behavior change: opt-in setting, on by default (preserves existing behavior)
This commit is contained in:
parent
94588e324c
commit
5261fa176d
@ -153,6 +153,7 @@ _DEFAULTS = {
|
|||||||
"infinite_scroll": "0",
|
"infinite_scroll": "0",
|
||||||
"library_filename_template": "",
|
"library_filename_template": "",
|
||||||
"unbookmark_on_save": "0",
|
"unbookmark_on_save": "0",
|
||||||
|
"search_history_enabled": "1",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class SearchBar(QWidget):
|
|||||||
|
|
||||||
def _do_search(self) -> None:
|
def _do_search(self) -> None:
|
||||||
query = self._input.text().strip()
|
query = self._input.text().strip()
|
||||||
if self._db and query:
|
if self._db and query and self._db.get_setting_bool("search_history_enabled"):
|
||||||
self._db.add_search_history(query)
|
self._db.add_search_history(query)
|
||||||
self.search_requested.emit(query)
|
self.search_requested.emit(query)
|
||||||
|
|
||||||
@ -116,8 +116,8 @@ class SearchBar(QWidget):
|
|||||||
saved_actions[id(a)] = (sid, query)
|
saved_actions[id(a)] = (sid, query)
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
|
|
||||||
# History
|
# History (only shown when the setting is on)
|
||||||
history = self._db.get_search_history()
|
history = self._db.get_search_history() if self._db.get_setting_bool("search_history_enabled") else []
|
||||||
if history:
|
if history:
|
||||||
hist_header = menu.addAction("-- Recent --")
|
hist_header = menu.addAction("-- Recent --")
|
||||||
hist_header.setEnabled(False)
|
hist_header.setEnabled(False)
|
||||||
|
|||||||
@ -192,6 +192,11 @@ class SettingsDialog(QDialog):
|
|||||||
self._unbookmark_on_save.setChecked(self._db.get_setting_bool("unbookmark_on_save"))
|
self._unbookmark_on_save.setChecked(self._db.get_setting_bool("unbookmark_on_save"))
|
||||||
form.addRow("", self._unbookmark_on_save)
|
form.addRow("", self._unbookmark_on_save)
|
||||||
|
|
||||||
|
# Search history
|
||||||
|
self._search_history = QCheckBox("Record recent searches")
|
||||||
|
self._search_history.setChecked(self._db.get_setting_bool("search_history_enabled"))
|
||||||
|
form.addRow("", self._search_history)
|
||||||
|
|
||||||
# Slideshow monitor
|
# Slideshow monitor
|
||||||
from PySide6.QtWidgets import QApplication
|
from PySide6.QtWidgets import QApplication
|
||||||
self._monitor_combo = QComboBox()
|
self._monitor_combo = QComboBox()
|
||||||
@ -785,6 +790,7 @@ class SettingsDialog(QDialog):
|
|||||||
self._db.set_setting("prefetch_mode", self._prefetch_combo.currentText())
|
self._db.set_setting("prefetch_mode", self._prefetch_combo.currentText())
|
||||||
self._db.set_setting("infinite_scroll", "1" if self._infinite_scroll.isChecked() else "0")
|
self._db.set_setting("infinite_scroll", "1" if self._infinite_scroll.isChecked() else "0")
|
||||||
self._db.set_setting("unbookmark_on_save", "1" if self._unbookmark_on_save.isChecked() else "0")
|
self._db.set_setting("unbookmark_on_save", "1" if self._unbookmark_on_save.isChecked() else "0")
|
||||||
|
self._db.set_setting("search_history_enabled", "1" if self._search_history.isChecked() else "0")
|
||||||
self._db.set_setting("slideshow_monitor", self._monitor_combo.currentText())
|
self._db.set_setting("slideshow_monitor", self._monitor_combo.currentText())
|
||||||
self._db.set_setting("library_dir", self._library_dir.text().strip())
|
self._db.set_setting("library_dir", self._library_dir.text().strip())
|
||||||
self._db.set_setting("library_filename_template", self._library_filename_template.text().strip())
|
self._db.set_setting("library_filename_template", self._library_filename_template.text().strip())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user