mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-02-27 16:43:40 +01:00
...
This commit is contained in:
parent
34f6626c2a
commit
ad00a746a9
1 changed files with 10 additions and 6 deletions
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
import weakref
|
||||
|
||||
import sip
|
||||
from PyQt4.Qt import (QLineEdit, QAbstractListModel, Qt, pyqtSignal, QObject,
|
||||
QApplication, QListView, QPoint, QModelIndex)
|
||||
|
||||
|
|
@ -82,7 +83,6 @@ def __init__(self, completer_widget, max_visible_items=7):
|
|||
self.entered.connect(self.item_entered)
|
||||
self.activated.connect(self.item_chosen)
|
||||
self.pressed.connect(self.item_chosen)
|
||||
self.eat_focus_out = True
|
||||
self.installEventFilter(self)
|
||||
|
||||
def hide(self):
|
||||
|
|
@ -167,7 +167,7 @@ def popup(self, select_first=True):
|
|||
def eventFilter(self, obj, e):
|
||||
'Redirect key presses from the popup to the widget'
|
||||
widget = self.completer_widget()
|
||||
if widget is None:
|
||||
if widget is None or sip.isdeleted(widget):
|
||||
return False
|
||||
etype = e.type()
|
||||
if obj is not self:
|
||||
|
|
@ -198,9 +198,9 @@ def eventFilter(self, obj, e):
|
|||
e.accept()
|
||||
return True
|
||||
# Send to widget
|
||||
self.eat_focus_out = False
|
||||
widget.eat_focus_out = False
|
||||
widget.keyPressEvent(e)
|
||||
self.eat_focus_out = True
|
||||
widget.eat_focus_out = True
|
||||
if not widget.hasFocus():
|
||||
# Widget lost focus hide the popup
|
||||
self.hide()
|
||||
|
|
@ -335,6 +335,7 @@ def __init__(self, *args):
|
|||
EnComboBox.__init__(self, *args)
|
||||
self.setLineEdit(LineEdit(self, completer_widget=self))
|
||||
self.setCompleter(None)
|
||||
self.eat_focus_out = True
|
||||
self.installEventFilter(self)
|
||||
|
||||
# Interface {{{
|
||||
|
|
@ -389,9 +390,12 @@ def clear(self):
|
|||
EnComboBox.clear(self)
|
||||
|
||||
def eventFilter(self, obj, e):
|
||||
c = self.lineEdit().mcompleter
|
||||
try:
|
||||
c = self.lineEdit().mcompleter
|
||||
except AttributeError:
|
||||
return False
|
||||
etype = e.type()
|
||||
if c.eat_focus_out and self is obj and etype == e.FocusOut:
|
||||
if self.eat_focus_out and self is obj and etype == e.FocusOut:
|
||||
if c.isVisible():
|
||||
return True
|
||||
return EnComboBox.eventFilter(self, obj, e)
|
||||
|
|
|
|||
Loading…
Reference in a new issue