mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A spot of refactoring
This commit is contained in:
parent
f863d3b46a
commit
5404ba04d2
@ -109,7 +109,7 @@ class SearchBox2(QComboBox): # {{{
|
|||||||
self.line_edit = SearchLineEdit(self)
|
self.line_edit = SearchLineEdit(self)
|
||||||
self.setLineEdit(self.line_edit)
|
self.setLineEdit(self.line_edit)
|
||||||
if add_clear_action:
|
if add_clear_action:
|
||||||
self.clear_action = self.lineEdit().addAction(QIcon(I('clear_left.png')), self.lineEdit().TrailingPosition)
|
self.clear_action = self.add_action('clear_left.png')
|
||||||
self.clear_action.triggered.connect(self.clear_clicked)
|
self.clear_action.triggered.connect(self.clear_clicked)
|
||||||
|
|
||||||
c = self.line_edit.completer()
|
c = self.line_edit.completer()
|
||||||
@ -131,6 +131,11 @@ class SearchBox2(QComboBox): # {{{
|
|||||||
self._in_a_search = False
|
self._in_a_search = False
|
||||||
self.tool_tip_text = self.toolTip()
|
self.tool_tip_text = self.toolTip()
|
||||||
|
|
||||||
|
def add_action(self, icon, position=QLineEdit.TrailingPosition):
|
||||||
|
if not isinstance(icon, QIcon):
|
||||||
|
icon = QIcon(I(icon))
|
||||||
|
return self.lineEdit().addAction(icon, position)
|
||||||
|
|
||||||
def initialize(self, opt_name, colorize=False, help_text=_('Search')):
|
def initialize(self, opt_name, colorize=False, help_text=_('Search')):
|
||||||
self.as_you_type = config['search_as_you_type']
|
self.as_you_type = config['search_as_you_type']
|
||||||
self.opt_name = opt_name
|
self.opt_name = opt_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user