diff --git a/src/Mod/CAM/Path/Post/Utils.py b/src/Mod/CAM/Path/Post/Utils.py index 0b43cb0b25..9c01bf2030 100644 --- a/src/Mod/CAM/Path/Post/Utils.py +++ b/src/Mod/CAM/Path/Post/Utils.py @@ -208,7 +208,7 @@ class GCodeHighlighter(QtGui.QSyntaxHighlighter): class GCodeEditorDialog(QtGui.QDialog): - def __init__(self, parent=None): + def __init__(self, parent=None, refactored=False): if parent is None: parent = FreeCADGui.getMainWindow() QtGui.QDialog.__init__(self, parent) @@ -225,14 +225,21 @@ class GCodeEditorDialog(QtGui.QDialog): self.editor.setText("G01 X55 Y4.5 F300.0") layout.addWidget(self.editor) - # OK and Cancel buttons - self.buttons = QtGui.QDialogButtonBox( - QtGui.QDialogButtonBox.Apply - | QtGui.QDialogButtonBox.Discard - | QtGui.QDialogButtonBox.Cancel, - QtCore.Qt.Horizontal, - self, - ) + # buttons depending on the post processor used + if refactored: + self.buttons = QtGui.QDialogButtonBox( + QtGui.QDialogButtonBox.Apply + | QtGui.QDialogButtonBox.Discard + | QtGui.QDialogButtonBox.Cancel, + QtCore.Qt.Horizontal, + self, + ) + else: + self.buttons = QtGui.QDialogButtonBox( + QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, + QtCore.Qt.Horizontal, + self, + ) layout.addWidget(self.buttons) # restore placement and size @@ -253,7 +260,7 @@ class GCodeEditorDialog(QtGui.QDialog): match self.buttons.buttonRole(button): case QtGui.QDialogButtonBox.RejectRole: self.done(0) - case QtGui.QDialogButtonBox.ApplyRole: + case QtGui.QDialogButtonBox.ApplyRole | QtGui.QDialogButtonBox.AcceptRole: self.done(1) case QtGui.QDialogButtonBox.DestructiveRole: self.done(2) diff --git a/src/Mod/CAM/Path/Post/UtilsExport.py b/src/Mod/CAM/Path/Post/UtilsExport.py index 03e082269c..da5023548f 100644 --- a/src/Mod/CAM/Path/Post/UtilsExport.py +++ b/src/Mod/CAM/Path/Post/UtilsExport.py @@ -336,7 +336,7 @@ def export_common(values: Values, objectslist, filename: str) -> str: if len(final) > 100000: print("Skipping editor since output is greater than 100kb") else: - dia = PostUtils.GCodeEditorDialog() + dia = PostUtils.GCodeEditorDialog(refactored=True) # the editor expects lines to end in "\n", and returns lines ending in "\n" if values["END_OF_LINE_CHARACTERS"] == "\n": dia.editor.setText(final) @@ -361,9 +361,8 @@ def export_common(values: Values, objectslist, filename: str) -> str: # "\r\n" means "use \r\n" final = final_for_editor.replace("\n", values["END_OF_LINE_CHARACTERS"]) - print("done postprocessing.") - if editor_result == 0: + print("canceled postprocessing.") return None if not filename == "-": @@ -382,4 +381,6 @@ def export_common(values: Values, objectslist, filename: str) -> str: # "write out the gcode with whatever end-of-line characters the system # that is running the postprocessor uses". gfile.write(final) + + print("done postprocessing.") return final