Core: use FileHandler in Application::sOpen and Application::sInsert

This commit is contained in:
wmayer
2023-03-18 23:21:29 +01:00
parent e8d2f9527e
commit 771315cfdc
2 changed files with 25 additions and 108 deletions

View File

@@ -29,6 +29,7 @@
# include <QCloseEvent>
# include <QDir>
# include <QFileInfo>
# include <QImageReader>
# include <QLocale>
# include <QMessageBox>
# include <QMessageLogContext>
@@ -329,6 +330,22 @@ struct PyMethodDef FreeCADGui_methods[] = {
} // namespace Gui
namespace {
void setImportImageFormats()
{
QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
std::stringstream str;
str << "Image formats (";
for (const auto& ext : supportedFormats) {
str << "*." << ext.constData() << " ";
}
str << ")";
std::string filter = str.str();
App::GetApplication().addImportType(filter.c_str(), "FreeCADGui");
}
}
Application::Application(bool GUIenabled)
{
//App::GetApplication().Attach(this);
@@ -2158,6 +2175,7 @@ void Application::runApplication()
try {
Base::Console().Log("Run Gui init script\n");
runInitGuiScript();
setImportImageFormats();
}
catch (const Base::Exception& e) {
Base::Console().Error("Error in FreeCADGuiInit.py: %s\n", e.what());