Exemplo n.º 1
0
int main(int argc, char** argv)
{
  try
  {
    INIT_OPENFLUID_APPLICATION_WITH_GUI(argc, argv);

    // translations management
    QString Lang = openfluid::base::PreferencesManager::instance()->getLang();

    QTranslator QtTranslator;
    QTranslator OpenFLUIDTranslator;
    if (Lang != "default")
    {
      // load provided default translations
      QtTranslator.load("qt_" + Lang.left(2) + ".qm",
                        QLibraryInfo::location(QLibraryInfo::TranslationsPath));

      // load provided OpenFLUID translations
      OpenFLUIDTranslator.load(
          QString(openfluid::config::TRANSLATIONS_FILEROOT.c_str()) + "-" + Lang + ".qm",
          QString(openfluid::base::Environment::getTranslationsDir().c_str()));
    }
    OPENFLUID_APPLICATION.installTranslator(&QtTranslator);
    OPENFLUID_APPLICATION.installTranslator(&OpenFLUIDTranslator);

// TODO remove the #if linux when icons problem on win32 will be solved
#if linux
    Q_INIT_RESOURCE(openfluiduicommon);
#endif

    QString LogDir;

    if (argc >= 2)
      LogDir = QString(argv[1]);
    else
      LogDir = QDir::currentPath();

    openfluid::ui::common::LogExplorerDialog LogDlg(LogDir);

    QRect ScreenRect = QApplication::desktop()->screenGeometry();
    LogDlg.resize(ScreenRect.width()*0.9,ScreenRect.height()*0.9);
    LogDlg.move((ScreenRect.width()-LogDlg.width())/2, (ScreenRect.height()-LogDlg.height())/2);

    LogDlg.show();

    return CLOSE_OPENFLUID_APPLICATION_WITH_GUI;
  }
  catch (std::bad_alloc & E)
  {
    std::cerr << "bad_alloc ERROR: " << E.what()
              << ". Possibly not enough memory available" << std::endl;
  }
  catch (std::bad_exception & E)
  {
    std::cerr << "bad_exception ERROR: " << E.what() << std::endl;
  }
  catch (std::bad_cast & E)
  {
    std::cerr << "bad_cast ERROR: " << E.what() << std::endl;
  }
  catch (std::exception & E)
  {
    std::cerr << "std ERROR: " << E.what() << std::endl;
  }
  catch (...)
  {
    std::cerr << "ERROR: " << "Unknown Error" << std::endl;
  }
}
Exemplo n.º 2
0
int main(int argc, char** argv)
{
  try
  {
    INIT_OPENFLUID_APPLICATION_WITH_GUI(argc, argv);

    openfluid::ui::common::OpenFLUIDSplashScreen Splash(QPixmap(":/images/openfluid_splash_devstudio.png"));
    Splash.show();

    Splash.setMessage("i18n");

    // translations management
    QString Lang = openfluid::base::PreferencesManager::instance()->getLang();

    QTranslator QtTranslator;
    QTranslator OpenFLUIDTranslator;
    if (Lang != "default")
    {
      // load provided default translations
      QtTranslator.load("qt_" + Lang.left(2) + ".qm", QLibraryInfo::location(QLibraryInfo::TranslationsPath));

      // load provided OpenFLUID translations
      OpenFLUIDTranslator.load(QString(openfluid::config::TRANSLATIONS_FILEROOT.c_str()) + "-" + Lang + ".qm",
                               QString(openfluid::base::Environment::getTranslationsDir().c_str()));
    }
    OPENFLUID_APPLICATION.installTranslator(&QtTranslator);
    OPENFLUID_APPLICATION.installTranslator(&OpenFLUIDTranslator);

//    OPENFLUID_APPLICATION.setStyleSheet(QString("QToolTip { color: #FFFFFF; background-color: %1; "
//                                                "border: 1px solid %2; }")
//                                        .arg(BUILDER_TOOLTIP_BGCOLOR,BUILDER_TOOLTIP_BORDERCOLOR));


// TODO remove the #if linux when icons problem on win32 will be solved
#if linux
    Q_INIT_RESOURCE(openfluiduicommon);
#endif

//    OPENFLUID_APPLICATION.setAttribute(Qt::AA_DontShowIconsInMenus);

    MainWindow m_MainWindow(&Splash);
    m_MainWindow.show();
    Splash.finish(&m_MainWindow);

    return CLOSE_OPENFLUID_APPLICATION_WITH_GUI;
  }
  catch (std::bad_alloc & E)
  {
    std::cerr << "bad_alloc ERROR: " << E.what() << ". Possibly not enough memory available" << std::endl;
  }
  catch (std::bad_exception & E)
  {
    std::cerr << "bad_exception ERROR: " << E.what() << std::endl;
  }
  catch (std::bad_cast & E)
  {
    std::cerr << "bad_cast ERROR: " << E.what() << std::endl;
  }
  catch (std::exception & E)
  {
    std::cerr << "std ERROR: " << E.what() << std::endl;
  }
  catch (...)
  {
    std::cerr << "ERROR: " << "Unknown Error" << std::endl;
  }
}
Exemplo n.º 3
0
int main(int argc, char** argv)
{

  try
  {

    int ExitCode = 0;

    INIT_OPENFLUID_APPLICATION_WITH_GUI(argc,argv);

    do
    {
      openfluid::ui::common::OpenFLUIDSplashScreen Splash(
        openfluid::ui::common::getImage("openfluid_splash_builder","builder")
      );

      Splash.show();

      Splash.setMessage("i18n");
      // translations management
      QString Lang = openfluid::base::PreferencesManager::instance()->getLang();

      QTranslator QtTranslator;
      QTranslator OpenFLUIDTranslator;
      if (Lang != "default")
      {
        // load provided default translations
        QtTranslator.load("qt_"+Lang.left(2)+".qm",
                          QLibraryInfo::location(QLibraryInfo::TranslationsPath));

        // load provided OpenFLUID translations
        OpenFLUIDTranslator.load(QString(openfluid::config::TRANSLATIONS_FILEROOT.c_str()) + "-" + Lang + ".qm",
                                 QString(openfluid::base::Environment::getTranslationsDir().c_str()));
      }
      OPENFLUID_APPLICATION.installTranslator(&QtTranslator);
      OPENFLUID_APPLICATION.installTranslator(&OpenFLUIDTranslator);

      OPENFLUID_APPLICATION.setStyleSheet(QString("QToolTip { color: #FFFFFF; background-color: %1; "
                                                  "border: 1px solid %2; }")
                                          .arg(openfluid::ui::config::TOOLTIP_BGCOLOR,
                                               openfluid::ui::config::TOOLTIP_BORDERCOLOR));

      // Application launching
      BuilderApp App(&Splash);

      App.initialize();
      App.run();

      Splash.finish(App.mainWindow());

      ExitCode = CLOSE_OPENFLUID_APPLICATION_WITH_GUI;

      OPENFLUID_APPLICATION.flush();

    }
    while (ExitCode == openfluid::ui::config::EXIT_CODE_FOR_RESTART);

    return ExitCode;

  }
  catch (std::bad_alloc & E)
  {
    std::cerr << "bad_alloc ERROR: " << E.what()
             << ". Possibly not enough memory available" << std::endl;
  }
  catch (std::bad_exception & E)
  {
    std::cerr << "bad_exception ERROR: " << E.what() << std::endl;
  }
  catch (std::bad_cast & E)
  {
    std::cerr << "bad_cast ERROR: " << E.what() << std::endl;
  }
  catch (std::exception & E)
  {
    std::cerr << "std ERROR: " << E.what() << std::endl;
  }
  catch (...)
  {
    std::cerr << "ERROR: " << "Unknown Error" << std::endl;
  }
}