2424from labelme ._label_file import ShapeDict
2525from labelme .config import get_config
2626from labelme .shape import Shape
27+ from labelme .utils .qt import shift_and_ctrl_pressed
28+ from labelme .utils .qt import shift_pressed
2729from labelme .widgets import AiPromptWidget
2830from labelme .widgets import BrightnessContrastDialog
2931from labelme .widgets import Canvas
@@ -396,7 +398,10 @@ def __init__(
396398 self .deleteSelectedShape ,
397399 shortcuts ["delete_polygon" ],
398400 "cancel" ,
399- self .tr ("Delete the selected polygons" ),
401+ "{} {}" .format (
402+ self .tr ("Delete the selected polygons" ),
403+ self .tr ("(Hold Shift to skip confirmation)" ),
404+ ),
400405 enabled = False ,
401406 )
402407 duplicate = action (
@@ -1828,9 +1833,7 @@ def loadRecent(self, filename):
18281833
18291834 def openPrevImg (self , _value = False ):
18301835 keep_prev = self ._config ["keep_prev" ]
1831- if QtWidgets .QApplication .keyboardModifiers () == (
1832- Qt .ControlModifier | Qt .ShiftModifier
1833- ):
1836+ if shift_and_ctrl_pressed ():
18341837 self ._config ["keep_prev" ] = True
18351838
18361839 if not self .mayContinue ():
@@ -1852,9 +1855,7 @@ def openPrevImg(self, _value=False):
18521855
18531856 def openNextImg (self , _value = False , load = True ):
18541857 keep_prev = self ._config ["keep_prev" ]
1855- if QtWidgets .QApplication .keyboardModifiers () == (
1856- Qt .ControlModifier | Qt .ShiftModifier
1857- ):
1858+ if shift_and_ctrl_pressed ():
18581859 self ._config ["keep_prev" ] = True
18591860
18601861 if not self .mayContinue ():
@@ -2089,8 +2090,12 @@ def deleteSelectedShape(self):
20892090 msg = self .tr (
20902091 "You are about to permanently delete {} polygons, proceed anyway?"
20912092 ).format (len (self .canvas .selectedShapes ))
2092- if yes == QtWidgets .QMessageBox .warning (
2093- self , self .tr ("Attention" ), msg , yes | no , yes
2093+
2094+ if shift_pressed () or (
2095+ yes
2096+ == QtWidgets .QMessageBox .warning (
2097+ self , self .tr ("Attention" ), msg , yes | no , yes
2098+ )
20942099 ):
20952100 self .remLabels (self .canvas .deleteSelected ())
20962101 self .setDirty ()
0 commit comments