[Gui] Trigger the same checks for Drag & Drop files as File > Open
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <boost/interprocess/sync/file_lock.hpp>
|
||||
#include <Inventor/errors/SoDebugError.h>
|
||||
#include <Inventor/errors/SoError.h>
|
||||
#include <QCheckBox>
|
||||
#include <QCloseEvent>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
@@ -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<const App::Document*, Gui::Document*>::iterator doc = d->documents.find(&Doc);
|
||||
|
||||
@@ -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);
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user