From e8edb437184320399068c4336d51b4364a6b50c5 Mon Sep 17 00:00:00 2001 From: HinGwenWoong Date: Sun, 20 Feb 2022 17:20:29 +0800 Subject: [PATCH] Add Right click change key class --- PPOCRLabel/PPOCRLabel.py | 18 ++++++++++++++++-- .../resources/strings/strings-en.properties | 3 ++- .../resources/strings/strings-zh-CN.properties | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 15f62c56..105989c7 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -464,6 +464,9 @@ class MainWindow(QMainWindow): undo = action(getStr("undo"), self.undoShapeEdit, 'Ctrl+Z', "undo", getStr("undo"), enabled=False) + change_cls = action(getStr("keyChange"), self.change_box_key, + 'Ctrl+B', "undo", getStr("keyChange"), enabled=False) + lock = action(getStr("lockBox"), self.lockSelectedShape, None, "lock", getStr("lockBoxDetail"), enabled=False) @@ -525,14 +528,15 @@ class MainWindow(QMainWindow): shapeLineColor=shapeLineColor, shapeFillColor=shapeFillColor, zoom=zoom, zoomIn=zoomIn, zoomOut=zoomOut, zoomOrg=zoomOrg, fitWindow=fitWindow, fitWidth=fitWidth, - zoomActions=zoomActions, saveLabel=saveLabel, + zoomActions=zoomActions, saveLabel=saveLabel, change_cls=change_cls, undo=undo, undoLastPoint=undoLastPoint, open_dataset_dir=open_dataset_dir, rotateLeft=rotateLeft, rotateRight=rotateRight, lock=lock, fileMenuActions=(opendir, open_dataset_dir, saveLabel, resetAll, quit), beginner=(), advanced=(), editMenu=(createpoly, edit, copy, delete, singleRere, None, undo, undoLastPoint, None, rotateLeft, rotateRight, None, color1, self.drawSquaresOption, lock), - beginnerContext=(create, edit, copy, delete, singleRere, rotateLeft, rotateRight, lock), + beginnerContext=( + create, edit, copy, delete, singleRere, rotateLeft, rotateRight, lock, change_cls), advancedContext=(createMode, editMode, edit, copy, delete, shapeLineColor, shapeFillColor), onLoadActive=(create, createMode, editMode), @@ -984,6 +988,7 @@ class MainWindow(QMainWindow): self.actions.copy.setEnabled(n_selected) self.actions.edit.setEnabled(n_selected == 1) self.actions.lock.setEnabled(n_selected) + self.actions.change_cls.setEnabled(n_selected) def addLabel(self, shape): shape.paintLabel = self.displayLabelOption.isChecked() @@ -2178,6 +2183,15 @@ class MainWindow(QMainWindow): self.autoSaveNum = 5 # Used for backup print('The program will automatically save once after confirming 5 images (default)') + def change_box_key(self): + key_text, _ = self.keyDialog.popUp(self.key_previous_text) + if key_text is None: + return + self.key_previous_text = key_text + for shape in self.canvas.selectedShapes: + shape.key_cls = key_text + self._update_shape_color(shape) + def undoShapeEdit(self): self.canvas.restoreShape() self.labelList.clear() diff --git a/PPOCRLabel/resources/strings/strings-en.properties b/PPOCRLabel/resources/strings/strings-en.properties index a32979aa..3c4eda65 100644 --- a/PPOCRLabel/resources/strings/strings-en.properties +++ b/PPOCRLabel/resources/strings/strings-en.properties @@ -108,4 +108,5 @@ autoSaveMode=Auto Export Label Mode lockBox=Lock selected box/Unlock all box lockBoxDetail=Lock selected box/Unlock all box keyListTitle=Key List -keyDialogTip=Enter object label \ No newline at end of file +keyDialogTip=Enter object label +keyChange=Change Box Key diff --git a/PPOCRLabel/resources/strings/strings-zh-CN.properties b/PPOCRLabel/resources/strings/strings-zh-CN.properties index 1694d568..a7c30368 100644 --- a/PPOCRLabel/resources/strings/strings-zh-CN.properties +++ b/PPOCRLabel/resources/strings/strings-zh-CN.properties @@ -108,4 +108,5 @@ autoSaveMode=自动导出标记结果 lockBox=锁定框/解除锁定框 lockBoxDetail=若当前没有框处于锁定状态则锁定选中的框,若存在锁定框则解除所有锁定框的锁定状态 keyListTitle=关键词列表 -keyDialogTip=请输入类型名称 \ No newline at end of file +keyDialogTip=请输入类型名称 +keyChange=更改Box关键字类别 \ No newline at end of file -- GitLab