Move the advanced search button into the line edit

This commit is contained in:
Kovid Goyal 2017-06-10 12:00:48 +05:30
parent 5404ba04d2
commit d7886a0001
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 16 deletions

View File

@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
from functools import partial
from PyQt5.Qt import (QIcon, Qt, QWidget, QSize, QFrame,
pyqtSignal, QToolButton, QMenu, QAction, QCoreApplication,
pyqtSignal, QToolButton, QMenu, QLineEdit, QCoreApplication,
QObject, QVBoxLayout, QSizePolicy, QLabel, QHBoxLayout, QActionGroup)
@ -205,18 +205,6 @@ class SearchBar(QWidget): # {{{
parent.search_count = x
x.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
parent.advanced_search_button = x = QToolButton(self)
x.setCursor(Qt.PointingHandCursor)
parent.advanced_search_toggle_action = ac = QAction(parent)
parent.addAction(ac)
parent.keyboard.register_shortcut('advanced search toggle',
_('Advanced search'), default_keys=("Shift+Ctrl+F",),
action=ac)
ac.triggered.connect(x.click)
x.setIcon(QIcon(I('search.png')))
l.addWidget(x)
x.setToolTip(_("Advanced search"))
x = parent.search = SearchBox2(self)
x.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
x.setObjectName("search")
@ -225,6 +213,12 @@ class SearchBar(QWidget): # {{{
x.setMinimumContentsLength(10)
l.addWidget(x)
parent.advanced_search_toggle_action = ac = parent.search.add_action('search.png', QLineEdit.LeadingPosition)
parent.addAction(ac)
parent.keyboard.register_shortcut('advanced search toggle',
_('Advanced search'), default_keys=("Shift+Ctrl+F",),
action=ac)
self.search_button = QToolButton()
self.search_button.setToolButtonStyle(Qt.ToolButtonTextOnly)
self.search_button.setText(_('Search'))

View File

@ -447,13 +447,13 @@ class SearchBoxMixin(object): # {{{
def init_search_box_mixin(self):
self.search.initialize('main_search_history', colorize=True,
help_text=_('Search (For advanced search click the button to the left)'))
help_text=_('Search (For advanced search click the icon to the left)'))
self.search.cleared.connect(self.search_box_cleared)
# Queued so that search.current_text will be correct
self.search.changed.connect(self.search_box_changed,
type=Qt.QueuedConnection)
self.search.focus_to_library.connect(self.focus_to_library)
self.advanced_search_button.clicked[bool].connect(self.do_advanced_search)
self.advanced_search_toggle_action.triggered.connect(self.do_advanced_search)
self.search.clear()
self.search.setMaximumWidth(self.width()-150)
@ -468,7 +468,6 @@ class SearchBoxMixin(object): # {{{
self.addAction(self.action_focus_search)
self.search.setStatusTip(re.sub(r'<\w+>', ' ',
unicode(self.search.toolTip())))
self.advanced_search_button.setStatusTip(self.advanced_search_button.toolTip())
self.set_highlight_only_button_icon()
self.highlight_only_button.clicked.connect(self.highlight_only_clicked)
tt = _('Enable or disable search highlighting.') + '<br><br>'