This commit is contained in:
Kovid Goyal 2014-07-08 13:26:21 +05:30
parent 8e74361336
commit 4b88420482

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re
import re, time
from functools import partial
@ -21,7 +21,7 @@ from calibre.gui2.dialogs.search import SearchDialog
class SearchLineEdit(QLineEdit): # {{{
key_pressed = pyqtSignal(object)
select_on_mouse_press = False
select_on_mouse_press = None
def keyPressEvent(self, event):
self.key_pressed.emit(event)
@ -41,14 +41,14 @@ class SearchLineEdit(QLineEdit): # {{{
return QLineEdit.paste(self)
def focusInEvent(self, ev):
self.select_on_mouse_press = True
self.select_on_mouse_press = time.time()
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
if self.select_on_mouse_press is not None and abs(time.time() - self.select_on_mouse_press) < 0.2:
self.selectAll()
self.select_on_mouse_press = None
# }}}
class SearchBox2(QComboBox): # {{{