提交 c2babe97 编写于 作者: K Kentaro Wada

Keep previous label in QLineEdit for label

上级 3e753e20
......@@ -681,8 +681,8 @@ class MainWindow(QMainWindow, WindowMixin):
position MUST be in global coordinates.
"""
text = ''
items = self.uniqLabelList.selectedItems()
text = None
if items:
text = items[0].text()
text = self.labelDialog.popUp(text)
......
......@@ -109,14 +109,14 @@ class LabelDialog(QDialog):
self.edit.setText(self.edit.text().trimmed())
def popUp(self, text=None, move=True):
if text is None:
text = ''
self.edit.setText(text)
self.edit.setSelection(0, len(text))
items = self.labelList.findItems(text, Qt.MatchFixedString)
if items:
assert len(items) == 1
self.labelList.setCurrentItem(items[0])
# if text is None, the previous label in self.edit is kept
if text is not None:
self.edit.setText(text)
self.edit.setSelection(0, len(text))
items = self.labelList.findItems(text, Qt.MatchFixedString)
if items:
assert len(items) == 1
self.labelList.setCurrentItem(items[0])
self.edit.setFocus(Qt.PopupFocusReason)
if move:
self.move(QCursor.pos())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册