diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 5a13553bf4..c8827f4b01 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -707,6 +708,11 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch // load the file with the module if (File.hasExtension("FCStd")) { Command::doCommand(Command::App, "%s.open(u\"%s\")", Module, unicodepath.c_str()); + setStatus(UserInitiatedOpenDocument, false); + App::Document* doc = App::GetApplication().getActiveDocument(); + checkPartialRestore(doc); + checkRestoreError(doc); + checkForRecomputes(); if (activeDocument()) { activeDocument()->setModified(false); } @@ -1007,6 +1013,30 @@ void Application::checkForRecomputes() { "Please check report view for more details.")); } +void Application::checkPartialRestore(App::Document* doc) +{ + if (doc && doc->testStatus(App::Document::PartialRestore)) { + QMessageBox::critical( + getMainWindow(), + QObject::tr("Error"), + QObject::tr("There were errors while loading the file. Some data might have been " + "modified or not recovered at all. Look in the report view for more " + "specific information about the objects involved.")); + } +} + +void Application::checkRestoreError(App::Document* doc) +{ + if (doc && doc->testStatus(App::Document::RestoreError)) { + QMessageBox::critical( + getMainWindow(), + QObject::tr("Error"), + QObject::tr("There were serious errors while loading the file. Some data might have " + "been modified or not recovered at all. Saving the project will most " + "likely result in loss of data.")); + } +} + void Application::slotActiveDocument(const App::Document& Doc) { std::map::iterator doc = d->documents.find(&Doc); diff --git a/src/Gui/Application.h b/src/Gui/Application.h index e358e6008c..54f7c4dd15 100644 --- a/src/Gui/Application.h +++ b/src/Gui/Application.h @@ -79,6 +79,10 @@ public: App::Document *reopen(App::Document *doc); /// Prompt about recomputing if needed static void checkForRecomputes(); + /// Prompt about PartialRestore + void checkPartialRestore(App::Document* doc); + /// Prompt for Errors on open + void checkRestoreError(App::Document* doc); //@} diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 6d9274b69a..8ed8880d7e 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -96,26 +96,6 @@ StdCmdOpen::StdCmdOpen() void StdCmdOpen::activated(int iMsg) { - // clang-format off - auto checkPartialRestore = [](App::Document* doc) { - if (doc && doc->testStatus(App::Document::PartialRestore)) { - QMessageBox::critical(getMainWindow(), QObject::tr("Error"), - QObject::tr("There were errors while loading the file. Some data might have been " - "modified or not recovered at all. Look in the report view for more " - "specific information about the objects involved.")); - } - }; - - auto checkRestoreError = [](App::Document* doc) { - if (doc && doc->testStatus(App::Document::RestoreError)) { - QMessageBox::critical(getMainWindow(), QObject::tr("Error"), - QObject::tr("There were serious errors while loading the file. Some data might have " - "been modified or not recovered at all. Saving the project will most " - "likely result in loss of data.")); - } - }; - // clang-format on - Q_UNUSED(iMsg); // fill the list of registered endings @@ -183,8 +163,8 @@ void StdCmdOpen::activated(int iMsg) App::Document *doc = App::GetApplication().getActiveDocument(); - checkPartialRestore(doc); - checkRestoreError(doc); + getGuiApplication()->checkPartialRestore(doc); + getGuiApplication()->checkRestoreError(doc); } } }