Added a Settings file to hold configuration options in preparation for adding better support for external editors.

This commit is contained in:
Jeremy Wright 2014-12-18 13:42:07 -05:00
parent a0108668a5
commit 9c894268b8
2 changed files with 10 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import FreeCAD, FreeCADGui
from PySide import QtGui
import ExportCQ, ImportCQ
import module_locator
import Settings
#Distinguish python built-in open function from the one declared here
if open.__module__ == '__builtin__':
@ -213,8 +214,9 @@ class CadQuerySaveScript:
cqCodePane = mw.findChild(QtGui.QPlainTextEdit, "cqCodePane")
#If the code pane doesn't have a filename, we need to present the save as dialog
if len(cqCodePane.file.path) == 0 or os.path.basename(cqCodePane.file.path) == 'script_template.py':
FreeCAD.Console.PrintMessage("\r\nYou cannot save a blank file or save over a template file.")
if len(cqCodePane.file.path) == 0 or os.path.basename(cqCodePane.file.path) == 'script_template.py' \
or os.path.split(cqCodePane.file.path)[-2].endswith('Examples'):
FreeCAD.Console.PrintError("\r\nYou cannot save over a blank file, example file or template file.")
CadQuerySaveAsScript().Activated()
@ -223,6 +225,10 @@ class CadQuerySaveScript:
#Rely on our export library to help us save the file
ExportCQ.save()
#Execute the script if the user has asked for it
if Settings.execute_on_save:
CadQueryExecuteScript().Activated()
class CadQuerySaveAsScript:
"""CadQuery's command to save-as a script file"""
previousPath = None

2
CadQuery/Settings.py Normal file
View File

@ -0,0 +1,2 @@
execute_on_save = False # Automatically execute a script every time you save
use_external_editor = False # Automatically reloads and executes a file when an external change is made