Просмотр исходного кода

- in the new Tools DB added ability to double click on the ID in the tree widget to execute adding a tool from DB

Marius Stanciu 5 лет назад
Родитель
Сommit
a872a958ca
5 измененных файлов с 28 добавлено и 14 удалено
  1. 10 0
      FlatCAMCommon.py
  2. 1 0
      FlatCAMObj.py
  3. 1 0
      README.md
  4. 15 14
      flatcamTools/ToolNCC.py
  5. 1 0
      flatcamTools/ToolPaint.py

+ 10 - 0
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())

+ 1 - 0
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()

+ 1 - 0
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
 

+ 15 - 14
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 = []

+ 1 - 0
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()