diff --git a/FlatCAMCommon.py b/FlatCAMCommon.py index 9d02b94e..08142a9e 100644 --- a/FlatCAMCommon.py +++ b/FlatCAMCommon.py @@ -2229,6 +2229,9 @@ class ToolsDB2(QtWidgets.QWidget): self.current_toolid = None + # variable to show if double clicking and item will trigger adding a tool from DB + self.ok_to_add = False + # ############################################################################## # ######################## SIGNALS ############################################# # ############################################################################## @@ -2247,6 +2250,8 @@ class ToolsDB2(QtWidgets.QWidget): self.tree_widget.itemChanged.connect(self.on_list_item_edited) self.tree_widget.customContextMenuRequested.connect(self.on_menu_request) + self.tree_widget.itemDoubleClicked.connect(self.on_item_double_clicked) + self.setup_db_ui() def on_menu_request(self, pos): @@ -2264,6 +2269,11 @@ class ToolsDB2(QtWidgets.QWidget): # tree_item = self.tree_widget.itemAt(pos) menu.exec(self.tree_widget.viewport().mapToGlobal(pos)) + def on_item_double_clicked(self, item, column): + if column == 0 and self.ok_to_add is True: + self.ok_to_add = False + self.on_tool_requested_from_app() + def on_list_selection_change(self, current, previous): # for idx in current.indexes(): # print(idx.data()) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index a28e2c73..a267856f 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -4774,6 +4774,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.app.ui.plot_tab_area.setCurrentWidget(self.app.tools_db_tab) break self.app.on_tools_database() + self.app.tools_db_tab.ok_to_add = True self.app.tools_db_tab.buttons_frame.hide() self.app.tools_db_tab.add_tool_from_db.show() self.app.tools_db_tab.cancel_tool_from_db.show() diff --git a/README.md b/README.md index 88c30ba0..ec435ee2 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing. - fixed issues in the new database when adding the tool in a Geometry object - fixed a bug in Geometry object that generated a change of dictionary while iterating over it - started to add the new database links in the NCC and Paint Tools +- in the new Tools DB added ability to double click on the ID in the tree widget to execute adding a tool from DB 28.03.2020 diff --git a/flatcamTools/ToolNCC.py b/flatcamTools/ToolNCC.py index af81fb95..11be5cbe 100644 --- a/flatcamTools/ToolNCC.py +++ b/flatcamTools/ToolNCC.py @@ -3911,20 +3911,6 @@ class NonCopperClear(FlatCAMTool, Gerber): return ret_val - def reset_fields(self): - self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) - - def reset_usage(self): - self.obj_name = "" - self.ncc_obj = None - self.bound_obj = None - - self.first_click = False - self.cursor_pos = None - self.mouse_is_dragging = False - - self.sel_rect = [] - @staticmethod def poly2rings(poly): return [poly.exterior] + [interior for interior in poly.interiors] @@ -4057,6 +4043,21 @@ class NonCopperClear(FlatCAMTool, Gerber): self.app.ui.plot_tab_area.setCurrentWidget(self.app.tools_db_tab) break self.app.on_tools_database(source='ncc') + self.app.tools_db_tab.ok_to_add = True self.app.tools_db_tab.buttons_frame.hide() self.app.tools_db_tab.add_tool_from_db.show() self.app.tools_db_tab.cancel_tool_from_db.show() + + def reset_fields(self): + self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) + + def reset_usage(self): + self.obj_name = "" + self.ncc_obj = None + self.bound_obj = None + + self.first_click = False + self.cursor_pos = None + self.mouse_is_dragging = False + + self.sel_rect = [] diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py index 0b930c4c..3f7c1e48 100644 --- a/flatcamTools/ToolPaint.py +++ b/flatcamTools/ToolPaint.py @@ -4423,6 +4423,7 @@ class ToolPaint(FlatCAMTool, Gerber): self.app.ui.plot_tab_area.setCurrentWidget(self.app.tools_db_tab) break self.app.on_tools_database(source='paint') + self.app.tools_db_tab.ok_to_add = True self.app.tools_db_tab.buttons_frame.hide() self.app.tools_db_tab.add_tool_from_db.show() self.app.tools_db_tab.cancel_tool_from_db.show()