Ejemplo n.º 1
0
int main(int argc, char* argv[])
{
    start_memory_tracking();

    // Our message handler must be set before the construction of QApplication.
    g_previous_message_handler = qInstallMsgHandler(message_handler);

    QApplication application(argc, argv);
    QApplication::setOrganizationName("appleseedhq");
    QApplication::setOrganizationDomain("appleseedhq.net");
    QApplication::setApplicationName("appleseed.studio");
    QApplication::setApplicationVersion(Appleseed::get_lib_version());
    QApplication::setWindowIcon(QIcon(make_app_path("icons/appleseed.png")));

    // The locale must be set after the construction of QApplication.
    QLocale::setDefault(QLocale::C);
    setlocale(LC_ALL, "C");

    check_installation();

    // Parse the command line.
    SuperLogger logger;
#ifdef _WIN32
    logger.set_log_target(create_string_log_target());
#endif
    CommandLineHandler cl;
    cl.parse(argc, const_cast<const char**>(argv), logger);

    configure_application(application);

    appleseed::studio::MainWindow window;

    if (!cl.m_filename.values().empty())
    {
        const QString filename = QString::fromStdString(cl.m_filename.value());

        if (cl.m_render.is_set())
        {
            const QString configuration = QString::fromStdString(cl.m_render.value());
            window.open_and_render_project(filename, configuration);
        }
        else
        {
            window.open_project(filename);
        }
    }

    window.show();

    return application.exec();
}
Ejemplo n.º 2
0
int main(int argc, char* argv[])
{
    // Enable memory tracking immediately as to catch as many leaks as possible.
    start_memory_tracking();

    // Our message handler must be set before the construction of QApplication.
    g_previous_message_handler = qInstallMsgHandler(message_handler);

    QApplication application(argc, argv);
    QApplication::setOrganizationName("appleseedhq");
    QApplication::setOrganizationDomain("appleseedhq.net");
    QApplication::setApplicationName("appleseed.studio");
    QApplication::setApplicationVersion(Appleseed::get_lib_version());
    QApplication::setWindowIcon(QIcon(make_app_path("icons/appleseed.png")));
    application.setAttribute(Qt::AA_DontUseNativeMenuBar, true);

    // The locale must be set after the construction of QApplication.
    QLocale::setDefault(QLocale::C);

    // QApplication sets C locale to the user's locale, we need to fix this.
    std::setlocale(LC_ALL, "C");

    // QT changes locale when loading image from disk for the very first time.
    // The problem was tracked for both QImage and QPixmap.
    // Both classes in their `load()` function call `QImageReader.read()`
    // which results in change of the locale back to system settings.
    // This is a dirty fix which loads any image at the very beginning and
    // resets the locale right after, thus preventing the `QImageReader.read()`
    // to change it again (as it happens only on the very first `read`).
    // Issue reported and tracked on GitHub under reference #1435.
    QImageReader(make_app_path("icons/icon.png")).read();   // any image

    // Make sure this build can run on this host.
    check_compatibility();

    // Make sure appleseed is correctly installed.
    check_installation();

    // Parse the command line.
    SuperLogger logger;
#ifdef _WIN32
    // On Windows, we will display command line arguments in a message box
    // so we need to capture CommandLineHandler's output into a string.
    logger.set_log_target(create_string_log_target());
#endif
    CommandLineHandler cl;
    cl.parse(argc, const_cast<const char**>(argv), logger);

    // Configure the application to use our default stylesheet file.
    set_default_stylesheet(application);

    // Create the application's main window.
    appleseed::studio::MainWindow window;

    // Initialize the python interpreter and load plugins.
    PythonInterpreter::instance().set_main_window(&window);
    PythonInterpreter::instance().load_plugins();

    // If a project file was specified on the command line, open it and optionally start rendering.
    if (!cl.m_filename.values().empty())
    {
        const QString filename = QString::fromStdString(cl.m_filename.value());

        if (cl.m_render.is_set())
        {
            const QString configuration = QString::fromStdString(cl.m_render.value());
            window.open_and_render_project(filename, configuration);
        }
        else
        {
            window.open_project_async(filename);
        }
    }

    window.show();

    return application.exec();
}