From ae5d9af9ae66f2334897c6c9fdf57969079cc932 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 27 Nov 2020 03:39:13 +0200 Subject: [PATCH] - in Geometry Editor - added a context menu in the Geometry Table --- CHANGELOG.md | 1 + appEditors/AppGeoEditor.py | 22 ++++++++++++++++++ .../dark_resources/orientation32.png | Bin 0 -> 840 bytes assets/resources/orientation32.png | Bin 0 -> 734 bytes 4 files changed, 23 insertions(+) create mode 100644 assets/resources/dark_resources/orientation32.png create mode 100644 assets/resources/orientation32.png 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 0000000000000000000000000000000000000000..fe2a5451b51669b766ad7de4df4d382f7f7fa959 GIT binary patch literal 840 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f+@+{-GzZ+Rj;xUkjGiz z5n0T@z;^_M8K-LVNdpDhOFVsD*`IJrGs-L9H)98yz$E7B;uzv_{OuI`jNm|#WA*Q! zYC5TI%@Uf-7s=(i(kknvd^ewxhElBTANQjdj~-q7;E7fq*F~ijuGUBDMV4?ZwVD;B z?&#Y4(pKMBR`sMcU**Eelhs1v;x`&^fDr7KLD}I)f!MR%VH|uZ44-uQhG!}h% zZJ~UFLBwL3#;NME;PSF>Yqwv&n>)V{Y ztCP>act2^PhG;-M(yR-{zl%-l@{{ z%5^!{&(3{!FL%o^`T3`+7d?3Ax$=~`C%exSljWUT*PN=FJdtVLg9#h?SUBdCdB(qS zf0!Y8C2>JmY|c3g+3Zi9!WX|rU%$fi?6Oe619#bm$M2SE?C^Q1(qOyS@VZyR48{x6 zMV2CUjk6i5(vQF17NV-HrFFC@=AP;L&5|6~-ktjup1bpkum)Gc-t}5XB0PCK+bX4W zL&VmG*Bn(l+#>g7>%Omj%fg(W%ryQ~QOdGFX8Oz(>SyGyIi)`OJ0S{;59}@7ocVoxXlQFa*K+}ihTQy=%(P0}8YVV;lmTjx1lbUrpH@mmtT}V`<;yxP!WTttDnm{r-UW|lL=2{ literal 0 HcmV?d00001 diff --git a/assets/resources/orientation32.png b/assets/resources/orientation32.png new file mode 100644 index 0000000000000000000000000000000000000000..ce2be2804dded03107bf16eb31de28331fbd02d2 GIT binary patch literal 734 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f+@+{-GzZ+Rj;xUkjGiz z5n0T@z;^_M8K-LVNdpDhOFVsD*`IJrGs^SLdKoRsz`(f1)5S5wuiswtZ-9*0L2-}?U+CM`-;)2kvEib38 ze0Sil+_D94trjz=o!LDv-sz(BbBEJis-*`PcqUglo=q*CKj%`(q3=0g>{ffONnfRT ze!|Wp!No4I0wGqH=L@n}=RFfEcMle@=@gvfpLD0=+w-zdN$T?-Y*nb(mEZmRcGN6I zi3}f)d77! zpEZ~&pSq`}%rkB8_J!d$r(8^VX}{x1c3jo