diff --git a/src/App/Application.cpp b/src/App/Application.cpp index fb1a57735692..3cbbd6063c47 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -435,9 +435,11 @@ void Application::renameDocument(const char *OldName, const char *NewName) Document* Application::newDocument(const char * Name, const char * UserName, bool createView, bool tempDoc) { + QString L10nName = QObject::tr("UnnamedDoc"); // get a valid name anyway! if (!Name || Name[0] == '\0') - Name = "Unnamed"; + Name = qUtf8Printable(L10nName); +// Name = (L10nName.toStdString()).c_str(); string name = getUniqueDocumentName(Name, tempDoc); // return the temporary document if it exists diff --git a/src/App/CMakeLists.txt b/src/App/CMakeLists.txt index 7ebe15135e52..85d9f4fd95ee 100644 --- a/src/App/CMakeLists.txt +++ b/src/App/CMakeLists.txt @@ -128,8 +128,10 @@ SET(FreeCADApp_XML_SRCS ) SOURCE_GROUP("XML" FILES ${FreeCADApp_XML_SRCS}) +qt5_add_resources(FreeCADApp_QRC_SRCS Resources/App.qrc) # The document stuff SET(Document_CPP_SRCS + ${FreeCADApp_QRC_SRCS} Annotation.cpp Document.cpp DocumentObject.cpp diff --git a/src/Mod/Fem/App/AppFemPy.cpp b/src/Mod/Fem/App/AppFemPy.cpp index ce6bde8c372f..2a3082fb69ed 100644 --- a/src/Mod/Fem/App/AppFemPy.cpp +++ b/src/Mod/Fem/App/AppFemPy.cpp @@ -123,7 +123,8 @@ class Module : public Py::ExtensionModule mesh->read(EncodedName.c_str()); Base::FileInfo file(EncodedName.c_str()); // create new document and add Import feature - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + QString newDocumentName = QObject::tr("Unnamed"); + App::Document *pcDoc = App::GetApplication().newDocument(qUtf8Printable(newDocumentName)); FemMeshObject *pcFeature = static_cast (pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str())); pcFeature->Label.setValue(file.fileNamePure().c_str()); diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index 6527e60373af..1143c76a38f5 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -79,7 +79,7 @@ #include #include "ImpExpDxf.h" - +#include namespace Import { class ImportOCAFExt : public Import::ImportOCAF2 @@ -146,17 +146,17 @@ class Module : public Py::ExtensionModule std::string Utf8Name = std::string(Name); PyMem_Free(Name); std::string name8bit = Part::encodeFilename(Utf8Name); - + QString newDocumentName = QObject::tr("Unnamed"); try { //Base::Console().Log("Insert in Part with %s",Name); Base::FileInfo file(Utf8Name.c_str()); - + App::Document *pcDoc = nullptr; if (DocName) { pcDoc = App::GetApplication().getDocument(DocName); } if (!pcDoc) { - pcDoc = App::GetApplication().newDocument("Unnamed"); + pcDoc = App::GetApplication().newDocument(qUtf8Printable(newDocumentName)); } Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication(); diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index ded51294ed8d..39bb70f28347 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -411,7 +411,7 @@ class Module : public Py::ExtensionModule std::string Utf8Name = std::string(Name); PyMem_Free(Name); std::string name8bit = Part::encodeFilename(Utf8Name); - + QString newDocumentName = QObject::tr("Unnamed"); try { //Base::Console().Log("Insert in Part with %s",Name); Base::FileInfo file(Utf8Name.c_str()); @@ -421,7 +421,7 @@ class Module : public Py::ExtensionModule pcDoc = App::GetApplication().getDocument(DocName); } if (!pcDoc) { - pcDoc = App::GetApplication().newDocument("Unnamed"); + pcDoc = App::GetApplication().newDocument(qUtf8Printable(newDocumentName)); } Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication(); diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index c6675395d2e5..6403509bf412 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -173,9 +173,9 @@ class Module : public Py::ExtensionModule std::string EncodedName = std::string(Name); PyMem_Free(Name); - // create new document and add Import feature - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + QString newDocumentName = QObject::tr("Unnamed"); + App::Document *pcDoc = App::GetApplication().newDocument(qUtf8Printable(newDocumentName)); Mesh::Importer import(pcDoc); import.load(EncodedName); diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 64dd4f46bf65..1f42acad5bff 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -110,7 +110,7 @@ #include "TopoShapeSolidPy.h" #include "TopoShapeWirePy.h" #include "TopoShapeVertexPy.h" - +#include #ifdef FCUseFreeType # include "FT2FC.h" #endif @@ -630,14 +630,14 @@ class Module : public Py::ExtensionModule //Base::Console().Log("Open in Part with %s",Name); Base::FileInfo file(EncodedName.c_str()); - + QString newDocumentName = QObject::tr("Unnamed"); // extract ending if (file.extension().empty()) throw Py::RuntimeError("No file extension"); - if (file.hasExtension("stp") || file.hasExtension("step")) { // create new document and add Import feature - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + + App::Document *pcDoc = App::GetApplication().newDocument(qUtf8Printable(newDocumentName)); #if 1 ImportStepParts(pcDoc,EncodedName.c_str()); #else @@ -648,7 +648,8 @@ class Module : public Py::ExtensionModule } #if 1 else if (file.hasExtension("igs") || file.hasExtension("iges")) { - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + + App::Document *pcDoc = App::GetApplication().newDocument(qUtf8Printable(newDocumentName)); ImportIgesParts(pcDoc,EncodedName.c_str()); pcDoc->recompute(); } diff --git a/src/Mod/Path/Gui/AppPathGuiPy.cpp b/src/Mod/Path/Gui/AppPathGuiPy.cpp index b9f8c4a8cff3..682b265fdf69 100644 --- a/src/Mod/Path/Gui/AppPathGuiPy.cpp +++ b/src/Mod/Path/Gui/AppPathGuiPy.cpp @@ -103,8 +103,9 @@ class Module : public Py::ExtensionModule std::ostringstream pre; std::ostringstream cmd; + QString newDocumentName = QObject::tr("Unnamed"); if (processor.empty()) { - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + App::Document *pcDoc = App::GetApplication().newDocument(qUtf8Printable(newDocumentName)); Gui::Command::runCommand(Gui::Command::Gui,"import Path"); cmd << "Path.read(\"" << EncodedName << "\",\"" << pcDoc->getName() << "\")"; Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str()); diff --git a/src/Mod/Points/App/AppPointsPy.cpp b/src/Mod/Points/App/AppPointsPy.cpp index 22fa85c1285b..870fbbced47d 100644 --- a/src/Mod/Points/App/AppPointsPy.cpp +++ b/src/Mod/Points/App/AppPointsPy.cpp @@ -45,7 +45,7 @@ #include "PointsAlgos.h" #include "Structured.h" #include "Properties.h" - +#include namespace Points { class Module : public Py::ExtensionModule { @@ -112,8 +112,8 @@ class Module : public Py::ExtensionModule } reader->read(EncodedName); - - App::Document* pcDoc = App::GetApplication().newDocument("Unnamed"); + QString newDocumentName = QObject::tr("Unnamed"); + App::Document* pcDoc = App::GetApplication().newDocument(qUtf8Printable(newDocumentName)); Points::Feature* pcFeature = nullptr; if (reader->hasProperties()) {