PartDesign: Return to previous feature after edit

This commit is contained in:
Kacper Donat
2025-06-19 21:33:14 +02:00
parent 386c5cd910
commit 2b5a95f3d0
4 changed files with 51 additions and 21 deletions

View File

@@ -108,14 +108,18 @@ bool ViewProvider::setEdit(int ModNum)
msgBox.setInformativeText(QObject::tr("Close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes) {
if (msgBox.exec() == QMessageBox::Yes) {
Gui::Control().reject();
} else {
return false;
}
}
previouslyShownViewProvider = dynamic_cast<ViewProvider*>(
Gui::Application::Instance->getViewProvider(getBodyViewProvider()->getShownFeature())
);
// clear the selection (convenience)
Gui::Selection().clearSelection();
@@ -146,27 +150,21 @@ TaskDlgFeatureParameters *ViewProvider::getEditDialog() {
void ViewProvider::unsetEdit(int ModNum)
{
// return to the WB we were in before editing the PartDesign feature
if (!oldWb.empty())
if (!oldWb.empty()) {
Gui::Command::assureWorkbench(oldWb.c_str());
}
// ensure that after edit we still show the same feature
if (previouslyShownViewProvider) {
previouslyShownViewProvider->show();
}
if (ModNum == ViewProvider::Default) {
// when pressing ESC make sure to close the dialog
#if 0
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
#endif
Gui::Control().closeDialog();
#if 0
if ((activeBody != NULL) && (oldTip != NULL)) {
Gui::Selection().clearSelection();
Gui::Selection().addSelection(oldTip->getDocument()->getName(), oldTip->getNameInDocument());
Gui::Command::doCommand(Gui::Command::Gui,"FreeCADGui.runCommand('PartDesign_MoveTip')");
}
#endif
oldTip = nullptr;
}
else {
PartGui::ViewProviderPart::unsetEdit(ModNum);
oldTip = nullptr;
}
}