From 61888959e26e6e02e8668bed35bcb418bca7a216 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Wed, 16 Mar 2022 11:47:51 -0500 Subject: [PATCH] Path: Change action to warning with option for action. --- src/Mod/Path/PathScripts/PathJobGui.py | 32 ++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathJobGui.py b/src/Mod/Path/PathScripts/PathJobGui.py index 8e18c2df41..15294360d4 100644 --- a/src/Mod/Path/PathScripts/PathJobGui.py +++ b/src/Mod/Path/PathScripts/PathJobGui.py @@ -1572,15 +1572,37 @@ class TaskPanel: def _jobIntegrityCheck(self): """_jobIntegrityCheck() ... Check Job object for existence of Model and Tools - If either Model or Tools is empty, change GUI tab and open appropriate selection window.""" + If either Model or Tools is empty, change GUI tab, issue appropriate warning, + and offer chance to add appropriate item.""" + + def _displayWarningWindow(msg): + """Display window with warning message and Add action button. + Return action state.""" + txtHeader = translate("Path_Job", "Warning") + txtPleaseAddOne = translate("Path_Job", "Please add one.") + txtOk = translate("Path_Job", "Ok") + txtAdd = translate("Path_Job", "Add") + + msgbox = QtGui.QMessageBox( + QtGui.QMessageBox.Warning, txtHeader, msg + " " + txtPleaseAddOne + ) + msgbox.addButton(txtOk, QtGui.QMessageBox.AcceptRole) # Add 'Ok' button + msgbox.addButton(txtAdd, QtGui.QMessageBox.ActionRole) # Add 'Add' button + return msgbox.exec_() + + # Check if at least on base model is present if len(self.obj.Model.Group) == 0: - PathLog.info(translate("Path_Job", "Please select a model for this job.")) self.form.setCurrentIndex(0) # Change tab to General tab - self.jobModelEdit() + no_model_txt = translate("Path_Job", "This job has no base model.") + if _displayWarningWindow(no_model_txt) == 1: + self.jobModelEdit() + + # Check if at least one tool is present if len(self.obj.Tools.Group) == 0: - PathLog.info(translate("Path_Job", "Please add a tool to this job.")) self.form.setCurrentIndex(3) # Change tab to Tools tab - self.toolControllerAdd() + no_tool_txt = translate("Path_Job", "This job has no tool.") + if _displayWarningWindow(no_tool_txt) == 1: + self.toolControllerAdd() # SelectionObserver interface def addSelection(self, doc, obj, sub, pnt):