Exemplo n.º 1
0
KSambaShareData::UserShareError KSambaSharePrivate::isPathValid(const QString &path) const
{
    QFileInfo pathInfo = path;

    if (!pathInfo.exists()) {
        return KSambaShareData::UserSharePathNotExists;
    }

    if (!pathInfo.isDir()) {
        return KSambaShareData::UserSharePathNotDirectory;
    }

    if (pathInfo.isRelative()) {
        if (pathInfo.makeAbsolute()) {
            return KSambaShareData::UserSharePathNotAbsolute;
        }
    }

    // TODO: check if the user is root
    if (KSambaSharePrivate::testparmParamValue(QStringLiteral("usershare owner only"))
            == QLatin1String("Yes")) {
        if (!pathInfo.permission(QFile::ReadUser | QFile::WriteUser)) {
            return KSambaShareData::UserSharePathNotAllowed;
        }
    }

    return KSambaShareData::UserSharePathOk;
}
Exemplo n.º 2
0
void MetaTranslator::makeFileNamesAbsolute(const QDir &oldPath)
{
    TMM newmm;
    for (TMM::iterator m = mm.begin(); m != mm.end(); ++m) {
        MetaTranslatorMessage msg = m.key();
        QString fileName = m.key().fileName();
        QFileInfo fi (fileName);
        if (fi.isRelative()) {
            fileName = oldPath.absoluteFilePath(fileName);
        }

        msg.setFileName(fileName);
        newmm.insert(msg, m.value());
    }
    mm = newmm;
}
Exemplo n.º 3
0
QString GeoDataObject::resolvePath( const QString &relativePath ) const
{
    QUrl const url( relativePath );
    QFileInfo const fileInfo( url.path() );
    if ( url.isRelative() && fileInfo.isRelative() ) {
        GeoDataDocument const * document = dynamic_cast<GeoDataDocument const*>( this );
        if ( document ) {
            QString const baseUri = document->baseUri();
            QFileInfo const documentRoot = baseUri.isEmpty() ? document->fileName() : baseUri;
            QFileInfo const absoluteImage( documentRoot.absolutePath() + '/' + url.path() );
            return absoluteImage.absoluteFilePath();
        } else if ( d->m_parent ) {
            return d->m_parent->resolvePath( relativePath );
        }
    }

    return relativePath;
}
Exemplo n.º 4
0
MainWindow::MainWindow( const QString& filename )
    : KMainWindow()
    , d( new MainWindowPrivate )
{
    d->msecElapsed = 0;
    d->frameCount = 0;

    if( !filename.isEmpty() )
    {
        QFileInfo fi = QFileInfo( filename );
        if( fi.isRelative() )
            d->fileName = fi.canonicalFilePath();
        else
            d->fileName = filename;
        QTimer::singleShot( 0, this, SLOT( openProject() ) );
    }
    else
    {
        QWidget* base = new QWidget( this );
        QVBoxLayout* layout = new QVBoxLayout();
        base->setLayout( layout );
        setCentralWidget( base );

        QLabel* header = new QLabel( i18n( "Please select a Project" ), base );
        header->setAlignment( Qt::AlignCenter );
        QFont font;
        font.setBold( true );
        header->setFont( font );
        layout->addWidget( header );

        d->listWidget = new QListWidget( base );
        layout->addWidget( d->listWidget );
        connect( d->listWidget, SIGNAL( activated( QModelIndex ) ), SLOT( activated( QModelIndex ) ) );

        KPushButton* button = new KPushButton( i18n( "Open other project..." ), base );
        layout->addWidget( button );
        connect( button, SIGNAL( clicked( bool ) ), SLOT( openClicked( bool ) ) );
        loadGamesList();
    }
    resize( 500, 500 );
}
Exemplo n.º 5
0
/*!
 * \brief OMEditApplication::OMEditApplication
 * \param argc
 * \param argv
 * \param threadData
 */
OMEditApplication::OMEditApplication(int &argc, char **argv, threadData_t* threadData)
  : QApplication(argc, argv)
{
  // set the stylesheet
  setStyleSheet("file:///:/Resources/css/stylesheet.qss");
#if !(QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
  QTextCodec::setCodecForTr(QTextCodec::codecForName(Helper::utf8.toLatin1().data()));
  QTextCodec::setCodecForCStrings(QTextCodec::codecForName(Helper::utf8.toLatin1().data()));
#endif
#ifndef WIN32
  QTextCodec::setCodecForLocale(QTextCodec::codecForName(Helper::utf8.toLatin1().data()));
#endif
  setAttribute(Qt::AA_DontShowIconsInMenus, false);
  // Localization
  //*a.severin/ add localization
  const char *omhome = getenv("OPENMODELICAHOME");
#ifdef WIN32
  if (!omhome) {
    QMessageBox::critical(0, QString(Helper::applicationName).append(" - ").append(Helper::error),
                          GUIMessages::getMessage(GUIMessages::OPENMODELICAHOME_NOT_FOUND), Helper::ok);
    quit();
    exit(1);
  }
#else /* unix */
  omhome = omhome ? omhome : CONFIG_DEFAULT_OPENMODELICAHOME;
#endif
  QSettings *pSettings = Utilities::getApplicationSettings();
  QLocale settingsLocale = QLocale(pSettings->value("language").toString());
  settingsLocale = settingsLocale.name() == "C" ? pSettings->value("language").toLocale() : settingsLocale;
  QString locale = settingsLocale.name().isEmpty() ? QLocale::system().name() : settingsLocale.name();
  /* Set the default locale of the application so that QSpinBox etc show values according to the locale.
   * Set OMEdit locale to C so that we get dot as decimal separator instead of comma.
   */
  QLocale::setDefault(QLocale::c());

  QString translationDirectory = omhome + QString("/share/omedit/nls");
  // install Qt's default translations
  QTranslator *pQtTranslator = new QTranslator(this);
#ifdef Q_OS_WIN
  pQtTranslator->load("qt_" + locale, translationDirectory);
#else
  pQtTranslator->load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif
  installTranslator(pQtTranslator);
  // install application translations
  QTranslator *pTranslator = new QTranslator(this);
  pTranslator->load("OMEdit_" + locale, translationDirectory);
  installTranslator(pTranslator);
  // Splash Screen
  QPixmap pixmap(":/Resources/icons/omedit_splashscreen.png");
  SplashScreen *pSplashScreen = SplashScreen::instance();
  pSplashScreen->setPixmap(pixmap);
  pSplashScreen->show();
  Helper::initHelperVariables();
  /* Force C-style doubles */
  setlocale(LC_NUMERIC, "C");
  // if user has requested to open the file by passing it in argument then,
  bool debug = false;
  QString fileName = "";
  QStringList fileNames;
  if (arguments().size() > 1) {
    for (int i = 1; i < arguments().size(); i++) {
      if (strncmp(arguments().at(i).toStdString().c_str(), "--Debug=",8) == 0) {
        QString debugArg = arguments().at(i);
        debugArg.remove("--Debug=");
        if (0 == strcmp("true", debugArg.toStdString().c_str())) {
          debug = true;
        } else {
          debug = false;
        }
      } else {
        fileName = arguments().at(i);
        if (!fileName.isEmpty()) {
          // if path is relative make it absolute
          QFileInfo file (fileName);
          QString absoluteFileName = fileName;
          if (file.isRelative()) {
            absoluteFileName = QString("%1/%2").arg(QDir::currentPath()).arg(fileName);
          }
          absoluteFileName = absoluteFileName.replace("\\", "/");
          if (QFile::exists(absoluteFileName)) {
            fileNames << absoluteFileName;
          } else {
            printf("Invalid command line argument: %s %s\n", fileName.toStdString().c_str(), absoluteFileName.toStdString().c_str());
          }
        }
      }
    }
  }
  // MainWindow Initialization
  MainWindow *pMainwindow = MainWindow::instance(debug);
  pMainwindow->setUpMainWindow(threadData);
  if (pMainwindow->getExitApplicationStatus()) {        // if there is some issue in running the application.
    quit();
    exit(1);
  }
  // open the files passed as command line arguments
  foreach (QString fileName, fileNames) {
    pMainwindow->getLibraryWidget()->openFile(fileName);
  }
MapfileParser * QGisImporter::importMapFile() {

  QFile f(qgsPath);

  // some first basic checks on the filepath
  if (!f.open(QIODevice::ReadOnly)) {
    return NULL;
  }

  QDomDocument doc("QGisImporterXmlDoc");
  if (!doc.setContent(&f)) {
    f.close();
    return NULL;
  }

  qDebug() << "QGIS project XML loaded, parsing ...";

  MapfileParser * mf = new MapfileParser();

  // gets the title
  QDomNode titleNode = doc.elementsByTagName("title").at(0);
  mf->setMapName(titleNode.toElement().text());


  // gets the extent
  float xmin, ymin, xmax, ymax;
  QDomNode extent = doc.elementsByTagName("extent").at(0);

  xmin = extent.firstChildElement("xmin").text().toFloat();
  xmax = extent.firstChildElement("xmax").text().toFloat();
  ymin = extent.firstChildElement("ymin").text().toFloat();
  ymax = extent.firstChildElement("ymax").text().toFloat();

  mf->setMapExtent(xmin, ymin, xmax, ymax);

  // units
  QDomNode mapcanvasNode = doc.elementsByTagName("mapcanvas").at(0);
  QString units = mapcanvasNode.firstChildElement("units").text();
  // TODO: check possible values for units QGis-side
  mf->setMapUnits(units == "degrees" ? "dd" : units);

  // TODO: setting default width / height ? (the information is not
  // available into QGis XML format)

  // gets the projection
  QDomNode destinationSrsNode = doc.elementsByTagName("destinationsrs").at(0);

  QString proj4Str = destinationSrsNode.firstChildElement("spatialrefsys").firstChildElement("proj4").text();
  mf->setMapProjection(proj4Str);

  // Layers
  QDomNodeList layersNodes = doc.elementsByTagName("maplayer");

  qDebug() << layersNodes.size() << " layers to parse";

  for (int i = 0 ; i < layersNodes.size(); ++i) {
    QString layerName = layersNodes.at(i).firstChildElement("layername").text();
    QString dataStr = layersNodes.at(i).firstChildElement("datasource").text();
    QString typeStr =  layersNodes.at(i).firstChildElement("provider").text();
    QString projStr =  layersNodes.at(i).firstChildElement("srs").firstChildElement("spatialrefsys").firstChildElement("proj4").text();
    qDebug() <<  layerName << dataStr << typeStr << projStr;
    /* data is a file - need to check if relative or absolute, if it exists ... */
    QFileInfo dataFinfo = QFileInfo(dataStr);
    if (dataFinfo.isRelative()) {
      dataStr = QFileInfo(qgsPath).dir().absolutePath() + "/" + dataStr;
    }
    // data is ogr, call the underlying library to determine the type
    int geomType = MS_LAYER_RASTER;
    if (typeStr == "ogr") {
      geomType = getGeometryType(dataStr);
    }

    mf->addLayer(layerName, dataStr, projStr, geomType);
  }



  f.close();

  return mf;
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
  /* Do not use the signal handler OR exception filter if user is building a debug version. Perhaps the user wants to use gdb. */
  MMC_INIT();

#ifdef QT_NO_DEBUG
#ifdef WIN32
  SetUnhandledExceptionFilter(exceptionFilter);
#else
  /* Abnormal termination (abort) */
  signal(SIGABRT, signalHandler);
  /* Segmentation violation */
  signal(SIGSEGV, signalHandler);
  /* Illegal instruction */
  signal(SIGILL, signalHandler);
  /* Floating point error */
  signal(SIGFPE, signalHandler);
#endif // #ifdef WIN32
#endif // #ifdef QT_NO_DEBUG
  // if user asks for --help
  for(int i = 1; i < argc; i++) {
    if (strcmp(argv[i], "--help") == 0) {
      printOMEditUsage();
      return 0;
    }
  }
  Q_INIT_RESOURCE(resource_omedit);
  QApplication a(argc, argv);
  // set the stylesheet
  a.setStyleSheet("file:///:/Resources/css/stylesheet.qss");
#if !(QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
  QTextCodec::setCodecForTr(QTextCodec::codecForName(Helper::utf8.toLatin1().data()));
  QTextCodec::setCodecForCStrings(QTextCodec::codecForName(Helper::utf8.toLatin1().data()));
#endif
#ifndef WIN32
  QTextCodec::setCodecForLocale(QTextCodec::codecForName(Helper::utf8.toLatin1().data()));
#endif
  a.setAttribute(Qt::AA_DontShowIconsInMenus, false);
  // Localization
  //*a.severin/ add localization
  const char *omhome = getenv("OPENMODELICAHOME");
#ifdef WIN32
  if (!omhome) {
    QMessageBox::critical(0, QString(Helper::applicationName).append(" - ").append(Helper::error),
                          GUIMessages::getMessage(GUIMessages::OPENMODELICAHOME_NOT_FOUND), Helper::ok);
    a.quit();
    exit(1);
  }
#else /* unix */
  omhome = omhome ? omhome : CONFIG_DEFAULT_OPENMODELICAHOME;
#endif
  QSettings *pSettings = OpenModelica::getApplicationSettings();
  QLocale settingsLocale = QLocale(pSettings->value("language").toString());
  settingsLocale = settingsLocale.name() == "C" ? pSettings->value("language").toLocale() : settingsLocale;
  QString locale = settingsLocale.name().isEmpty() ? QLocale::system().name() : settingsLocale.name();
  /* set the default locale of the application so that QSpinBox etc show values according to the locale. */
  QLocale::setDefault(settingsLocale);

  QString translationDirectory = omhome + QString("/share/omedit/nls");
  // install Qt's default translations
  QTranslator qtTranslator;
#ifdef Q_OS_WIN
  qtTranslator.load("qt_" + locale, translationDirectory);
#else
  qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif
  a.installTranslator(&qtTranslator);
  // install application translations
  QTranslator translator;
  translator.load("OMEdit_" + locale, translationDirectory);
  a.installTranslator(&translator);
  // Splash Screen
  QPixmap pixmap(":/Resources/icons/omedit_splashscreen.png");
  QSplashScreen splashScreen(pixmap);
  //splashScreen.setMessage();
  splashScreen.show();
  Helper::initHelperVariables();
  /* Force C-style doubles */
  setlocale(LC_NUMERIC, "C");
  // if user has requested to open the file by passing it in argument then,
  bool OMCLogger = false;
  bool debug = false;
  QString fileName = "";
  QStringList fileNames;
  if (a.arguments().size() > 1) {
    for (int i = 1; i < a.arguments().size(); i++) {
      if (strncmp(a.arguments().at(i).toStdString().c_str(), "--OMCLogger=",12) == 0) {
        QString omcLoggerArg = a.arguments().at(i);
        omcLoggerArg.remove("--OMCLogger=");
        if (0 == strcmp("true", omcLoggerArg.toStdString().c_str())) {
          OMCLogger = true;
        } else {
          OMCLogger = false;
        }
      } else if (strncmp(a.arguments().at(i).toStdString().c_str(), "--Debug=",8) == 0) {
        QString debugArg = a.arguments().at(i);
        debugArg.remove("--Debug=");
        if (0 == strcmp("true", debugArg.toStdString().c_str())) {
          debug = true;
        } else {
          debug = false;
        }
      } else {
        fileName = a.arguments().at(i);
        if (!fileName.isEmpty()) {
          // if path is relative make it absolute
          QFileInfo file (fileName);
          if (file.isRelative()) {
            fileName.prepend(QString(QDir::currentPath()).append("/"));
          }
          fileName = fileName.replace("\\", "/");
          fileNames << fileName;
        }
      }
    }
  }
  // MainWindow Initialization
  MainWindow mainwindow(&splashScreen, debug);
  if (mainwindow.getExitApplicationStatus()) {        // if there is some issue in running the application.
    a.quit();
    exit(1);
  }
  // open the files passed as command line arguments
  foreach (QString fileName, fileNames) {
    mainwindow.getLibraryWidget()->openFile(fileName);
  }
Exemplo n.º 8
0
void parseCmdLine (int argc,
                   char **argv,
                   bool &isDebug,
                   QString &errorReportFile,
                   QString &fileCmdScriptFile,
                   bool &isRegressionTest,
                   bool &isGnuplot,
                   QStringList &loadStartupFiles)
{
    const int COLUMN_WIDTH = 20;
    bool showUsage = false;

    // State
    bool nextIsErrorReportFile = false;
    bool nextIsFileCmdScript = false;

    // Defaults
    isDebug = false;
    errorReportFile = "";
    fileCmdScriptFile = "";
    isRegressionTest = false;
    isGnuplot = false;

    for (int i = 1; i < argc; i++) {

        if (nextIsErrorReportFile) {
            errorReportFile = argv [i];
            showUsage |= !checkFileExists (errorReportFile);
            nextIsErrorReportFile = false;
        } else if (nextIsFileCmdScript) {
            fileCmdScriptFile = argv [i];
            showUsage |= !checkFileExists (fileCmdScriptFile);
            nextIsFileCmdScript = false;
        } else if (strcmp (argv [i], DASH_DEBUG.toLatin1().data()) == 0) {
            isDebug = true;
        } else if (strcmp (argv [i], DASH_ERROR_REPORT.toLatin1().data()) == 0) {
            nextIsErrorReportFile = true;
        } else if (strcmp (argv [i], DASH_FILE_CMD_SCRIPT.toLatin1().data()) == 0) {
            nextIsFileCmdScript = true;
        } else if (strcmp (argv [i], DASH_GNUPLOT.toLatin1().data()) == 0) {
            isGnuplot = true;
        } else if (strcmp (argv [i], DASH_HELP.toLatin1().data()) == 0) {
            showUsage = true; // User requested help
        } else if (strcmp (argv [i], DASH_REGRESSION.toLatin1().data()) == 0) {
            isRegressionTest = true;
        } else if (strncmp (argv [i], DASH.toLatin1().data(), 1) == 0) {
            showUsage = true; // User entered an unrecognized token
        } else {
            // MainWindow will change current directory (which is often some obscure application directory),
            // so relative paths must be changed in advance to absolute so the files can still be found
            QString fileName = argv [i];
            QFileInfo fInfo (fileName);
            if (fInfo.isRelative()) {
                fileName = fInfo.absoluteFilePath();
            }
            loadStartupFiles << fileName; // Save file name
        }
    }

    if (showUsage || nextIsErrorReportFile) {

        cerr << "Usage: engauge "
             << "[" << DASH_DEBUG.toLatin1().data() << "] "
             << "[" << DASH_ERROR_REPORT.toLatin1().data() << " <file>] "
             << "[" << DASH_FILE_CMD_SCRIPT.toLatin1().data() << " <file> "
             << "[" << DASH_GNUPLOT.toLatin1().data() << "] "
             << "[" << DASH_HELP.toLatin1().data() << "] "
             << "[" << DASH_REGRESSION.toLatin1().data() << "] "
             << "[<load_file1>] [<load_file2>] ..." << endl
             << "  " << DASH_DEBUG.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data()
             << QObject::tr ("Enables extra debug information. Used for debugging").toLatin1().data() << endl
             << "  " << DASH_ERROR_REPORT.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data()
             << QObject::tr ("Specifies an error report file as input. Used for debugging and testing").toLatin1().data() << endl
             << "  " << DASH_FILE_CMD_SCRIPT.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data()
             << QObject::tr ("Specifies a file command script file as input. Used for debugging and testing").toLatin1().data() << endl
             << "  " << DASH_GNUPLOT.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data()
             << QObject::tr ("Output diagnostic gnuplot input files. Used for debugging").toLatin1().data() << endl
             << "  " << DASH_HELP.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data()
             << QObject::tr ("Show this help information").toLatin1().data() << endl
             << "  " << DASH_REGRESSION.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data()
             << QObject::tr ("Executes the error report file or file command script. Used for regression testing").toLatin1().data() << endl
             << "  " << QString ("<load file> ").leftJustified(COLUMN_WIDTH, ' ').toLatin1().data()
             << QObject::tr ("File(s) to be imported or opened at startup").toLatin1().data() << endl;

        exit (0);
    }
}
Exemplo n.º 9
0
void
pfmPage::slotPFMFileEdit (const QString &string)
{
    pfm_def->name = string;


    if (!pfm_def->name.endsWith (".pfm")) pfm_def->name += ".pfm";


    mBinSize->setEnabled (TRUE);
    gBinSize->setEnabled (TRUE);
    minDepth->setEnabled (TRUE);
    maxDepth->setEnabled (TRUE);
    precision->setEnabled (TRUE);
    area_browse->setEnabled (TRUE);
    area_map->setEnabled (TRUE);
    area_pfm->setEnabled (TRUE);
    area_nsew->setEnabled (TRUE);


    //  Watch out for directory names that might be typed in.

    if (QFileInfo (string).isDir ()) return;


    FILE *fp;
    NV_INT32 hnd;
    PFM_OPEN_ARGS open_args;


    strcpy (open_args.list_path, pfm_def->name.toAscii ());


    //  Try to open the file.  If it exists we will not allow the user to change the bin size,
    //  depth precision, etc.

    pfm_def->existing = NVFalse;
    if ((fp = fopen (open_args.list_path, "r")) != NULL)
    {
        fclose (fp);

        open_args.checkpoint = 0;

        if ((hnd = open_existing_pfm_file (&open_args)) >= 0)
        {
            NV_CHAR file[512];
            get_target_file (hnd, open_args.list_path, file);
            feature_edit->setText (QString (file));
            get_mosaic_file (hnd, open_args.list_path, file);
            mosaic_edit->setText (QString (file));

            close_pfm_file (hnd);


            area_edit->setText (tr ("Defined in PFM structure"));


            mBinSize->setEnabled (FALSE);
            gBinSize->setEnabled (FALSE);
            minDepth->setEnabled (FALSE);
            maxDepth->setEnabled (FALSE);
            precision->setEnabled (FALSE);
            area_browse->setEnabled (FALSE);
            area_map->setEnabled (FALSE);
            area_pfm->setEnabled (FALSE);
            area_nsew->setEnabled (FALSE);

            pfm_def->existing = NVTrue;
        }
        else
        {
            QMessageBox::warning (this, tr ("Open PFM Structure"),
                                  tr ("The file ") + QDir::toNativeSeparators (QString (open_args.list_path)) +
                                  tr (" is not a PFM structure or there was an error reading the file.") +
                                  tr ("  The error message returned was:\n\n") +
                                  QString (pfm_error_str (pfm_error)));

            if (pfm_error == CHECKPOINT_FILE_EXISTS_ERROR)
            {
                fprintf (stderr, "\n\n%s\n", pfm_error_str (pfm_error));
                exit (-1);
            }
            return;
        }
    }
    else
    {
        if (area_edit->text () == tr ("Defined in PFM structure")) area_edit->clear ();

        feature_edit->setText ("NONE");
        mosaic_edit->setText ("NONE");

        QFileInfo fi = QFileInfo (pfm_def->name);
        if (fi.isRelative ())
        {
            //  Get the absolute path name

            QDir dir;

            pfm_def->name.prepend ("/");
            pfm_def->name.prepend (dir.canonicalPath());
        }
    }

    if (!pfm_file_edit->text ().isEmpty () && !area_edit->text ().isEmpty ())
    {
        setButtonText (QWizard::NextButton, tr ("Next"));
    }
    else
    {
        if (l_page_num > 1) setButtonText (QWizard::NextButton, tr ("Finish"));
    }
}
Exemplo n.º 10
0
int main(int argc, char *argv[])
{
  Q_INIT_RESOURCE(resource_omedit);
  // read the second argument if specified by user.
  QString fileName = QString();
  // adding style sheet
  argc++;
  argv[(argc - 1)] = "-stylesheet=:/Resources/css/stylesheet.qss";

  QApplication a(argc, argv);
  QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
  QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
  a.setAttribute(Qt::AA_DontShowIconsInMenus, false);
  // Localization
  //*a.severin/ add localization
  const char *omhome = getenv("OPENMODELICAHOME");
#ifdef WIN32
  if (!omhome) {
    QMessageBox::critical(0, QString(Helper::applicationName).append(" - ").append(Helper::error),
                          GUIMessages::getMessage(GUIMessages::OPENMODELICAHOME_NOT_FOUND), Helper::ok);
    a.quit();
    exit(1);
  }
#else /* unix */
  omhome = omhome ? omhome : CONFIG_DEFAULT_OPENMODELICAHOME;
#endif
  QSettings settings(QSettings::IniFormat, QSettings::UserScope, "openmodelica", "omedit");
  QString language = settings.value("language").toString();
  QString translationDirectory = omhome + QString("/share/omedit/nls");
  QString locale = language.isEmpty() ? QLocale::system().name() : language;
  // install Qt's default translations
  QTranslator qtTranslator;
#ifdef Q_OS_WIN
  qtTranslator.load("qt_" + locale, translationDirectory);
#else
  qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif
  a.installTranslator(&qtTranslator);
  // install application translations
  QTranslator translator;
  translator.load("OMEdit_" + locale, translationDirectory);
  a.installTranslator(&translator);
  // Splash Screen
  QPixmap pixmap(":/Resources/icons/omeditor_splash.png");
  SplashScreen splashScreen(pixmap);
  splashScreen.setMessage();
  splashScreen.show();
  Helper::initHelperVariables();
  // MainWindow Initialization
  MainWindow mainwindow(&splashScreen);
  if (mainwindow.mExitApplication) {        // if there is some issue in running the application.
    a.quit();
    exit(1);
  }
  bool OMCLogger = false;
  // if user has requested to open the file by passing it in argument then,
  if (a.arguments().size() > 1)
  {
    for (int i = 1; i < a.arguments().size(); i++)
    {
      if (strncmp(a.arguments().at(i).toStdString().c_str(), "--OMCLogger=",12) == 0) {
        QString omcLoggerArg = a.arguments().at(i);
        omcLoggerArg.remove("--OMCLogger=");
        if (0 == strcmp("true", omcLoggerArg.toStdString().c_str()))
          OMCLogger = true;
        else if (0 == strcmp("false", omcLoggerArg.toStdString().c_str()))
          OMCLogger = false;
      }
      fileName = a.arguments().at(i);
      if (!fileName.isEmpty())
      {
        // if path is relative make it absolute
        QFileInfo file (fileName);
        if (file.isRelative())
        {
          fileName.prepend(QString(QDir::currentPath()).append("/"));
        }
        mainwindow.mpProjectTabs->openFile(fileName);
      }
    }
  }
  // hide OMCLogger send custom expression feature if OMCLogger is false
  mainwindow.mpOMCProxy->enableCustomExpression(OMCLogger);
  // finally show the main window
  mainwindow.show();
  // hide the splash screen
  splashScreen.finish(&mainwindow);
  return a.exec();
}