diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc index 71d2d0cfa3c9..ecca417fd280 100644 --- a/src/Mod/Path/Gui/Resources/Path.qrc +++ b/src/Mod/Path/Gui/Resources/Path.qrc @@ -50,6 +50,7 @@ icons/Path-Stop.svg icons/Path-ToolChange.svg icons/Path-ToolController.svg + icons/Path-ToolDuplicate.svg icons/Path-Toolpath.svg icons/Path-ToolTable.svg icons/Path-Area.svg diff --git a/src/Mod/Path/Gui/Resources/icons/Path-ToolDuplicate.svg b/src/Mod/Path/Gui/Resources/icons/Path-ToolDuplicate.svg new file mode 100644 index 000000000000..8880eed31b3b --- /dev/null +++ b/src/Mod/Path/Gui/Resources/icons/Path-ToolDuplicate.svg @@ -0,0 +1,856 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + Path-ToolChange + 2016-01-20 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Path/Gui/Resources/icons/Path-ToolChange.svg + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Path/Gui/Resources/panels/ToolLibraryEditor.ui b/src/Mod/Path/Gui/Resources/panels/ToolLibraryEditor.ui index ed3cdf6bd539..7f9d7bc2a617 100644 --- a/src/Mod/Path/Gui/Resources/panels/ToolLibraryEditor.ui +++ b/src/Mod/Path/Gui/Resources/panels/ToolLibraryEditor.ui @@ -39,258 +39,333 @@ - + - - - - 225 - 16777215 - - - - - 0 - - - 0 - - - 6 - - - 0 - - - - - - - Tool Tables - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - + + + + + + 225 + 16777215 + + + + + 0 + + + 0 + + + 6 + + + 0 + - + - - - - 32 - 32 - - + - - - - - :/icons/FreeCAD-default/scalable/edit-edit.svg:/icons/FreeCAD-default/scalable/edit-edit.svg + Tool Tables - - + + + Qt::Horizontal + + - 32 - 32 + 20 + 20 - - - - - - :/icons/FreeCAD-default/scalable/list-remove.svg - - - + - - - - 32 - 32 - - - - - - - - :/icons/FreeCAD-default/scalable/list-add.svg - - - + + + + + + 32 + 32 + + + + + + + + :/icons/FreeCAD-default/scalable/edit-edit.svg:/icons/FreeCAD-default/scalable/edit-edit.svg + + + + + + + + 32 + 32 + + + + + + + + :/icons/FreeCAD-default/scalable/list-remove.svg + + + + + + + + + 32 + 32 + + + + + + + + :/icons/FreeCAD-default/scalable/list-add.svg + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 0 + 0 + + + + true + + + + 20 + 20 + + + + - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 0 - 0 - - - - true - - - - 20 - 20 - - - - - - + + + + + + false + + + false + + + QAbstractItemView::NoDragDrop + + + Qt::IgnoreAction + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + false + + + false + + + false + + + + - - - false - - - false - - - QAbstractItemView::NoDragDrop - - - Qt::IgnoreAction - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - true - - - false - - - false - - + + + + + New Tool + + + + :/icons/Path-ToolController.svg:/icons/Path-ToolController.svg + + + + + + + false + + + + 0 + 0 + + + + + + + Delete + + + + :/icons/delete.svg:/icons/delete.svg + + + + + + + false + + + false + + + Edit + + + + :/icons/edit-edit.svg:/icons/edit-edit.svg + + + + + + + false + + + false + + + Duplicate + + + + :/icons/Path-ToolDuplicate.svg:/icons/Path-ToolDuplicate.svg + + + + + + + false + + + Move up + + + + :/icons/button_up.svg:/icons/button_up.svg + + + false + + + false + + + false + + + + + + + false + + + false + + + Move down + + + + :/icons/button_down.svg:/icons/button_down.svg + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - - - - 0 - 0 - - - - Create Tool Controllers for the selected tools - - - Create Tool Controller(s) - - - - :/icons/Path-LengthOffset.svg:/icons/Path-LengthOffset.svg - - - - - - - New Tool - - - - :/icons/Path-ToolController.svg:/icons/Path-ToolController.svg - - - - - - - Delete - - - - :/icons/delete.svg:/icons/delete.svg - - - - - - - Move up - - - - :/icons/button_up.svg:/icons/button_up.svg - - - false - - - false - - - false - - - - - - - Move down - - - - :/icons/button_down.svg:/icons/button_down.svg - - - - + + + false + + + + 0 + 0 + + + + Create Tool Controllers for the selected tools + + + Create Tool Controller(s) + + + + :/icons/Path-LengthOffset.svg:/icons/Path-LengthOffset.svg + + diff --git a/src/Mod/Path/PathScripts/PathToolLibraryManager.py b/src/Mod/Path/PathScripts/PathToolLibraryManager.py index a3148a454a43..1d61f03ecd8d 100644 --- a/src/Mod/Path/PathScripts/PathToolLibraryManager.py +++ b/src/Mod/Path/PathScripts/PathToolLibraryManager.py @@ -499,6 +499,19 @@ def movedown(self, number, listname): self.saveMainLibrary() return True, target + def duplicate(self, number, listname): + ''' duplicates the selected tool in the selected tool table ''' + tt = self.getTableFromName(listname) + tool = tt.getTool(number).copy() + tt.addTools(tool) + + newID = list(tt.Tools)[-1] + + if listname == self.getCurrentTableName(): + self.saveMainLibrary() + return True, newID + + def delete(self, number, listname): '''deletes a tool from the current list''' tt = self.getTableFromName(listname) @@ -591,6 +604,9 @@ def delete(self): def editTool(self, currItem): '''load the tool edit dialog''' + if not currItem: + currItem = self.form.ToolsList.selectedIndexes()[1] + row = currItem.row() value = currItem.sibling(row, 1).data() listname = self.TLM.getCurrentTableName() @@ -626,6 +642,17 @@ def moveDown(self): self.loadTable(listname) self.updateSelection(newNum) + def duplicate(self): + '''duplicated the selected tool in the current tool table''' + item = self.form.ToolsList.selectedIndexes()[1].data() + if item: + number = int(item) + listname = self.TLM.getCurrentTableName() + success, newNum = self.TLM.duplicate(number, listname) + if success: + self.loadTable(listname) + self.updateSelection(newNum) + def updateSelection(self, number): '''update the tool list selection to track moves''' model = self.form.ToolsList.model() @@ -661,6 +688,8 @@ def toolSelected(self, index): self.form.ButtonDelete.setEnabled(False) self.form.ButtonUp.setEnabled(False) self.form.ButtonDown.setEnabled(False) + self.form.ButtonEdit.setEnabled(False) + self.form.ButtonDuplicate.setEnabled(False) model = self.form.ToolsList.model() checkCount = 0 @@ -679,6 +708,8 @@ def toolSelected(self, index): self.form.ButtonDelete.setEnabled(True) self.form.ButtonUp.setEnabled(True) self.form.ButtonDown.setEnabled(True) + self.form.ButtonEdit.setEnabled(True) + self.form.ButtonDuplicate.setEnabled(True) if len(PathUtils.GetJobs()) == 0: self.form.btnCopyTools.setEnabled(False) @@ -744,8 +775,9 @@ def loadTable(self, name): if tooldata: self.form.ToolsList.setModel(tooldata) self.form.ToolsList.resizeColumnsToContents() + self.form.ToolsList.horizontalHeader().setResizeMode(self.form.ToolsList.model().columnCount() - 1, QtGui.QHeaderView.Stretch) self.setCurrentToolTableByName(name) - + def addNewToolTable(self): ''' adds new tool to selected tool table ''' @@ -819,6 +851,8 @@ def setupUi(self): self.form.ButtonDown.clicked.connect(self.moveDown) self.form.ButtonUp.clicked.connect(self.moveUp) self.form.ButtonDelete.clicked.connect(self.delete) + self.form.ButtonEdit.clicked.connect(self.editTool) + self.form.ButtonDuplicate.clicked.connect(self.duplicate) self.form.ToolsList.doubleClicked.connect(self.editTool) self.form.ToolsList.clicked.connect(self.toolSelected) @@ -837,12 +871,6 @@ def setupUi(self): self.form.ButtonRenameToolTable.clicked.connect(self.initTableRename) self.form.ButtonRenameToolTable.setToolTip(translate("TooltableEditor","Rename Selected Tool Table")) - - self.form.btnCopyTools.setEnabled(False) - self.form.ButtonDelete.setEnabled(False) - self.form.ButtonUp.setEnabled(False) - self.form.ButtonDown.setEnabled(False) - self.setFields() class CommandToolLibraryEdit():