-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Allow holding shift to delete polys without confirmation #1481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ | |
| from labelme._label_file import ShapeDict | ||
| from labelme.config import get_config | ||
| from labelme.shape import Shape | ||
| from labelme.utils.qt import shift_and_ctrl_pressed | ||
| from labelme.utils.qt import shift_pressed | ||
| from labelme.widgets import AiPromptWidget | ||
| from labelme.widgets import BrightnessContrastDialog | ||
| from labelme.widgets import Canvas | ||
|
|
@@ -398,7 +400,10 @@ def __init__( | |
| self.deleteSelectedShape, | ||
| shortcuts["delete_polygon"], | ||
| "cancel", | ||
| self.tr("Delete the selected polygons"), | ||
| "{} {}".format( | ||
| self.tr("Delete the selected polygons"), | ||
| self.tr("(Hold Shift to skip confirmation)"), | ||
| ), | ||
| enabled=False, | ||
| ) | ||
| duplicate = action( | ||
|
|
@@ -1836,9 +1841,7 @@ def loadRecent(self, filename): | |
|
|
||
| def openPrevImg(self, _value=False): | ||
| keep_prev = self._config["keep_prev"] | ||
| if QtWidgets.QApplication.keyboardModifiers() == ( | ||
| Qt.ControlModifier | Qt.ShiftModifier | ||
| ): | ||
| if shift_and_ctrl_pressed(): | ||
| self._config["keep_prev"] = True | ||
|
|
||
| if not self.mayContinue(): | ||
|
|
@@ -1860,9 +1863,7 @@ def openPrevImg(self, _value=False): | |
|
|
||
| def openNextImg(self, _value=False, load=True): | ||
| keep_prev = self._config["keep_prev"] | ||
| if QtWidgets.QApplication.keyboardModifiers() == ( | ||
| Qt.ControlModifier | Qt.ShiftModifier | ||
| ): | ||
| if shift_and_ctrl_pressed(): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - just using the same new function for the same functionality.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i mean, this pr is for deleting poly right? why you change keep_prev?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a bit of a side effect – I think, back last year when I originally made this PR, I figured it'd be worth it to unify the modifier key functionality used both for "hold shift to delete polys" and "hold shift+ctrl" as used here, into canonical helper functions. |
||
| self._config["keep_prev"] = True | ||
|
|
||
| if not self.mayContinue(): | ||
|
|
@@ -2097,8 +2098,12 @@ def deleteSelectedShape(self): | |
| msg = self.tr( | ||
| "You are about to permanently delete {} polygons, proceed anyway?" | ||
| ).format(len(self.canvas.selectedShapes)) | ||
| if yes == QtWidgets.QMessageBox.warning( | ||
| self, self.tr("Attention"), msg, yes | no, yes | ||
|
|
||
| if shift_pressed() or ( | ||
| yes | ||
| == QtWidgets.QMessageBox.warning( | ||
| self, self.tr("Attention"), msg, yes | no, yes | ||
| ) | ||
| ): | ||
| self.remLabels(self.canvas.deleteSelected()) | ||
| self.setDirty() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why separate translation texts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I didn't want to invalidate existing translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know, but is that the right thing to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you. I'm fine doing it either this way or by changing the entire translation.