diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 51865e326703875c09afb828414ffef6a3ff2970..6376173bad63bcd0656c07d37a86ec48a69f506d 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -80,6 +80,7 @@ class MainWindow(QMainWindow): settings = self.settings self.lang = lang self.kie_mode = kie_mode + self.key_previous_text = "" # Load string bundle for i18n if lang not in ['ch', 'en']: lang = 'en' @@ -428,6 +429,7 @@ class MainWindow(QMainWindow): # key list dialog if kie_mode: self.keyDialog = KeyDialog( + text=getStr('keyDialogTip'), parent=self, labels=None, sort_labels=True, @@ -1219,10 +1221,9 @@ class MainWindow(QMainWindow): self.canvas.resetAllLines() if self.kie_mode: - previous_text = self.keyDialog.edit.text() - text, flags, group_id = self.keyDialog.popUp(text) - if not text: - self.keyDialog.edit.setText(previous_text) + self.key_previous_text, flags = self.keyDialog.popUp(self.key_previous_text) + if not self.key_previous_text: + self.keyDialog.edit.setText(self.key_previous_text) def scrollRequest(self, delta, orientation): units = - delta / (8 * 15) diff --git a/PPOCRLabel/libs/keyDialog.py b/PPOCRLabel/libs/keyDialog.py index 2332354c43ac9e87da9cf88532e15d2ba739efde..028227aa98d5a5496ce529b843535ce4d8d81232 100644 --- a/PPOCRLabel/libs/keyDialog.py +++ b/PPOCRLabel/libs/keyDialog.py @@ -1,13 +1,10 @@ import re -import sys from PyQt5 import QtCore from PyQt5 import QtGui from PyQt5 import QtWidgets - from libs.utils import newIcon, labelValidator - QT5 = True @@ -49,16 +46,11 @@ class KeyDialog(QtWidgets.QDialog): self.edit.editingFinished.connect(self.postProcess) if flags: 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() if show_text_field: layout_edit = QtWidgets.QHBoxLayout() layout_edit.addWidget(self.edit, 6) - layout_edit.addWidget(self.edit_group_id, 2) layout.addLayout(layout_edit) # buttons self.buttonBox = bb = QtWidgets.QDialogButtonBox( @@ -189,13 +181,7 @@ class KeyDialog(QtWidgets.QDialog): flags[item.text()] = item.isChecked() return flags - def getGroupId(self): - 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): + def popUp(self, text=None, move=True, flags=None): if self._fit_to_content["row"]: self.labelList.setMinimumHeight( self.labelList.sizeHintForRow(0) * self.labelList.count() + 2 @@ -213,10 +199,7 @@ class KeyDialog(QtWidgets.QDialog): self.resetFlags(text) self.edit.setText(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) if items: if len(items) != 1: @@ -227,6 +210,6 @@ class KeyDialog(QtWidgets.QDialog): if move: self.move(QtGui.QCursor.pos()) if self.exec_(): - return self.edit.text(), self.getFlags(), self.getGroupId() + return self.edit.text(), self.getFlags() else: return None, None, None diff --git a/PPOCRLabel/resources/strings/strings-en.properties b/PPOCRLabel/resources/strings/strings-en.properties index eee25ec1af36c796e97af252b53e0e9948cc1444..a32979aaedce5c2f14d3b65d3dc637b7762a7c02 100644 --- a/PPOCRLabel/resources/strings/strings-en.properties +++ b/PPOCRLabel/resources/strings/strings-en.properties @@ -107,4 +107,5 @@ undoLastPoint=Undo Last Point autoSaveMode=Auto Export Label Mode lockBox=Lock selected box/Unlock all box lockBoxDetail=Lock selected box/Unlock all box -keyListTitle=Key List \ No newline at end of file +keyListTitle=Key List +keyDialogTip=Enter object label \ No newline at end of file diff --git a/PPOCRLabel/resources/strings/strings-zh-CN.properties b/PPOCRLabel/resources/strings/strings-zh-CN.properties index bb411bfdb37a1b8dd5b59cca4a556f67f3a95dfa..1694d568413eed26a682cc8c8d67c986599ae756 100644 --- a/PPOCRLabel/resources/strings/strings-zh-CN.properties +++ b/PPOCRLabel/resources/strings/strings-zh-CN.properties @@ -107,4 +107,5 @@ undoLastPoint=撤销上个点 autoSaveMode=自动导出标记结果 lockBox=锁定框/解除锁定框 lockBoxDetail=若当前没有框处于锁定状态则锁定选中的框,若存在锁定框则解除所有锁定框的锁定状态 -keyListTitle=关键词列表 \ No newline at end of file +keyListTitle=关键词列表 +keyDialogTip=请输入类型名称 \ No newline at end of file