mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When clicking in the search box, select all existing text, for easy replacement. Fixes #1338862 [[Enhancement] Search enhancements](https://bugs.launchpad.net/calibre/+bug/1338862)
This commit is contained in:
parent
f8127127d1
commit
8e74361336
@ -21,6 +21,7 @@ from calibre.gui2.dialogs.search import SearchDialog
|
|||||||
|
|
||||||
class SearchLineEdit(QLineEdit): # {{{
|
class SearchLineEdit(QLineEdit): # {{{
|
||||||
key_pressed = pyqtSignal(object)
|
key_pressed = pyqtSignal(object)
|
||||||
|
select_on_mouse_press = False
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
self.key_pressed.emit(event)
|
self.key_pressed.emit(event)
|
||||||
@ -38,6 +39,16 @@ class SearchLineEdit(QLineEdit): # {{{
|
|||||||
def paste(self, *args):
|
def paste(self, *args):
|
||||||
self.parent().normalize_state()
|
self.parent().normalize_state()
|
||||||
return QLineEdit.paste(self)
|
return QLineEdit.paste(self)
|
||||||
|
|
||||||
|
def focusInEvent(self, ev):
|
||||||
|
self.select_on_mouse_press = True
|
||||||
|
return QLineEdit.focusInEvent(self, ev)
|
||||||
|
|
||||||
|
def mousePressEvent(self, ev):
|
||||||
|
QLineEdit.mousePressEvent(self, ev)
|
||||||
|
if self.select_on_mouse_press:
|
||||||
|
self.select_on_mouse_press = False
|
||||||
|
self.selectAll()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class SearchBox2(QComboBox): # {{{
|
class SearchBox2(QComboBox): # {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user