mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Add a button next to the search bar to toggle easily between highlight and restrict search modes
This commit is contained in:
commit
a3ea4a5f75
BIN
resources/images/highlight_only_off.png
Normal file
BIN
resources/images/highlight_only_off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 810 B |
BIN
resources/images/highlight_only_on.png
Normal file
BIN
resources/images/highlight_only_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 396 B |
@ -196,6 +196,10 @@ class SearchBar(QWidget): # {{{
|
|||||||
l.addWidget(x)
|
l.addWidget(x)
|
||||||
x.setToolTip(_("Reset Quick Search"))
|
x.setToolTip(_("Reset Quick Search"))
|
||||||
|
|
||||||
|
x = parent.highlight_only_button = QToolButton(self)
|
||||||
|
x.setIcon(QIcon(I('arrow-down.png')))
|
||||||
|
l.addWidget(x)
|
||||||
|
|
||||||
x = parent.search_options_button = QToolButton(self)
|
x = parent.search_options_button = QToolButton(self)
|
||||||
x.setIcon(QIcon(I('config.png')))
|
x.setIcon(QIcon(I('config.png')))
|
||||||
x.setObjectName("search_option_button")
|
x.setObjectName("search_option_button")
|
||||||
|
@ -171,10 +171,10 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
return ConfigWidgetBase.commit(self)
|
return ConfigWidgetBase.commit(self)
|
||||||
|
|
||||||
def refresh_gui(self, gui):
|
def refresh_gui(self, gui):
|
||||||
|
gui.set_highlight_only_button_icon()
|
||||||
if self.muc_changed:
|
if self.muc_changed:
|
||||||
gui.tags_view.set_new_model()
|
gui.tags_view.set_new_model()
|
||||||
gui.search.search_as_you_type(config['search_as_you_type'])
|
gui.search.search_as_you_type(config['search_as_you_type'])
|
||||||
gui.library_view.model().set_highlight_only(config['highlight_search_matches'])
|
|
||||||
gui.search.do_search()
|
gui.search.do_search()
|
||||||
|
|
||||||
def clear_histories(self, *args):
|
def clear_histories(self, *args):
|
||||||
|
@ -10,7 +10,7 @@ import re
|
|||||||
|
|
||||||
from PyQt4.Qt import QComboBox, Qt, QLineEdit, QStringList, pyqtSlot, QDialog, \
|
from PyQt4.Qt import QComboBox, Qt, QLineEdit, QStringList, pyqtSlot, QDialog, \
|
||||||
pyqtSignal, QCompleter, QAction, QKeySequence, QTimer, \
|
pyqtSignal, QCompleter, QAction, QKeySequence, QTimer, \
|
||||||
QString
|
QString, QIcon
|
||||||
|
|
||||||
from calibre.gui2 import config
|
from calibre.gui2 import config
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
@ -383,6 +383,22 @@ class SearchBoxMixin(object): # {{{
|
|||||||
self.advanced_search_button.setStatusTip(self.advanced_search_button.toolTip())
|
self.advanced_search_button.setStatusTip(self.advanced_search_button.toolTip())
|
||||||
self.clear_button.setStatusTip(self.clear_button.toolTip())
|
self.clear_button.setStatusTip(self.clear_button.toolTip())
|
||||||
self.search_options_button.clicked.connect(self.search_options_button_clicked)
|
self.search_options_button.clicked.connect(self.search_options_button_clicked)
|
||||||
|
self.set_highlight_only_button_icon()
|
||||||
|
self.highlight_only_button.clicked.connect(self.highlight_only_clicked)
|
||||||
|
tt = _('Enable or disable search highlighting.') + '<br><br>'
|
||||||
|
tt += config.help('highlight_search_matches')
|
||||||
|
self.highlight_only_button.setToolTip(tt)
|
||||||
|
|
||||||
|
def highlight_only_clicked(self, state):
|
||||||
|
config['highlight_search_matches'] = not config['highlight_search_matches']
|
||||||
|
self.set_highlight_only_button_icon()
|
||||||
|
|
||||||
|
def set_highlight_only_button_icon(self):
|
||||||
|
if config['highlight_search_matches']:
|
||||||
|
self.highlight_only_button.setIcon(QIcon(I('highlight_only_on.png')))
|
||||||
|
else:
|
||||||
|
self.highlight_only_button.setIcon(QIcon(I('highlight_only_off.png')))
|
||||||
|
self.library_view.model().set_highlight_only(config['highlight_search_matches'])
|
||||||
|
|
||||||
def focus_search_box(self, *args):
|
def focus_search_box(self, *args):
|
||||||
self.search.setFocus(Qt.OtherFocusReason)
|
self.search.setFocus(Qt.OtherFocusReason)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user