diff --git a/booru_viewer/core/db.py b/booru_viewer/core/db.py index 8be4bbc..39963b9 100644 --- a/booru_viewer/core/db.py +++ b/booru_viewer/core/db.py @@ -153,6 +153,7 @@ _DEFAULTS = { "infinite_scroll": "0", "library_filename_template": "", "unbookmark_on_save": "0", + "search_history_enabled": "1", } diff --git a/booru_viewer/gui/search.py b/booru_viewer/gui/search.py index f24209e..5c491e9 100644 --- a/booru_viewer/gui/search.py +++ b/booru_viewer/gui/search.py @@ -94,7 +94,7 @@ class SearchBar(QWidget): def _do_search(self) -> None: 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.search_requested.emit(query) @@ -116,8 +116,8 @@ class SearchBar(QWidget): saved_actions[id(a)] = (sid, query) menu.addSeparator() - # History - history = self._db.get_search_history() + # History (only shown when the setting is on) + history = self._db.get_search_history() if self._db.get_setting_bool("search_history_enabled") else [] if history: hist_header = menu.addAction("-- Recent --") hist_header.setEnabled(False) diff --git a/booru_viewer/gui/settings.py b/booru_viewer/gui/settings.py index 74e9eee..f19fb34 100644 --- a/booru_viewer/gui/settings.py +++ b/booru_viewer/gui/settings.py @@ -192,6 +192,11 @@ class SettingsDialog(QDialog): self._unbookmark_on_save.setChecked(self._db.get_setting_bool("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 from PySide6.QtWidgets import QApplication 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("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("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("library_dir", self._library_dir.text().strip()) self._db.set_setting("library_filename_template", self._library_filename_template.text().strip())