From 04aa6d23fb7d21645532e63486b440239b0de01e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 19 Aug 2013 11:27:47 +0530 Subject: [PATCH] Ask for confirmation when toggle search highlight is clicked --- src/calibre/gui2/search_box.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index edd05168f4..a50b3dfe9c 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -14,7 +14,7 @@ from PyQt4.Qt import QComboBox, Qt, QLineEdit, QStringList, pyqtSlot, QDialog, \ pyqtSignal, QCompleter, QAction, QKeySequence, QTimer, \ QString, QIcon, QMenu -from calibre.gui2 import config, error_dialog +from calibre.gui2 import config, error_dialog, question_dialog from calibre.gui2.dialogs.confirm_delete import confirm from calibre.gui2.dialogs.saved_search_editor import SavedSearchEditor from calibre.gui2.dialogs.search import SearchDialog @@ -420,6 +420,11 @@ class SearchBoxMixin(object): # {{{ self.highlight_only_button.setToolTip(tt) def highlight_only_clicked(self, state): + if not config['highlight_search_matches'] and not question_dialog(self, _('Are you sure?'), + _('This will change how searching works. When you search, instead of showing only the ' + 'matching books, all books will be shown with the matching books highlighted. ' + 'Are you sure this is what you want?'), skip_dialog_name='confirm_search_highlight_toggle'): + return config['highlight_search_matches'] = not config['highlight_search_matches'] self.set_highlight_only_button_icon() self.search.do_search()