mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
Apply first tag autosuggestion with Enter/Return
This commit is contained in:
parent
0c85aed04a
commit
153849c01b
1 changed files with 7 additions and 1 deletions
|
@ -37,9 +37,9 @@ class TagEdit(QLineEdit):
|
||||||
|
|
||||||
def keyPressEvent(self, evt):
|
def keyPressEvent(self, evt):
|
||||||
if (evt.key() == Qt.Key_Tab and evt.modifiers() & Qt.ControlModifier):
|
if (evt.key() == Qt.Key_Tab and evt.modifiers() & Qt.ControlModifier):
|
||||||
|
# select next completion
|
||||||
if not self.completer.popup().isVisible():
|
if not self.completer.popup().isVisible():
|
||||||
self.showCompleter()
|
self.showCompleter()
|
||||||
# select next completion
|
|
||||||
index = self.completer.currentIndex()
|
index = self.completer.currentIndex()
|
||||||
self.completer.popup().setCurrentIndex(index)
|
self.completer.popup().setCurrentIndex(index)
|
||||||
cur_row = index.row()
|
cur_row = index.row()
|
||||||
|
@ -47,6 +47,12 @@ class TagEdit(QLineEdit):
|
||||||
self.completer.setCurrentRow(0)
|
self.completer.setCurrentRow(0)
|
||||||
return
|
return
|
||||||
if evt.key() in (Qt.Key_Enter, Qt.Key_Return):
|
if evt.key() in (Qt.Key_Enter, Qt.Key_Return):
|
||||||
|
# apply first completion if no suggestion selected
|
||||||
|
selected_row = self.completer.popup().currentIndex().row()
|
||||||
|
if selected_row == -1:
|
||||||
|
self.completer.setCurrentRow(0)
|
||||||
|
index = self.completer.currentIndex()
|
||||||
|
self.completer.popup().setCurrentIndex(index)
|
||||||
self.hideCompleter()
|
self.hideCompleter()
|
||||||
QWidget.keyPressEvent(self, evt)
|
QWidget.keyPressEvent(self, evt)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue