Ejemplo n.º 1
0
QString QgsServerProjectParser::projectTitle() const
{
  if ( !mXMLDoc )
  {
    return QString();
  }

  QDomElement qgisElem = mXMLDoc->documentElement();
  if ( qgisElem.isNull() )
  {
    return QString();
  }

  QDomElement titleElem = qgisElem.firstChildElement( "title" );
  if ( !titleElem.isNull() )
  {
    QString title = titleElem.text();
    if ( !title.isEmpty() )
    {
      return title;
    }
  }

  //no title element or not project title set. Use project filename without extension
  QFileInfo projectFileInfo( mProjectPath );
  return projectFileInfo.baseName();
}
Ejemplo n.º 2
0
  bool ProjectManager::loadProject(QString projectFilePath, DataProxy& configs)
  {
    if(!readJson(projectFilePath.toStdString(), configs))
    {
      return false;
    }

    QFileInfo projectFileInfo(projectFilePath);
    mCurrentProjectFolder = projectFileInfo.absolutePath();
    QDir::setCurrent(mCurrentProjectFolder);
    return true;
  }
Ejemplo n.º 3
0
  bool EditorApplication::loadProject(const QString& projectFilePath)
  {
    DataProxy projectConfig;
    if(!mProjectManager->loadProject(projectFilePath, projectConfig))
    {
      return false;
    }

    QFileInfo projectFileInfo(projectFilePath);
    QString gameConfig(projectConfig.get("configPath", "gameConfig.json").c_str());
    QString resourcePath(projectFileInfo.absolutePath().append(QDir::separator()).append("resources"));
    mConfigOverride.put("render", mConfig.get<DataProxy>("render", DataProxy()));

    initEngine("renderWindow", gameConfig, resourcePath);
    return true;
  }
Ejemplo n.º 4
0
QString
Project::checkBackupFile(const QString& projectFile)
{
    QString backupFilename = projectFile + Project::backupSuffix;
    QFile   autoBackup( backupFilename );
    if ( autoBackup.exists() == true )
    {
        QFileInfo       projectFileInfo( projectFile );
        QFileInfo       autobackupFileInfo( autoBackup );

        if ( autobackupFileInfo.lastModified() > projectFileInfo.lastModified() )
        {
            if ( m_projectManagerUi != NULL && m_projectManagerUi->shouldLoadBackupFile() )
                return backupFilename;
        }
        else
        {
            if ( m_projectManagerUi != NULL && m_projectManagerUi->shouldDeleteOutdatedBackupFile() )
                autoBackup.remove();
        }
    }
    return projectFile;
}
Ejemplo n.º 5
0
int main(int argc, char **argv)
{
    KAboutData about("lokalize", 0, ki18nc("@title", "Lokalize"), version, ki18n(description),
                     KAboutData::License_GPL, ki18nc("@info:credit", "(c) 2007-2011 Nick Shaforostoff\n(c) 1999-2006 The KBabel developers") /*, KLocalizedString(), 0, "*****@*****.**"*/);
    about.addAuthor( ki18n("Nick Shaforostoff"), KLocalizedString(), "*****@*****.**" );
    about.addCredit (ki18n("Google Inc."), ki18n("sponsored development as part of Google Summer Of Code program"), QByteArray(), "http://google.com");
    about.addCredit (ki18n("Translate-toolkit"), ki18n("provided excellent cross-format converting scripts"), QByteArray(), "http://translate.sourceforge.net");
    about.addCredit (ki18n("Viesturs Zarins"), ki18n("project tree merging translation+templates"), "*****@*****.**", QByteArray());
    about.addCredit (ki18n("Stephan Johach"), ki18n("bug fixing patches"), "*****@*****.**");
    about.addCredit (ki18n("Chusslove Illich"), ki18n("bug fixing patches"), "*****@*****.**");
    about.addCredit (ki18n("Jure Repinc"), ki18n("testing and bug fixing"), "*****@*****.**");
    about.addCredit (ki18n("Stefan Asserhall"), ki18n("patches"), "*****@*****.**");
    about.addCredit (ki18n("Papp Laszlo"), ki18n("bug fixing patches"), "*****@*****.**");

    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    //options.add("merge-source <URL>", ki18n( "Source for the merge mode" ));
    options.add("noprojectscan", ki18n( "Do not scan files of the project."));
    options.add("project <filename>", ki18n( "Load specified project."));
    options.add("+[URL]", ki18n( "Document to open" ));
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;

    //qDebug() is important as it aviods compile 'optimization'.
    qDebug()<<qRegisterMetaType<DocPosition>();
    qDebug()<<qRegisterMetaType<InlineTag>();
    qDebug()<<qRegisterMetaType<CatalogString>();
    qRegisterMetaTypeStreamOperators<InlineTag>("InlineTag");
    qRegisterMetaTypeStreamOperators<CatalogString>("CatalogString");
    qAddPostRoutine(&cleanupSpellers);

    // see if we are starting with session management
    if (app.isSessionRestored())
        kRestoreMainWindows<LokalizeMainWindow>();
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

        if (!args->getOption("project").isEmpty())
        {
            // load needs an absolute path
            // FIXME: I do not know how to handle urls here
            // bug 245546 regarding symlinks
            QFileInfo projectFileInfo(args->getOption("project").toUtf8());
            QString projectFilePath=projectFileInfo.canonicalFilePath();
            if (projectFilePath.isEmpty())
                projectFilePath=projectFileInfo.absoluteFilePath();
            Project::instance()->load( projectFilePath );
        }
        LokalizeMainWindow* lmw=new LokalizeMainWindow;
        SettingsController::instance()->setMainWindowPtr(lmw);
        kWarning()<<"showing LokalizeMainWindow";
        lmw->show();
        kWarning()<<"LokalizeMainWindow shown";
        int j=args->count();
        while (--j>=0)
            lmw->fileOpen(args->url(j));

        Project::instance()->model()->setCompleteScan(args->isSet("projectscan"));
        args->clear();
    }

    int code=app.exec();

    ThreadWeaver::Weaver::instance()->dequeue();
    Project::instance()->model()->weaver()->dequeue();

    if (SettingsController::instance()->dirty) //for config changes done w/o config dialog
        Settings::self()->writeConfig();

    if (Project::instance()->isLoaded())
        Project::instance()->save();

    qWarning()<<"QCoreApplication::processEvents()...";
    QCoreApplication::processEvents();
    QCoreApplication::sendPostedEvents(0,0);

    qWarning()<<"Finishing Project jobs...";
    //Project::instance()->model()->weaver()->finish();
    // HACK due to deadlock with libstreamanalyzer.so.0 -> libxml2.so.2 -> etree.so -> libpython2.5.so.1.0 -> PyThread_acquire_lock
    while (!Project::instance()->model()->weaver()->isIdle())
    {
        QCoreApplication::processEvents();
        QCoreApplication::sendPostedEvents(0,0);
    }

    qWarning()<<"Finishing TM jobs...";
    ThreadWeaver::Weaver::instance()->finish();

    return code;
}