Added file path and job template to preferences.

This commit is contained in:
Markus Lampert
2017-06-21 11:41:34 -07:00
parent 0fcaea1b44
commit 907ea1b3ab
3 changed files with 415 additions and 239 deletions
+325 -223
View File
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>503</width>
<height>557</height>
<width>560</width>
<height>609</height>
</rect>
</property>
<property name="windowTitle">
@@ -15,235 +15,337 @@
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>0</number>
</property>
<property name="title">
<string>Output File</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Default Path</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="leOutputFile">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter a path and optionally file name (see below) to be used as the default for the post processor export.&lt;/p&gt;&lt;p&gt;The following substitutions are performed before the name is resolved at the time of the post processing:&lt;/p&gt;&lt;p&gt;%D ... directory of the active document&lt;br/&gt;%d ... name of the active document (with extension)&lt;br/&gt;%M ... user macro directory&lt;br/&gt;%j ... name of the active Job object&lt;/p&gt;&lt;p&gt;The following example store all files with the same name as the document the directory /home/freecad (please remove quotes):&lt;/p&gt;&lt;p&gt;&amp;quot;/home/cnc/%d.g-code&amp;quot;&lt;/p&gt;&lt;p&gt;See the file save policy below on how to deal with name conflicts.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbBrowseFileSystem">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" 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;Open a file system browser to select default path for output files.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>File Save Policy</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<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>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>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Post Processor</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<height>519</height>
</rect>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Post Processors Selection </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QListWidget" name="postProcessorList">
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;It doesn't seem there are any post processor scripts installed. Pleas add some into your macro directory and make sure the file name ends with &amp;quot;_post.py&amp;quot;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Default Post Processor</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="defaultPostProcessor">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select one of the post processors as the default.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="prefEntry" stdset="0">
<string>DefaultPostProcessor</string>
</property>
<property name="prefPath" stdset="0">
<string>Mod/Path</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default Arguments</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="defaultPostProcessorArgs">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Optional arguments passed to the default Post Processor specified above. See the Post Processor's documentation for supported arguments.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultPostProcessorArgs</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
<attribute name="label">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Defaults</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QLineEdit" name="leDefaultFilePath">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Path to look for templates, post processors, tool tables and other external files.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If left empty the macro directory is used.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Path</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="tbDefaultFilePath">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Template</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leDefaultJobTemplate">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default template to be selected when creating a new Job. &lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;This can be helpful when almost all jobs will be processed by the same machine with a similar setup.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If left empty no template will be preselected.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="tbDefaultJobTemplate">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Geometry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QWidget" name="widget_5" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Default Geometry Tolerance</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="geometryTolerance" native="true">
<property name="toolTip">
<string>Default value for new Jobs, used for computing Paths. Smaller increases accuracy, but slows down computation</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<height>519</height>
</rect>
</property>
<attribute name="label">
<string>Post Processor</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Output File</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Default Path</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="leOutputFile">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter a path and optionally file name (see below) to be used as the default for the post processor export.&lt;/p&gt;&lt;p&gt;The following substitutions are performed before the name is resolved at the time of the post processing:&lt;/p&gt;&lt;p&gt;%D ... directory of the active document&lt;br/&gt;%d ... name of the active document (with extension)&lt;br/&gt;%M ... user macro directory&lt;br/&gt;%j ... name of the active Job object&lt;/p&gt;&lt;p&gt;The following example store all files with the same name as the document the directory /home/freecad (please remove quotes):&lt;/p&gt;&lt;p&gt;&amp;quot;/home/cnc/%d.g-code&amp;quot;&lt;/p&gt;&lt;p&gt;See the file save policy below on how to deal with name conflicts.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbOutputFile">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>File Save Policy</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<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>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>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Post Processor</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Post Processors Selection </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QListWidget" name="postProcessorList">
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;It doesn't seem there are any post processor scripts installed. Pleas add some into your macro directory and make sure the file name ends with &amp;quot;_post.py&amp;quot;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Default Post Processor</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="defaultPostProcessor">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select one of the post processors as the default.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="prefEntry" stdset="0">
<string>DefaultPostProcessor</string>
</property>
<property name="prefPath" stdset="0">
<string>Mod/Path</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default Arguments</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="defaultPostProcessorArgs">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Optional arguments passed to the default Post Processor specified above. See the Post Processor's documentation for supported arguments.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultPostProcessorArgs</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Geometry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QWidget" name="widget_5" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Default Geometry Tolerance</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="geometryTolerance">
<property name="toolTip">
<string>Default value for new Jobs, used for computing Paths. Smaller increases accuracy, but slows down computation</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QWidget</extends>
<header>gui::inputfield.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+42 -10
View File
@@ -26,12 +26,23 @@ import FreeCAD
import os
import glob
import PathScripts.PathLog as PathLog
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.trackModule()
class PathPreferences:
PostProcessorDefault = "PostProcessorDefault"
PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
PostProcessorBlacklist = "PostProcessorBlacklist"
DefaultFilePath = "DefaultFilePath"
DefaultJobTemplate = "DefaultJobTemplate"
PostProcessorDefault = "PostProcessorDefault"
PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
PostProcessorBlacklist = "PostProcessorBlacklist"
PostProcessorOutputFile = "PostProcessorOutputFile"
PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
# Linear tolerance to use when generating Paths, eg when tesselating geometry
GeometryTolerance = "GeometryTolerance"
GeometryTolerance = "GeometryTolerance"
@classmethod
def preferences(cls):
@@ -76,6 +87,30 @@ class PathPreferences:
def defaultGeometryTolerance(cls):
return cls.preferences().GetFloat(cls.GeometryTolerance, 0.01)
@classmethod
def defaultFilePath(cls):
return cls.preferences().GetString(cls.DefaultFilePath)
@classmethod
def filePath(cls):
path = cls.defaultFilePath()
if not path:
grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
path = grp.GetString("MacroPath", FreeCAD.getUserAppDataDir())
return path
@classmethod
def defaultJobTemplate(cls):
return cls.preferences().GetString(cls.DefaultJobTemplate)
@classmethod
def setJobDefaults(cls, filePath, jobTemplate, geometryTolerance):
PathLog.track("(%s='%s', %s, %s)" % (cls.DefaultFilePath, filePath, jobTemplate, geometryTolerance))
pref = cls.preferences()
pref.SetString(cls.DefaultFilePath, filePath)
pref.SetString(cls.DefaultJobTemplate, jobTemplate)
pref.SetFloat(cls.GeometryTolerance, geometryTolerance)
@classmethod
def postProcessorBlacklist(cls):
pref = cls.preferences()
@@ -85,19 +120,15 @@ class PathPreferences:
return eval(blacklist)
@classmethod
def savePostProcessorDefaults(cls, processor, args, blacklist, geometryTolerance):
def setPostProcessorDefaults(cls, processor, args, blacklist):
pref = cls.preferences()
pref.SetString(cls.PostProcessorDefault, processor)
pref.SetString(cls.PostProcessorDefaultArgs, args)
pref.SetString(cls.PostProcessorBlacklist, "%s" % (blacklist))
pref.SetFloat(cls.GeometryTolerance, geometryTolerance)
PostProcessorOutputFile = "PostProcessorOutputFile"
PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
@classmethod
def saveOutputFileDefaults(cls, file, policy):
def setOutputFileDefaults(cls, file, policy):
pref = cls.preferences()
pref.SetString(cls.PostProcessorOutputFile, file)
pref.SetString(cls.PostProcessorOutputPolicy, policy)
@@ -111,3 +142,4 @@ class PathPreferences:
def defaultOutputPolicy(cls):
pref = cls.preferences()
return pref.GetString(cls.PostProcessorOutputPolicy, "")
@@ -24,12 +24,17 @@
import FreeCAD
import FreeCADGui
import PathScripts.PathLog as PathLog
from FreeCAD import Units
from PySide import QtCore, QtGui
from PathScripts.PathPreferences import PathPreferences
from PathScripts.PathPostProcessor import PostProcessor
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
class JobPreferencesPage:
def __init__(self, parent=None):
self.form = FreeCADGui.PySideUic.loadUi(":preferences/PathJob.ui")
@@ -39,6 +44,11 @@ class JobPreferencesPage:
self.processor = { }
def saveSettings(self):
filePath = self.form.leDefaultFilePath.text()
jobTemplate = self.form.leDefaultJobTemplate.text()
geometryTolerance = Units.Quantity(self.form.geometryTolerance.text())
PathPreferences.setJobDefaults(filePath, jobTemplate, geometryTolerance)
processor = str(self.form.defaultPostProcessor.currentText())
args = str(self.form.defaultPostProcessorArgs.text())
blacklist = []
@@ -46,12 +56,11 @@ class JobPreferencesPage:
item = self.form.postProcessorList.item(i)
if item.checkState() == QtCore.Qt.CheckState.Unchecked:
blacklist.append(item.text())
geometryTolerance = Units.Quantity(self.form.geometryTolerance.text())
PathPreferences.savePostProcessorDefaults(processor, args, blacklist, geometryTolerance)
PathPreferences.setPostProcessorDefaults(processor, args, blacklist)
path = str(self.form.leOutputFile.text())
policy = str(self.form.cboOutputPolicy.currentText())
PathPreferences.saveOutputFileDefaults(path, policy)
PathPreferences.setOutputFileDefaults(path, policy)
def selectComboEntry(self, widget, text):
index = widget.findText(text, QtCore.Qt.MatchFixedString)
@@ -82,6 +91,9 @@ class JobPreferencesPage:
self.verifyAndUpdateDefaultPostProcessorWith(str(self.form.defaultPostProcessor.currentText()))
def loadSettings(self):
self.form.leDefaultFilePath.setText(PathPreferences.defaultFilePath())
self.form.leDefaultJobTemplate.setText(PathPreferences.defaultJobTemplate())
blacklist = PathPreferences.postProcessorBlacklist()
for processor in PathPreferences.allAvailablePostProcessors():
item = QtGui.QListWidgetItem(processor)
@@ -101,10 +113,12 @@ class JobPreferencesPage:
self.form.leOutputFile.setText(PathPreferences.defaultOutputFile())
self.selectComboEntry(self.form.cboOutputPolicy, PathPreferences.defaultOutputPolicy())
self.form.tbDefaultFilePath.clicked.connect(self.browseDefaultFilePath)
self.form.tbDefaultJobTemplate.clicked.connect(self.browseDefaultJobTemplate)
self.form.postProcessorList.itemEntered.connect(self.setProcessorListTooltip)
self.form.postProcessorList.itemChanged.connect(self.verifyAndUpdateDefaultPostProcessor)
self.form.defaultPostProcessor.currentIndexChanged.connect(self.updateDefaultPostProcessorToolTip)
self.form.pbBrowseFileSystem.clicked.connect(self.browseFileSystem)
self.form.tbOutputFile.clicked.connect(self.browseOutputFile)
def getPostProcessor(self, name):
if not name in self.processor.keys():
@@ -136,7 +150,35 @@ class JobPreferencesPage:
self.form.defaultPostProcessor.setToolTip(self.postProcessorDefaultTooltip)
self.form.defaultPostProcessorArgs.setToolTip(self.postProcessorArgsDefaultTooltip)
def browseFileSystem(self):
foo = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow(), "Path - Output File/Directory", self.form.leOutputFile.text())
def bestGuessForFilePath(self):
path = self.form.leDefaultFilePath.text()
if not path:
path = PathPreferences.filePath()
return path
def browseDefaultJobTemplate(self):
path = self.form.leDefaultJobTemplate.text()
if not path:
path = self.bestGuessForFilePath()
foo = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),
"Path - Job Template",
path,
"job_*.xml")[0]
if foo:
self.form.leDefaultJobTemplate.setText(foo)
def browseDefaultFilePath(self):
path = self.bestGuessForFilePath()
foo = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow(), "Path - External File Directory", path)
if foo:
self.form.leDefaultFilePath.setText(foo)
def browseOutputFile(self):
path = self.form.leOutputFile.text()
foo = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow(), "Path - Output File/Directory", path)
if foo:
self.form.leOutputFile.setText(foo)