提交 814e8a87 编写于 作者: HinGwenWoong's avatar HinGwenWoong

Delete useless part in key dialog, translate tip

上级 77d83a60
...@@ -80,6 +80,7 @@ class MainWindow(QMainWindow): ...@@ -80,6 +80,7 @@ class MainWindow(QMainWindow):
settings = self.settings settings = self.settings
self.lang = lang self.lang = lang
self.kie_mode = kie_mode self.kie_mode = kie_mode
self.key_previous_text = ""
# Load string bundle for i18n # Load string bundle for i18n
if lang not in ['ch', 'en']: if lang not in ['ch', 'en']:
lang = 'en' lang = 'en'
...@@ -428,6 +429,7 @@ class MainWindow(QMainWindow): ...@@ -428,6 +429,7 @@ class MainWindow(QMainWindow):
# key list dialog # key list dialog
if kie_mode: if kie_mode:
self.keyDialog = KeyDialog( self.keyDialog = KeyDialog(
text=getStr('keyDialogTip'),
parent=self, parent=self,
labels=None, labels=None,
sort_labels=True, sort_labels=True,
...@@ -1219,10 +1221,9 @@ class MainWindow(QMainWindow): ...@@ -1219,10 +1221,9 @@ class MainWindow(QMainWindow):
self.canvas.resetAllLines() self.canvas.resetAllLines()
if self.kie_mode: if self.kie_mode:
previous_text = self.keyDialog.edit.text() self.key_previous_text, flags = self.keyDialog.popUp(self.key_previous_text)
text, flags, group_id = self.keyDialog.popUp(text) if not self.key_previous_text:
if not text: self.keyDialog.edit.setText(self.key_previous_text)
self.keyDialog.edit.setText(previous_text)
def scrollRequest(self, delta, orientation): def scrollRequest(self, delta, orientation):
units = - delta / (8 * 15) units = - delta / (8 * 15)
......
import re import re
import sys
from PyQt5 import QtCore from PyQt5 import QtCore
from PyQt5 import QtGui from PyQt5 import QtGui
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
from libs.utils import newIcon, labelValidator from libs.utils import newIcon, labelValidator
QT5 = True QT5 = True
...@@ -49,16 +46,11 @@ class KeyDialog(QtWidgets.QDialog): ...@@ -49,16 +46,11 @@ class KeyDialog(QtWidgets.QDialog):
self.edit.editingFinished.connect(self.postProcess) self.edit.editingFinished.connect(self.postProcess)
if flags: if flags:
self.edit.textChanged.connect(self.updateFlags) self.edit.textChanged.connect(self.updateFlags)
self.edit_group_id = QtWidgets.QLineEdit()
self.edit_group_id.setPlaceholderText("Group ID")
self.edit_group_id.setValidator(
QtGui.QRegExpValidator(QtCore.QRegExp(r"\d*"), None)
)
layout = QtWidgets.QVBoxLayout() layout = QtWidgets.QVBoxLayout()
if show_text_field: if show_text_field:
layout_edit = QtWidgets.QHBoxLayout() layout_edit = QtWidgets.QHBoxLayout()
layout_edit.addWidget(self.edit, 6) layout_edit.addWidget(self.edit, 6)
layout_edit.addWidget(self.edit_group_id, 2)
layout.addLayout(layout_edit) layout.addLayout(layout_edit)
# buttons # buttons
self.buttonBox = bb = QtWidgets.QDialogButtonBox( self.buttonBox = bb = QtWidgets.QDialogButtonBox(
...@@ -189,13 +181,7 @@ class KeyDialog(QtWidgets.QDialog): ...@@ -189,13 +181,7 @@ class KeyDialog(QtWidgets.QDialog):
flags[item.text()] = item.isChecked() flags[item.text()] = item.isChecked()
return flags return flags
def getGroupId(self): def popUp(self, text=None, move=True, flags=None):
group_id = self.edit_group_id.text()
if group_id:
return int(group_id)
return None
def popUp(self, text=None, move=True, flags=None, group_id=None):
if self._fit_to_content["row"]: if self._fit_to_content["row"]:
self.labelList.setMinimumHeight( self.labelList.setMinimumHeight(
self.labelList.sizeHintForRow(0) * self.labelList.count() + 2 self.labelList.sizeHintForRow(0) * self.labelList.count() + 2
...@@ -213,10 +199,7 @@ class KeyDialog(QtWidgets.QDialog): ...@@ -213,10 +199,7 @@ class KeyDialog(QtWidgets.QDialog):
self.resetFlags(text) self.resetFlags(text)
self.edit.setText(text) self.edit.setText(text)
self.edit.setSelection(0, len(text)) self.edit.setSelection(0, len(text))
if group_id is None:
self.edit_group_id.clear()
else:
self.edit_group_id.setText(str(group_id))
items = self.labelList.findItems(text, QtCore.Qt.MatchFixedString) items = self.labelList.findItems(text, QtCore.Qt.MatchFixedString)
if items: if items:
if len(items) != 1: if len(items) != 1:
...@@ -227,6 +210,6 @@ class KeyDialog(QtWidgets.QDialog): ...@@ -227,6 +210,6 @@ class KeyDialog(QtWidgets.QDialog):
if move: if move:
self.move(QtGui.QCursor.pos()) self.move(QtGui.QCursor.pos())
if self.exec_(): if self.exec_():
return self.edit.text(), self.getFlags(), self.getGroupId() return self.edit.text(), self.getFlags()
else: else:
return None, None, None return None, None, None
...@@ -107,4 +107,5 @@ undoLastPoint=Undo Last Point ...@@ -107,4 +107,5 @@ undoLastPoint=Undo Last Point
autoSaveMode=Auto Export Label Mode autoSaveMode=Auto Export Label Mode
lockBox=Lock selected box/Unlock all box lockBox=Lock selected box/Unlock all box
lockBoxDetail=Lock selected box/Unlock all box lockBoxDetail=Lock selected box/Unlock all box
keyListTitle=Key List keyListTitle=Key List
\ No newline at end of file keyDialogTip=Enter object label
\ No newline at end of file
...@@ -107,4 +107,5 @@ undoLastPoint=撤销上个点 ...@@ -107,4 +107,5 @@ undoLastPoint=撤销上个点
autoSaveMode=自动导出标记结果 autoSaveMode=自动导出标记结果
lockBox=锁定框/解除锁定框 lockBox=锁定框/解除锁定框
lockBoxDetail=若当前没有框处于锁定状态则锁定选中的框,若存在锁定框则解除所有锁定框的锁定状态 lockBoxDetail=若当前没有框处于锁定状态则锁定选中的框,若存在锁定框则解除所有锁定框的锁定状态
keyListTitle=关键词列表 keyListTitle=关键词列表
\ No newline at end of file keyDialogTip=请输入类型名称
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册