Improved default behaviour and removed output-policy from job settings.

This commit is contained in:
Markus Lampert 2016-10-27 17:48:29 -07:00 committed by wmayer
parent 18791037be
commit 422ac087ed
3 changed files with 19 additions and 83 deletions

View File

@ -145,8 +145,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>391</height>
<width>353</width>
<height>173</height>
</rect>
</property>
<attribute name="icon">
@ -215,8 +215,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>376</height>
<width>378</width>
<height>391</height>
</rect>
</property>
<attribute name="icon">
@ -263,51 +263,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>File Save Policy</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QComboBox" name="cboOutputPolicy">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Choose how to deal with potential file name conflicts. Always open a dialog, only open a dialog if the output file already exists, overwrite any existing file or add a unique (3 digit) sequential ID to the file name.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string></string>
</property>
</item>
<item>
<property name="text">
<string>Open File Dialog</string>
</property>
</item>
<item>
<property name="text">
<string>Open File Dialog on conflict</string>
</property>
</item>
<item>
<property name="text">
<string>Overwrite existing file</string>
</property>
</item>
<item>
<property name="text">
<string>Append Unique ID on conflict</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -48,31 +48,20 @@ except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
class OutputPolicy:
Default = ''
Dialog = 'Open File Dialog'
DialogOnConflict = 'Open File Dialog on conflict'
Overwrite = 'Overwrite existing file'
AppendID = 'Append Unique ID on conflict'
All = [Default, Dialog, DialogOnConflict, Overwrite, AppendID]
class ObjectPathJob:
def __init__(self, obj):
# obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project")
obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project"))
obj.OutputFile = ''
obj.OutputFile = PathPreferences.defaultOutputFile()
obj.setEditorMode("OutputFile", 0) # set to default mode
obj.addProperty("App::PropertyEnumeration", "OutputPolicy", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The policy on how to save output files and resolve name conflicts"))
obj.OutputPolicy = OutputPolicy.All
obj.OutputPolicy = OutputPolicy.Default
obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job"))
obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor"))
obj.PostProcessor = PathPreferences.allEnabledPostProcessors([''])
obj.PostProcessor = ''
obj.PostProcessor = PathPreferences.defaultPostProcessor()
obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)"))
obj.PostProcessorArgs = ''
obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs()
obj.addProperty("App::PropertyString", "MachineName", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Name of the Machine that will use the CNC program"))
obj.addProperty("Path::PropertyTooltable", "Tooltable", "Base", QtCore.QT_TRANSLATE_NOOP("App::Property","The tooltable used for this CNC program"))
@ -270,16 +259,10 @@ class TaskPanel:
def getFields(self):
'''sets properties in the object to match the form'''
if self.obj:
if hasattr(self.obj, "PostProcessor"):
self.obj.PostProcessor = str(self.form.cboPostProcessor.currentText())
if hasattr(self.obj, "PostProcessorArgs"):
self.obj.PostProcessorArgs = str(self.form.cboPostProcessorArgs.displayText())
if hasattr(self.obj, "Label"):
self.obj.Label = str(self.form.leLabel.text())
if hasattr(self.obj, "OutputFile"):
self.obj.OutputFile = str(self.form.leOutputFile.text())
if hasattr(self.obj, "OutputPolicy"):
self.obj.OutputPolicy = str(self.form.cboOutputPolicy.currentText())
self.obj.PostProcessor = str(self.form.cboPostProcessor.currentText())
self.obj.PostProcessorArgs = str(self.form.cboPostProcessorArgs.displayText())
self.obj.Label = str(self.form.leLabel.text())
self.obj.OutputFile = str(self.form.leOutputFile.text())
oldlist = self.obj.Group
newlist = []
@ -313,7 +296,6 @@ class TaskPanel:
self.form.leLabel.setText(self.obj.Label)
self.form.leOutputFile.setText(self.obj.OutputFile)
self.selectComboBoxText(self.form.cboOutputPolicy, self.obj.OutputPolicy)
self.selectComboBoxText(self.form.cboPostProcessor, self.obj.PostProcessor)
self.obj.Proxy.onChanged(self.obj, "PostProcessor")
@ -347,7 +329,6 @@ class TaskPanel:
# Connect Signals and Slots
self.form.cboPostProcessor.currentIndexChanged.connect(self.getFields)
self.form.leOutputFile.editingFinished.connect(self.getFields)
self.form.cboOutputPolicy.currentIndexChanged.connect(self.getFields)
self.form.leLabel.editingFinished.connect(self.getFields)
self.form.btnSelectFile.clicked.connect(self.setFile)
self.form.PathsList.indexesMoved.connect(self.getFields)

View File

@ -45,20 +45,22 @@ class DlgSelectPostProcessor:
def __init__(self, parent=None):
self.dialog = FreeCADGui.PySideUic.loadUi(":/panels/DlgSelectPostProcessor.ui")
firstItem = None
for post in PathPreferences.allEnabledPostProcessors():
item = QtGui.QListWidgetItem(post)
item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
self.dialog.lwPostProcessor.addItem(item)
if not firstItem:
firstItem = item
if firstItem:
self.dialog.lwPostProcessor.setCurrentItem(firstItem)
else:
self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
self.tooltips = {}
self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
self.dialog.lwPostProcessor.itemDoubleClicked.connect(self.dialog.accept)
self.dialog.lwPostProcessor.itemSelectionChanged.connect(self.enableOkButton)
self.dialog.lwPostProcessor.setMouseTracking(True)
self.dialog.lwPostProcessor.itemEntered.connect(self.updateTooltip)
def enableOkButton(self):
self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True)
def updateTooltip(self, item):
if item.text() in self.tooltips.keys():
tooltip = self.tooltips[item.text()]
@ -104,9 +106,7 @@ class CommandPathPost:
M = pref.GetString("MacroPath", FreeCAD.getUserAppDataDir())
filename = filename.replace('%M', M)
policy = job.OutputPolicy
if not policy or policy == '':
policy = PathPreferences.defaultOutputPolicy()
policy = PathPreferences.defaultOutputPolicy()
openDialog = policy == 'Open File Dialog'
if os.path.isdir(filename) or not os.path.isdir(os.path.dirname(filename)):