示例#1
0
void RecentFiles::prependFile(const QString &fileName) {
  QSettings settings;

  const QStringList oldRecentFiles = readRecentFiles(settings);
  QStringList recentFiles = oldRecentFiles;
  recentFiles.removeAll(fileName);
  recentFiles.prepend(fileName);
  if (oldRecentFiles != recentFiles) writeRecentFiles(recentFiles, settings);

  this->menuRecent->setEnabled(!recentFiles.isEmpty());
}
示例#2
0
void MainWindow::prependToRecentFiles(const QString &fileName)
{
    QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());

    const QStringList oldRecentFiles = readRecentFiles(settings);
    QStringList recentFiles = oldRecentFiles;
    recentFiles.removeAll(fileName);
    recentFiles.prepend(fileName);
    if (oldRecentFiles != recentFiles)
        writeRecentFiles(recentFiles, settings);

    setRecentFilesVisible(!recentFiles.isEmpty());
}
示例#3
0
void MainWindow::updateRecentFileActions()
{
    QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());

    const QStringList recentFiles = readRecentFiles(settings);
    const int count = qMin(int(MaxRecentFiles), recentFiles.size());
    int i = 0;
    for ( ; i < count; ++i) {
        const QString fileName = MainWindow::strippedName(recentFiles.at(i));
        recentFileActs[i]->setText(tr("&%1 %2").arg(i + 1).arg(fileName));
        recentFileActs[i]->setData(recentFiles.at(i));
        recentFileActs[i]->setVisible(true);
    }
    for ( ; i < MaxRecentFiles; ++i)
        recentFileActs[i]->setVisible(false);
}
示例#4
0
void RecentFiles::updateActions() {
  QSettings settings;

  const QStringList recentFiles = readRecentFiles(settings);
  const int count = qMin(int(MaxRecentFiles), recentFiles.size());
  int i = 0;
  for (; i < count; ++i) {
    const QString fileName = QFileInfo(recentFiles.at(i)).fileName();
    QString numberString = QString::number(i + 1);
    numberString = numberString.insert(numberString.length() - 1, '&');
    QString text = tr("%1 %2").arg(numberString).arg(fileName);
    recentFileActs[i]->setText(text);
    recentFileActs[i]->setData(recentFiles.at(i));
    recentFileActs[i]->setVisible(true);
  }
  for (; i < MaxRecentFiles; ++i) recentFileActs[i]->setVisible(false);
}
示例#5
0
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QDir::setCurrent(a.applicationDirPath());

    // See if we are loading something from the commandline.
    QString fileArg("");
    QString suffix("");
    QString argument = a.arguments().last();
    QFileInfo info(a.arguments().last());
    if(info.exists() && info.isFile())
    {
        if(info.suffix() == "ogscene")
        {
            // Yes we've got an ogscene file to load.
            fileArg = info.absoluteFilePath();
            suffix = info.suffix();
        }
        else if(info.baseName() != "qtOgitor" && info.baseName() != "qtOgitor_d"  )
        {
            // We are trying to load something we can't load
            // Exit the application.
            QMessageBox msg(QMessageBox::Critical, "Ogitor Error", "We can only load Ogitor Scenes.\nExiting..");
            msg.exec();
            return 0;
        }
    }

    a.setOrganizationName("Ogitor");
    a.setApplicationName("qtOgitor");

#if(OGRE_PLATFORM == OGRE_PLATFORM_APPLE)
    QFile file(":/stylesheets/osx.qss");
#else
    QFile file(":/stylesheets/obsidian.qss");
#endif
    file.open(QFile::ReadOnly);
    QString styleSheet = QLatin1String(file.readAll());
    a.setStyleSheet(styleSheet);

    QSettings settings;
    QString languageFile = settings.value("preferences/customLanguage").toString();

    QTranslator qtTranslator;
    QTranslator ogitorTranslator;

    if(languageFile != "ogitor_en.qm")
    {
        QString lang = "../languages/qt_" + languageFile;
        lang.remove("ogitor_");

        QString lang2 = "../languages/" + languageFile;

        if(QFile::exists(lang) && QFile::exists(lang2))
        {
            if(qtTranslator.load(lang))
                a.installTranslator(&qtTranslator);

            if(ogitorTranslator.load(lang2))
                a.installTranslator(&ogitorTranslator);
        }
        else
        {    
            // If the system-wide Qt translation file is present, load it.
            if(qtTranslator.load("qt_" + QLocale::system().name(),
                QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
            {
                a.installTranslator(&qtTranslator);
            }
            // Otherwise: load our own Qt translation file.
            else if(qtTranslator.load("../languages/qt_" + QLocale::system().name()))
            {
                a.installTranslator(&qtTranslator);
            }

            // Install qtOgitor translator
            if(ogitorTranslator.load("../languages/ogitor_" + QLocale::system().name()))
            {
                a.installTranslator(&ogitorTranslator);
            }
        }
    }

    bool skipSplash = settings.value("preferences/skipSplash", false).toBool();

    QSplashScreen *splash;
    if(!skipSplash)
    {
        QPixmap pixmap(":/images/OgitorLogo.png");
        splash = new QSplashScreen(pixmap);
        splash->show();
    }

#ifdef _DEBUG
    setupOgre(resourcePath() + Ogre::String("plugins_debug.cfg"), Ogre::String("ogre.cfg"), Ogre::String("ogitor.log"));
#else
    setupOgre(resourcePath() + Ogre::String("plugins.cfg"), Ogre::String("ogre.cfg"), Ogre::String("ogitor.log"));
#endif

    readRecentFiles(settings);

    mOgitorMainWindow = new MainWindow();
    mOgitorMainWindow->show();
    
    mOgitorMainWindow->setApplicationObject(&a);

    QString sceneToLoad = "";
    QString lastLoadedScene = settings.value("preferences/lastLoadedScene", "").toString();
    if((settings.value("preferences/loadLastLoadedScene", false).toBool()) && (fileArg.isEmpty()))
    {
        if(!lastLoadedScene.isEmpty())
        {
            sceneToLoad = lastLoadedScene;
        }
    }
    else if(!fileArg.isEmpty())
    {
        sceneToLoad = fileArg;
    }

    if(!sceneToLoad.isEmpty())
    {
        if(suffix == "material")
        {
        }
        else
        {
            Ogitors::OgitorsRoot::getSingletonPtr()->LoadScene(sceneToLoad.toStdString());
        }
    }

    mOgitorMainWindow->repaint();

    if(!skipSplash)
    {
        splash->finish(mOgitorMainWindow);
        delete splash;
    }

    int retval = a.exec();

    writeRecentFiles();

    delete mOgitorMainWindow;
    delete shortCuts;
    OGRE_DELETE mOgitorsRoot;
    OGRE_DELETE mSystem;
    OGRE_DELETE mOgreRoot;

    return retval;
}