Эх сурвалжийг харах

Add more actions to menus, copy shape properties

Add edit/copy/delete actions to menu, so that their shortcuts are
available as well.

Copy line/fill color when duplicating shapes.
Michael Pitidis 13 жил өмнө
parent
commit
e44df990b1
2 өөрчлөгдсөн 10 нэмэгдсэн , 5 устгасан
  1. 6 5
      labelme.py
  2. 4 0
      shape.py

+ 6 - 5
labelme.py

@@ -32,7 +32,6 @@ __appname__ = 'labelme'
 #   alternate files. Either keep enabled, or add "Save As" button.
 
 # TODO:
-# - [high] Add Return as a double-click shortcut in create.
 # - [high] Switch to simpler label dialog.
 # - [high] Deselect shape when clicking and already selected(?)
 # - [high] Sanitize shortcuts between beginner/advanced mode.
@@ -223,8 +222,6 @@ class MainWindow(QMainWindow, WindowMixin):
         addActions(labelMenu, (edit, delete))
         self.labelList.setContextMenuPolicy(Qt.CustomContextMenu)
         self.labelList.customContextMenuRequested.connect(self.popLabelListMenu)
-        # Add the action to the main window, so that its shortcut is global.
-        self.addAction(edit)
 
         # Store actions for further handling.
         self.actions = struct(save=save, open=open, close=close,
@@ -245,15 +242,19 @@ class MainWindow(QMainWindow, WindowMixin):
 
         self.menus = struct(
                 file=self.menu('&File'),
-                edit=self.menu('&Polygons'),
+                edit=self.menu('&Edit'),
                 view=self.menu('&View'),
                 labelList=labelMenu)
-        addActions(self.menus.edit, (color1, color2))
+
+        addActions(self.menus.edit, (
+            edit, copy, delete, None, color1, color2))
+
         addActions(self.menus.view, (
             labels, advancedMode, None,
             hideAll, showAll, None,
             zoomIn, zoomOut, zoomOrg, None,
             fitWindow, fitWidth))
+
         self.menus.file.aboutToShow.connect(self.updateFileMenu)
 
         # Custom context menu for the canvas widget:

+ 4 - 0
shape.py

@@ -160,6 +160,10 @@ class Shape(object):
         shape.fill = self.fill
         shape.selected = self.selected
         shape._closed = self._closed
+        if self.line_color != Shape.line_color:
+            shape.line_color = self.line_color
+        if self.fill_color != Shape.fill_color:
+            shape.fill_color = self.fill_color
         return shape
 
     def __len__(self):