mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
...
This commit is contained in:
parent
8e74361336
commit
4b88420482
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import re
|
import re, time
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
|
||||||
@ -21,7 +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
|
select_on_mouse_press = None
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
self.key_pressed.emit(event)
|
self.key_pressed.emit(event)
|
||||||
@ -41,14 +41,14 @@ class SearchLineEdit(QLineEdit): # {{{
|
|||||||
return QLineEdit.paste(self)
|
return QLineEdit.paste(self)
|
||||||
|
|
||||||
def focusInEvent(self, ev):
|
def focusInEvent(self, ev):
|
||||||
self.select_on_mouse_press = True
|
self.select_on_mouse_press = time.time()
|
||||||
return QLineEdit.focusInEvent(self, ev)
|
return QLineEdit.focusInEvent(self, ev)
|
||||||
|
|
||||||
def mousePressEvent(self, ev):
|
def mousePressEvent(self, ev):
|
||||||
QLineEdit.mousePressEvent(self, ev)
|
QLineEdit.mousePressEvent(self, ev)
|
||||||
if self.select_on_mouse_press:
|
if self.select_on_mouse_press is not None and abs(time.time() - self.select_on_mouse_press) < 0.2:
|
||||||
self.select_on_mouse_press = False
|
|
||||||
self.selectAll()
|
self.selectAll()
|
||||||
|
self.select_on_mouse_press = None
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class SearchBox2(QComboBox): # {{{
|
class SearchBox2(QComboBox): # {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user