Added a Settings file to hold configuration options in preparation for adding better support for external editors.
This commit is contained in:
parent
a0108668a5
commit
9c894268b8
|
@ -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
2
CadQuery/Settings.py
Normal 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
|
Loading…
Reference in New Issue
Block a user