Skip to content
Snippets Groups Projects
Commit 2e7f1101 authored by Martijn Buijs's avatar Martijn Buijs Committed by Kentaro Wada
Browse files

Enable selecting a label from the list using up/down keys

parent 0a69964a
Branches
No related tags found
No related merge requests found
......@@ -94,11 +94,20 @@ class LabelDialog(QDialog):
else:
self.edit.setText(self.edit.text().trimmed())
def popUp(self, text='', move=True):
def popUp(self, text=None, move=True):
if isinstance(text, str):
self.edit.setText(text)
self.edit.setSelection(0, len(text))
i = self.labelList.findItems(text, Qt.MatchFixedString)
if len(i) == 1:
self.labelList.setCurrentItem(i[0])
self.edit.setFocus(Qt.PopupFocusReason)
if move:
self.move(QCursor.pos())
return self.edit.text() if self.exec_() else None
def keyPressEvent(self, e):
if e.key() in [Qt.Key_Up, Qt.Key_Down]:
self.labelList.keyPressEvent(e)
else:
super().keyPressEvent(e)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment