Skip to content

Commit

Permalink
Abort changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Schildkroet committed Jan 2, 2021
1 parent cb9ad77 commit c504860
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/Mod/Path/PathScripts/PathDressupLeadInOut.py
Expand Up @@ -466,8 +466,9 @@ def generateLeadInOutCurve(self, obj):


class TaskPanel:
def __init__(self, obj):
def __init__(self, obj, view):
self.obj = obj
self.viewProvider = view
self.form = FreeCADGui.PySideUic.loadUi(":/panels/DressUpLeadInOutEdit.ui")
self.setupUi()

Expand All @@ -492,6 +493,12 @@ def clicked(self, button):
if button == QtGui.QDialogButtonBox.Apply:
self.updateModel()
FreeCAD.ActiveDocument.recompute()
if button == QtGui.QDialogButtonBox.Cancel:
self.abort()

def abort(self):
FreeCAD.ActiveDocument.abortTransaction()
self.cleanup(True)

def reject(self):
FreeCAD.ActiveDocument.abortTransaction()
Expand All @@ -504,6 +511,13 @@ def accept(self):
FreeCADGui.ActiveDocument.resetEdit()
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()

def cleanup(self, gui):
self.viewProvider.clearTaskPanel()
if gui:
#FreeCADGui.ActiveDocument.resetEdit()
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()

def getFields(self):
self.obj.LeadIn = self.form.chkLeadIn.isChecked()
Expand Down Expand Up @@ -567,6 +581,7 @@ def __init__(self, vobj):

def attach(self, vobj):
self.obj = vobj.Object
self.panel = None

def claimChildren(self):
if hasattr(self.obj.Base, "InList"):
Expand All @@ -584,10 +599,14 @@ def claimChildren(self):
def setEdit(self, vobj, mode=0):
# pylint: disable=unused-argument
FreeCADGui.Control.closeDialog()
panel = TaskPanel(vobj.Object)
panel = TaskPanel(vobj.Object, self)
FreeCADGui.Control.showDialog(panel)
panel.setupUi()
return True

def unsetEdit(self, vobj, mode=0):
if self.panel:
self.panel.abort()

def onDelete(self, arg1=None, arg2=None):
'''this makes sure that the base operation is added back to the project and visible'''
Expand All @@ -607,6 +626,9 @@ def __getstate__(self):
def __setstate__(self, state):
# pylint: disable=unused-argument
return None

def clearTaskPanel(self):
self.panel = None


class CommandPathDressupLeadInOut:
Expand Down

0 comments on commit c504860

Please sign in to comment.