diff --git a/src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui b/src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui
index 77d528cbd5..80bb90c3ca 100644
--- a/src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui
+++ b/src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui
@@ -63,7 +63,7 @@
-
- Tool Table
+ Tool Tables
@@ -130,100 +130,145 @@
-
-
+
+
+ QFrame::Box
+
+
-
-
-
- true
+
+
+ 0
-
- <html><head/><body><p>Table of Tool Bits of the library.</p></body></html>
+
+ 0
-
- true
-
-
- QAbstractItemView::InternalMove
-
-
- Qt::MoveAction
-
-
- QAbstractItemView::SelectRows
-
-
- true
-
-
- false
-
-
+
-
+
+
+ true
+
+
+ <html><head/><body><p>Table of Tool Bits of the library.</p></body></html>
+
+
+ QFrame::Box
+
+
+ QFrame::Sunken
+
+
+ 1
+
+
+ 0
+
+
+ true
+
+
+ QAbstractItemView::InternalMove
+
+
+ Qt::MoveAction
+
+
+ QAbstractItemView::SelectRows
+
+
+ true
+
+
+ false
+
+
+
+ -
+
+
-
+
+
+ Add Tool(s) to Job
+
+
+
+ :/icons/edit_OK.svg:/icons/edit_OK.svg
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 140
+ 20
+
+
+
+
+ -
+
+
+ <html><head/><body><p>Close the Tool Bit Library Editor</p></body></html>
+
+
+ Cancel
+
+
+
+ :/icons/button_invalid.svg:/icons/button_invalid.svg
+
+
+
+ -
+
+
+ <html><head/><body><p>Save the current Library</p></body></html>
+
+
+ Save Table
+
+
+
+ :/icons/document-save.svg:/icons/document-save.svg
+
+
+
+ -
+
+
+ <html><head/><body><p>Save the library to a new file</p></body></html>
+
+
+ Save Table As...
+
+
+
+ :/icons/document-save-as.svg:/icons/document-save-as.svg
+
+
+
+
+
+
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Add Tool Controller(s) to Job
-
-
-
- :/icons/edit_OK.svg:/icons/edit_OK.svg
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 14
- 20
-
-
-
-
- -
-
-
- <html><head/><body><p>Close the Tool Bit Library Editor</p></body></html>
-
-
- Cancel
-
-
-
- :/icons/button_invalid.svg:/icons/button_invalid.svg
-
-
-
+ -
+
-
@@ -235,38 +280,6 @@
- -
-
-
- <html><head/><body><p>Save the current Library</p></body></html>
-
-
- Save Table
-
-
-
- :/icons/document-save.svg:/icons/document-save.svg
-
-
-
- -
-
-
- <html><head/><body><p>Save the library to a new file</p></body></html>
-
-
- Save Table As...
-
-
-
- :/icons/document-save-as.svg:/icons/document-save-as.svg
-
-
-
-
-
- -
-
-
@@ -286,7 +299,7 @@
<html><head/><body><p>Add another Tool Bit to this library.</p><p><br/></p></body></html>
- Add Toolbit ...
+ Add Toolbit
@@ -300,7 +313,7 @@
<html><head/><body><p>Delete selected Tool Bit(s) from the library.</p><p><br/></p></body></html>
- Remove Selected
+ Remove
diff --git a/src/Mod/Path/PathScripts/PathPreferences.py b/src/Mod/Path/PathScripts/PathPreferences.py
index 87d8889c22..65eeefad59 100644
--- a/src/Mod/Path/PathScripts/PathPreferences.py
+++ b/src/Mod/Path/PathScripts/PathPreferences.py
@@ -44,6 +44,7 @@ PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
LastPathToolBit = "LastPathToolBit"
LastPathToolLibrary = "LastPathToolLibrary"
LastPathToolShape = "LastPathToolShape"
+LastPathToolTable ="LastPathToolTable"
UseLegacyTools = "UseLegacyTools"
UseAbsoluteToolPaths = "UseAbsoluteToolPaths"
@@ -209,6 +210,7 @@ def defaultOutputPolicy():
def defaultStockTemplate():
return preferences().GetString(DefaultStockTemplate, "")
+
def setDefaultStockTemplate(template):
preferences().SetString(DefaultStockTemplate, template)
@@ -223,16 +225,24 @@ def experimentalFeaturesEnabled():
def lastPathToolBit():
return preferences().GetString(LastPathToolBit, pathDefaultToolsPath('Bit'))
+
def setLastPathToolBit(path):
return preferences().SetString(LastPathToolBit, path)
def lastPathToolLibrary():
return preferences().GetString(LastPathToolLibrary, pathDefaultToolsPath('Library'))
+
def setLastPathToolLibrary(path):
return preferences().SetString(LastPathToolLibrary, path)
def lastPathToolShape():
return preferences().GetString(LastPathToolShape, pathDefaultToolsPath('Shape'))
+
def setLastPathToolShape(path):
return preferences().SetString(LastPathToolShape, path)
+def lastPathToolTable():
+ return preferences().GetString(LastPathToolTable, "")
+
+def setLastPathToolTable(table):
+ return preferences().SetString(LastPathToolTable, table)
diff --git a/src/Mod/Path/PathScripts/PathToolBitLibraryCmd.py b/src/Mod/Path/PathScripts/PathToolBitLibraryCmd.py
index 90f38fb896..e418192b60 100644
--- a/src/Mod/Path/PathScripts/PathToolBitLibraryCmd.py
+++ b/src/Mod/Path/PathScripts/PathToolBitLibraryCmd.py
@@ -91,7 +91,7 @@ class CommandToolBitLibraryLoad:
library = PathToolBitLibraryGui.ToolBitLibrary()
- if 1 == library.open(dialog=True) and job:
+ if 1 == library.open() and job:
for nr, tool in library.selectedOrAllTools():
tc = PathToolControllerGui.Create("TC: {}".format(tool.Label), tool, nr)
job.Proxy.addToolController(tc)
diff --git a/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py b/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py
index e3a3dfcc64..c9e509a3a8 100644
--- a/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py
+++ b/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py
@@ -224,7 +224,8 @@ class ToolBitLibrary(object):
reply = QtGui.QMessageBox.question(self.form, 'Warning', "Delete " + os.path.basename(self.path) + "?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel)
if reply == QtGui.QMessageBox.Yes and len(self.path) > 0:
os.remove(self.path)
- self.libraryOpen(False)
+ PathPreferences.setLastPathToolTable("")
+ self.libraryOpen(filedialog=False)
def toolEnumerate(self):
PathLog.track()
@@ -252,9 +253,11 @@ class ToolBitLibrary(object):
'''open(path=None, dialog=False) ... load library stored in path and bring up ui.
Returns 1 if user pressed OK, 0 otherwise.'''
if path:
- self.libraryOpen(False)
+ self.libraryOpen(path, filedialog=False)
elif dialog:
- self.libraryOpen()
+ self.libraryOpen(None, True)
+ else:
+ self.libraryOpen(None, False)
return self.form.exec_()
def updateToolbar(self):
@@ -263,22 +266,23 @@ class ToolBitLibrary(object):
else:
self.form.librarySave.setEnabled(False)
- def libraryOpen(self, filedialog=True):
+ def libraryOpen(self, path = None, filedialog=True):
import glob
PathLog.track()
- if filedialog:
+ path = PathPreferences.lastPathToolLibrary()
+
+ if filedialog or len(path) == 0:
path = PySide.QtGui.QFileDialog.getExistingDirectory(self.form, 'Tool Library Path', PathPreferences.lastPathToolLibrary(), 1)
+ #p = PySide.QtGui.QFileDialog.getOpenFileName(self.form, 'Tool Library', PathPreferences.lastPathToolLibrary(), '*.fctl')
if len(path) > 0:
PathPreferences.setLastPathToolLibrary(path)
else:
return
- else:
- path = PathPreferences.lastPathToolLibrary()
self.form.TableList.clear()
self.LibFiles.clear()
-
+
# Find all tool tables in directory
for file in glob.glob(path + '/*.fctl'):
self.LibFiles.append(file)
@@ -304,10 +308,17 @@ class ToolBitLibrary(object):
self.model.setHorizontalHeaderLabels(self.columnNames())
self.toolTableView.resizeColumnsToContents()
self.toolTableView.setUpdatesEnabled(True)
-
+
if len(self.LibFiles) > 0:
- self.libraryLoad(self.LibFiles[0])
- self.form.TableList.setCurrentRow(0)
+ for idx in range(len(self.LibFiles)):
+ if PathPreferences.lastPathToolTable() == os.path.basename(self.LibFiles[idx]):
+ break
+
+ if idx >= len(self.LibFiles):
+ idx = 0
+
+ self.libraryLoad(self.LibFiles[idx])
+ self.form.TableList.setCurrentRow(idx)
self.form.ButtonRemoveToolTable.setEnabled(True)
self.form.ButtonRenameToolTable.setEnabled(True)
@@ -318,6 +329,7 @@ class ToolBitLibrary(object):
if path:
with open(path) as fp:
+ PathPreferences.setLastPathToolTable(os.path.basename(path))
library = json.load(fp)
for toolBit in library['tools']:
@@ -333,6 +345,8 @@ class ToolBitLibrary(object):
self.toolTableView.resizeColumnsToContents()
self.toolTableView.setUpdatesEnabled(True)
+
+ #PathPreferences.setLastPathToolLibrary(path)
self.form.setWindowTitle("{} - {}".format(self.title, os.path.basename(path) if path else ''))
self.path = path
@@ -347,7 +361,7 @@ class ToolBitLibrary(object):
newName, ok = QtGui.QInputDialog.getText(None, translate("TooltableEditor","Rename Tooltable"),translate("TooltableEditor","Enter Name:"),QtGui.QLineEdit.Normal,name)
if ok and newName:
os.rename(PathPreferences.lastPathToolLibrary() + '/' + name, PathPreferences.lastPathToolLibrary() + '/' + newName)
- self.libraryOpen(False)
+ self.libraryOpen(filedialog=False)
#def createToolBit(self):
# tool = PathToolBit.ToolBitFactory().Create()
@@ -437,7 +451,7 @@ class ToolBitLibrary(object):
filename = PySide.QtGui.QFileDialog.getSaveFileName(self.form, \
translate("TooltableEditor", "Save toolbit library", None), \
- None, "{};;{}".format(TooltableTypeJSON, \
+ PathPreferences.lastPathToolLibrary(), "{};;{}".format(TooltableTypeJSON, \
TooltableTypeLinuxCNC))
# filename = PySide.QtGui.QFileDialog.getSaveFileName(self.form, \
# 'Tool Library', PathPreferences.lastPathToolLibrary(), '*.fctl')
@@ -451,7 +465,8 @@ class ToolBitLibrary(object):
self.path = path
self.librarySave()
self.updateToolbar()
- self.libraryOpen(False)
+ PathPreferences.setLastPathToolTable(os.path.basename(path))
+ self.libraryOpen(None, False)
def libraryCancel(self):
self.form.close()
@@ -487,7 +502,7 @@ class ToolBitLibrary(object):
self.form.ButtonRenameToolTable.clicked.connect(self.renameLibrary)
#self.form.libraryNew.clicked.connect(self.libraryNew)
- self.form.libraryOpen.clicked.connect(partial(self.libraryOpen, True))
+ self.form.libraryOpen.clicked.connect(partial(self.libraryOpen, filedialog=True))
self.form.librarySave.clicked.connect(self.librarySave)
self.form.librarySaveAs.clicked.connect(self.librarySaveAs)
self.form.libraryCancel.clicked.connect(self.libraryCancel)