diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e8b7108..df914a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ CHANGELOG for FlatCAM beta - in Geometry Editor - simplification method is now threaded and optimized - in Geometry Editor - fixed a crash on Geometry Editor exit - in Geometry Editor - added a new feature: ability to change the orientation (from CW to CCW and the revers) for Polygon and LinearRing geometry elements. +- in Geometry Editor - added a context menu in the Geometry Table 26.11.2020 diff --git a/appEditors/AppGeoEditor.py b/appEditors/AppGeoEditor.py index 32e5a846..06da9e0a 100644 --- a/appEditors/AppGeoEditor.py +++ b/appEditors/AppGeoEditor.py @@ -3385,6 +3385,7 @@ class AppGeoEditor(QtCore.QObject): self.tw = FCTree(columns=3, header_hidden=False, protected_column=[0, 1], extended_sel=True) self.tw.setHeaderLabels(["ID", _("Type"), _("Name")]) self.tw.setIndentation(0) + self.tw.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.tw.header().setStretchLastSection(True) self.tw.header().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) grid0.addWidget(self.tw, 2, 0, 1, 3) @@ -3430,6 +3431,7 @@ class AppGeoEditor(QtCore.QObject): is_ccw_lbl = FCLabel('%s:' % _("Is CCW")) self.is_ccw_entry = FCLabel('None') self.change_orientation_btn = FCButton(_("Change")) + self.change_orientation_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/orientation32.png')) self.change_orientation_btn.setToolTip( _("Change the orientation of the geometric element.\n" "Works for LinearRing and Polygons.") @@ -3673,6 +3675,8 @@ class AppGeoEditor(QtCore.QObject): self.simplification_btn.clicked.connect(self.on_simplification_click) self.change_orientation_btn.clicked.connect(self.on_change_orientation) + self.tw.customContextMenuRequested.connect(self.on_menu_request) + self.clear_tree_sig.connect(self.on_clear_tree) # Event signals disconnect id holders @@ -3947,6 +3951,24 @@ class AppGeoEditor(QtCore.QObject): self.app.worker_task.emit({'fcn': task_job, 'params': []}) + def on_menu_request(self, pos): + menu = QtWidgets.QMenu() + + delete_action = menu.addAction(QtGui.QIcon(self.app.resource_location + '/delete32.png'), _("Delete")) + delete_action.triggered.connect(self.delete_selected) + + menu.addSeparator() + + orientation_change = menu.addAction(QtGui.QIcon(self.app.resource_location + '/orientation32.png'), + _("Change")) + orientation_change.triggered.connect(self.on_change_orientation) + + if not self.tw.selectedItems(): + delete_action.setDisabled(True) + orientation_change.setDisabled(True) + + menu.exec(self.tw.viewport().mapToGlobal(pos)) + def activate(self): # adjust the status of the menu entries related to the editor self.app.ui.menueditedit.setDisabled(True) diff --git a/assets/resources/dark_resources/orientation32.png b/assets/resources/dark_resources/orientation32.png new file mode 100644 index 00000000..fe2a5451 Binary files /dev/null and b/assets/resources/dark_resources/orientation32.png differ diff --git a/assets/resources/orientation32.png b/assets/resources/orientation32.png new file mode 100644 index 00000000..ce2be280 Binary files /dev/null and b/assets/resources/orientation32.png differ