当前位置: 首页>>代码示例>>C++>>正文


C++ QTranslator类代码示例

本文整理汇总了C++中QTranslator的典型用法代码示例。如果您正苦于以下问题:C++ QTranslator类的具体用法?C++ QTranslator怎么用?C++ QTranslator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTranslator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    QTextStream QErr(stderr);

     //! This is need for libq4wine-core.so import;
    typedef void *CoreLibPrototype (bool);
    CoreLibPrototype *CoreLibClassPointer;
    std::auto_ptr<corelib> CoreLib;
    QLibrary libq4wine;

    // Loading libq4wine-core.so
#ifdef RELEASE
    libq4wine.setFileName(_CORELIB_PATH_);
#else
    libq4wine.setFileName(QString("%1/q4wine-lib/libq4wine-core").arg(APP_BUILD));
#endif

    if (!libq4wine.load()){
        libq4wine.load();
    }

    // Getting corelib calss pointer
    CoreLibClassPointer = (CoreLibPrototype *) libq4wine.resolve("createCoreLib");
    CoreLib.reset((corelib *)CoreLibClassPointer(false));

    if (!CoreLib.get()){
        QErr<<"[EE] Can't load shared library."<<endl;
        return -1;
    }

    DataBase db;
    if (!db.checkDb()){
        QErr<<"[EE] Can't init database engine."<<endl;
        return -1;
    }

    QTranslator qtt;

#ifdef RELEASE
    #ifdef _OS_DARWIN_
        QString i18nPath = QString("%1/%2.app/Contents/i18n").arg(QDir::currentPath()).arg(APP_SHORT_NAME);
    #else
        QString i18nPath = QString("%1/share/%2/i18n").arg(APP_PREF).arg(APP_SHORT_NAME);
    #endif
#else
    QString i18nPath = QString("%1/i18n").arg(APP_BUILD);
#endif

    qtt.load(CoreLib->getTranslationLang(), i18nPath);
    app.installTranslator(&qtt);

    if (!CoreLib->isConfigured()){
       QErr<<"[EE] App not configured! Re run wizard, or delete q4wine broken config files."<<endl;
       return -1;
    }

    QTextStream Qcout(stdout);
    WineObject wineObject;

    if (argc==1){
        app.arguments().append("-h");
        argc++;
    }

    for (int i=1; i<argc; i++){
        qDebug()<<app.arguments().at(i);
        if ((app.arguments().at(1)=="--version") or (app.arguments().at(1)=="-v")){
            Qcout<<QString("%1-helper %2").arg(APP_SHORT_NAME).arg(APP_VERS)<<endl;
            Qcout<<QString("(Copyright (C) 2008-2009, brezblock core team.")<<endl;
            Qcout<<QString("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.")<<endl;
            Qcout<<QObject::tr("This is free software: you are free to change and redistribute it.")<<endl;
            Qcout<<QObject::tr("There is NO WARRANTY, to the extent permitted by law.")<<endl;
            CoreLib->getBuildFlags();
            Qcout<<QObject::tr("Author: %1.").arg("Malakhov Alexey aka John Brezerk")<<endl;
            return 0;
        } else if (app.arguments().at(i)=="--prefix"){
            i++;
            if (i<argc)
                wineObject.setPrefix(app.arguments().at(i));
        }  else if (app.arguments().at(i)=="--wine-debug"){
            i++;
            if (i<argc)
                wineObject.setProgramDebug(app.arguments().at(i));
        }  else if (app.arguments().at(i)=="--console"){
            i++;
            if (i<argc)
                wineObject.setUseConsole(app.arguments().at(i).toInt());
        }  else if (app.arguments().at(i)=="--display"){
            i++;
            if (i<argc)
                wineObject.setProgramDisplay(app.arguments().at(i));
        }  else if (app.arguments().at(i)=="--nice"){
            i++;
            if (i<argc)
                wineObject.setProgramNice(app.arguments().at(i).toInt());
        }  else if (app.arguments().at(i)=="--desktop"){
            i++;
            if (i<argc)
                wineObject.setProgramDesktop(app.arguments().at(i));
//.........这里部分代码省略.........
开发者ID:ercolinux,项目名称:q4wine,代码行数:101,代码来源:q4wine-helper.cpp

示例2: processQdocconfFile

/*!
  Processes the qdoc config file \a fileName. This is the
  controller for all of qdoc.
 */
static void processQdocconfFile(const QString &fileName)
{
    QList<QTranslator *> translators;

    /*
      The Config instance represents the configuration data for qdoc.
      All the other classes are initialized with the config. Here we
      initialize the configuration with some default values.
     */
    Config config(tr("qdoc"));
    int i = 0;
    while (defaults[i].key) {
	config.setStringList(defaults[i].key,
                             QStringList() << defaults[i].value);
	++i;
    }
    config.setStringList(CONFIG_SLOW, QStringList(slow ? "true" : "false"));
    config.setStringList(CONFIG_SHOWINTERNAL,
                         QStringList(showInternal ? "true" : "false"));
    config.setStringList(CONFIG_OBSOLETELINKS,
                         QStringList(obsoleteLinks ? "true" : "false"));

    /*
      With the default configuration values in place, load
      the qdoc configuration file. Note that the configuration
      file may include other configuration files.

      The Location class keeps track of the current location
      in the file being processed, mainly for error reporting
      purposes.
     */
    Location::initialize(config);
    config.load(fileName);

    /*
      Add the defines to the configuration variables.
     */
    QStringList defs = defines + config.getStringList(CONFIG_DEFINES);
    config.setStringList(CONFIG_DEFINES,defs);
    Location::terminate();

    QString prevCurrentDir = QDir::currentPath();
    QString dir = QFileInfo(fileName).path();
    if (!dir.isEmpty())
	QDir::setCurrent(dir);

    /*
      Initialize all the classes and data structures with the
      qdoc configuration.
     */
    Location::initialize(config);
    Tokenizer::initialize(config);
    Doc::initialize(config);
    CppToQsConverter::initialize(config);
    CodeMarker::initialize(config);
    CodeParser::initialize(config);
    Generator::initialize(config);

    /*
      Load the language translators, if the configuration specifies any.
     */
    QStringList fileNames = config.getStringList(CONFIG_TRANSLATORS);
    QStringList::Iterator fn = fileNames.begin();
    while (fn != fileNames.end()) {
	QTranslator *translator = new QTranslator(0);
	if (!translator->load(*fn))
	    config.lastLocation().error(tr("Cannot load translator '%1'")
					 .arg(*fn));
	QCoreApplication::instance()->installTranslator(translator);
	translators.append(translator);
	++fn;
    }

    //QSet<QString> outputLanguages = config.getStringSet(CONFIG_OUTPUTLANGUAGES);

    /*
      Get the source language (Cpp) from the configuration
      and the location in the configuration file where the
      source language was set.
     */
    QString lang = config.getString(CONFIG_LANGUAGE);
    Location langLocation = config.lastLocation();

    /*
      Initialize the tree where all the parsed sources will be stored.
      The tree gets built as the source files are parsed, and then the
      documentation output is generated by traversing the tree.
     */
    Tree *tree = new Tree;
    tree->setVersion(config.getString(CONFIG_VERSION));

    /*
      There must be a code parser for the source code language, e.g. C++.
      If there isn't one, give up.
     */
    CodeParser *codeParser = CodeParser::parserForLanguage(lang);
//.........这里部分代码省略.........
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:101,代码来源:main.cpp

示例3: main

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
#ifndef Q_OS_WIN32
    QTranslator translator;
    QTranslator qtTranslator;
    QString sysLocale = QLocale::system().name();
    QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
    if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)
        && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
        app.installTranslator(&translator);
        app.installTranslator(&qtTranslator);
    }
#endif // Q_OS_WIN32

    QStringList args = app.arguments();
    QList<File> inFiles;
    QString inFormat(QLatin1String("auto"));
    QString outFileName;
    QString outFormat(QLatin1String("auto"));
    QString targetLanguage;
    QString sourceLanguage;
    bool dropTranslations = false;
    bool noObsolete = false;
    bool noFinished = false;
    bool verbose = false;
    bool noUiLines = false;
    Translator::LocationsType locations = Translator::DefaultLocations;

    ConversionData cd;
    Translator tr;

    for (int i = 1; i < args.size(); ++i) {
        if (args[i].startsWith(QLatin1String("--")))
            args[i].remove(0, 1);
        if (args[i] == QLatin1String("-o")
         || args[i] == QLatin1String("-output-file")) {
            if (++i >= args.size())
                return usage(args);
            outFileName = args[i];
        } else if (args[i] == QLatin1String("-of")
                || args[i] == QLatin1String("-output-format")) {
            if (++i >= args.size())
                return usage(args);
            outFormat = args[i];
        } else if (args[i] == QLatin1String("-i")
                || args[i] == QLatin1String("-input-file")) {
            if (++i >= args.size())
                return usage(args);
            File file;
            file.name = args[i];
            file.format = inFormat;
            inFiles.append(file);
        } else if (args[i] == QLatin1String("-if")
                || args[i] == QLatin1String("-input-format")) {
            if (++i >= args.size())
                return usage(args);
            inFormat = args[i];
        } else if (args[i] == QLatin1String("-input-codec")) {
            if (++i >= args.size())
                return usage(args);
            cd.m_codecForSource = args[i].toLatin1();
        } else if (args[i] == QLatin1String("-output-codec")) {
            if (++i >= args.size())
                return usage(args);
            cd.m_outputCodec = args[i].toLatin1();
        } else if (args[i] == QLatin1String("-drop-tag")) {
            if (++i >= args.size())
                return usage(args);
            cd.m_dropTags.append(args[i]);
        } else if (args[i] == QLatin1String("-drop-translations")) {
            dropTranslations = true;
        } else if (args[i] == QLatin1String("-target-language")) {
            if (++i >= args.size())
                return usage(args);
            targetLanguage = args[i];
        } else if (args[i] == QLatin1String("-source-language")) {
            if (++i >= args.size())
                return usage(args);
            sourceLanguage = args[i];
        } else if (args[i].startsWith(QLatin1String("-h"))) {
            usage(args);
            return 0;
        } else if (args[i] == QLatin1String("-no-obsolete")) {
            noObsolete = true;
        } else if (args[i] == QLatin1String("-no-finished")) {
            noFinished = true;
        } else if (args[i] == QLatin1String("-sort-contexts")) {
            cd.m_sortContexts = true;
        } else if (args[i] == QLatin1String("-locations")) {
            if (++i >= args.size())
                return usage(args);
            if (args[i] == QLatin1String("none"))
                locations = Translator::NoLocations;
            else if (args[i] == QLatin1String("relative"))
                locations = Translator::RelativeLocations;
            else if (args[i] == QLatin1String("absolute"))
                locations = Translator::AbsoluteLocations;
            else
                return usage(args);
//.........这里部分代码省略.........
开发者ID:husninazer,项目名称:qt,代码行数:101,代码来源:main.cpp

示例4: main

int main(int argc, char *argv[])
{
#if QT_VERSION < 0x050000
    // The GraphicsSystem needs to be set before the instantiation of the
    // QApplication. Therefore we need to parse the current setting
    // in this unusual place :-/
    QSettings graphicsSettings("KDE", "Marble Virtual Globe"); // keep the parameters here
    QString const graphicsString = graphicsSettings.value("View/graphicsSystem", "raster").toString();
    QApplication::setGraphicsSystem( graphicsString );
#endif

    QApplication app(argc, argv);
    app.setApplicationName( "Marble Virtual Globe" );
    app.setOrganizationName( "KDE" );
    app.setOrganizationDomain( "kde.org" );
    // Widget translation

#ifdef Q_WS_MAEMO_5
    // Work around http://bugreports.qt-project.org/browse/QTBUG-1313
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QString lang( "C" );
    QStringList const locales = QStringList() << "LC_ALL" << "LC_MESSAGES" << "LANG" << "LANGUAGE";
    foreach( const QString &locale, locales ) {
        if ( env.contains( locale ) && !env.value( locale ).isEmpty() ) {
            lang = env.value( locale, "C" );
            break;
        }
    }

    lang = lang.section( '_', 0, 0 );
#else
    QString      lang = QLocale::system().name().section('_', 0, 0);
#endif
    QTranslator  translator;
    translator.load( "marble-" + lang, MarbleDirs::path(QString("lang") ) );
    app.installTranslator(&translator);

    // For non static builds on mac and win
    // we need to be sure we can find the qt image
    // plugins. In mac be sure to look in the
    // application bundle...

#ifdef Q_WS_WIN
    QApplication::addLibraryPath( QApplication::applicationDirPath()
                                  + QDir::separator() + "plugins" );
#endif
#ifdef Q_OS_MACX
    QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus);
    qDebug("Adding qt image plugins to plugin search path...");
    CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
    CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle);
    const char *mypPathPtr = CFStringGetCStringPtr(myMacPath,CFStringGetSystemEncoding());
    CFRelease(myBundleRef);
    CFRelease(myMacPath);
    QString myPath(mypPathPtr);
    // if we are not in a bundle assume that the app is built
    // as a non bundle app and that image plugins will be
    // in system Qt frameworks. If the app is a bundle
    // lets try to set the qt plugin search path...
    if (myPath.contains(".app"))
    {
        myPath += "/Contents/plugins";
        QApplication::addLibraryPath( myPath );
        qDebug( "Added %s to plugin search path", qPrintable( myPath ) );
    }
#endif

    QString marbleDataPath;
    int dataPathIndex=0;
    QString mapThemeId;
    QString coordinatesString;
    QString distanceString;
    const MarbleGlobal::Profiles profiles = MarbleGlobal::SmallScreen | MarbleGlobal::HighResolution;

    QStringList args = QApplication::arguments();

    if ( args.contains( "-h" ) || args.contains( "--help" ) ) {
        qWarning() << "Usage: marble [options] [files]";
        qWarning();
        qWarning() << "[files] can be zero, one or more .kml and/or .gpx files to load and show.";
        qWarning();
        qWarning() << "general options:";
        qWarning() << "  --marbledatapath=<path> .... Overwrite the compile-time path to map themes and other data";
        qWarning() << "  --latlon=<coordinates> ..... Show map at given lat lon coordinates";
        qWarning() << "  --distance=<value> ......... Set the distance of the observer to the globe (in km)";
        qWarning() << "  --map=<id> ................. Use map id (e.g. \"earth/openstreetmap/openstreetmap.dgml\")";
        qWarning();
        qWarning() << "debug options:";
        qWarning() << "  --debug-info ............... write (more) debugging information to the console";
        qWarning() << "  --fps ...................... Show the paint performance (paint rate) in the top left corner";
        qWarning() << "  --runtimeTrace.............. Show the time spent and other debug info of each layer";
        qWarning() << "  --tile-id................... Write the identifier of texture tiles on top of them";
        qWarning() << "  --timedemo ................. Measure the paint performance while moving the map and quit";

        return 0;
    }

    for ( int i = 1; i < args.count(); ++i ) {
        const QString arg = args.at(i);

//.........这里部分代码省略.........
开发者ID:utkuaydin,项目名称:marble,代码行数:101,代码来源:main.cpp

示例5: main


//.........这里部分代码省略.........

#if defined(Q_OS_MAC)
    // file to open at start
    auto fileToOpen = QString();
    // install event filter to open clicked files in Mac OS X
    OpenFileFilter openFileFilter;
    app.installEventFilter(&openFileFilter);
    app.processEvents();
    auto requestedFile = openFileFilter.fileRequested();
    if (requestedFile.endsWith(QStringLiteral(".eddypro")))
    {
        fileToOpen = requestedFile;
    }
#endif

    // custom ttf setup
    int fontId_1 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-Regular.ttf"));
    Q_ASSERT(fontId_1 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_1);
    int fontId_2 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-Italic.ttf"));
    Q_ASSERT(fontId_2 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_2);
    int fontId_3 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-Bold.ttf"));
    Q_ASSERT(fontId_3 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_3);
    int fontId_4 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-Semibold.ttf"));
    Q_ASSERT(fontId_4 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_4);
    int fontId_5 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-BoldItalic.ttf"));
    Q_ASSERT(fontId_5 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_5);

    // load translation file embedded in resources
    QTranslator appTranslator;
    bool ok = appTranslator.load(QStringLiteral(":/tra/en"));
    qDebug() << "loading translation:" << ok;
    app.installTranslator(&appTranslator);

    // working dir
    QDir dir = QDir::current();
    qDebug() << "current dir" << dir.absolutePath();

    QString currentWorkingDir = QDir::currentPath();
    QString installationDir = qApp->applicationDirPath();
    qDebug() << "currentWorkingDir" << currentWorkingDir;
    qDebug() << "installationDir" << installationDir;
    if (currentWorkingDir != installationDir)
    {
        QDir::setCurrent(installationDir);
    }
    qDebug() << "currentWorkingDir" << QDir::currentPath();
    qDebug() << "currentWorkingDir" << QCoreApplication::applicationDirPath();

    // styles
    qDebug() << "------------------------------------------------------------";
    qDebug() << "Default Style: " << app.style()->metaObject()->className();

    MyStyle myStyle(app.style()->objectName());
    app.setStyle(&myStyle);

#if defined(Q_OS_WIN)
    FileUtils::loadStyleSheetFile(QStringLiteral(":/css/winstyle"));
#elif defined(Q_OS_MAC)
    FileUtils::loadStyleSheetFile(QStringLiteral(":/css/macstyle"));
#elif defined(Q_OS_LINUX)
    FileUtils::loadStyleSheetFile(QStringLiteral(":/css/linstyle"));
开发者ID:LI-COR,项目名称:eddypro-gui,代码行数:67,代码来源:main.cpp

示例6: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    qDebug()<<"launch";
    QFile file("D:\\mifmaster.txt");
    //if (file.exists()){file.remove();}
    qInstallMsgHandler(myMessageHandler);
    S60AutoStart::SetAutoStart(ETrue);
    QTranslator myTranslator;
    myTranslator.load("mifmaster_" + QLocale::system().name());
    a.installTranslator(&myTranslator);

    const QString INSTALL_REBOOT_MULTIPLE=Application::tr("Install MIF-files? Device will reboot multiple times.");
    const QString OPEN4ALL_NOT_ACTIVE=Application::tr("Open4All patch is not activated (it is recomended apply it to autostart), MIF files can not be installed without patch. Continue?");
    const QString DELETE_MIFMASTER_CONF=Application::tr("You're deleting MIFMaster, remove mif replacement patch (device will reboot)?");
    const QString PATCH_DELETED=Application::tr("Patch deleted! Remove application one more time :)");
    const QString INSTALL_REBOOT_ONCE=Application::tr("Install MIF-files? Phone will reboot.");
    const QString NO_MIF_FOUND=Application::tr("No *.mif files found!");
    const QString INSTALL_PATCH=Application::tr("MIF-files replacement patch is not installed, install it (reboot required)?");
    const QString ALL_DONE=Application::tr("All done!");
    const QString PATCH_INSTALLED=Application::tr("Patch installed! Copy MIF-files to E drive root folder and run an app");


    bool wasAutostart= argc > 1;
    qDebug()<<"autostart"<<wasAutostart;
    if (wasAutostart)  User::After(5000000);
    if (wasAutostart&&Application::getAutoStartReason()==EUndefined) return 0;

    if ((!Application::checkRoot())){
        if (!Application::confNote((OPEN4ALL_NOT_ACTIVE))) return 0;
    }
    if (Application::isUninstalling()&&Application::isPatchInstalled()){
        if (Application::confNote((DELETE_MIFMASTER_CONF)))
        {
            Application::renameAknIcon(false);
            Application::setAutoStartReason(EUninstallingApp);
            Application::reset();
        }
    }
    qDebug()<<"main";
    if (wasAutostart&&Application::getAutoStartReason()==EUninstallingApp){

        Application::removePatchAndPreparedMIFs();
        Application::setAutoStartReason(EUndefined);
        Application::note((PATCH_DELETED));
        return 0;
    }
    if (Application::isPatchInstalled()&&(!Application::isUninstalling()))
    {
        if (!Application::isAvkonReplacementNeeded()&&(!wasAutostart)){
            if (Application::confNote((INSTALL_REBOOT_ONCE)))
            {
            int mifs=Application::copyMIFs();
            Application::switchCache();
            qDebug()<<mifs;
            if (mifs!=0) Application::reset();
            else if (mifs==0) Application::note(NO_MIF_FOUND);

            }
            return 0;
        }
        if (Application::isAknIconRenamed())
        {

           Application::copyMIFs();
           Application::renameAknIcon(true);
           Application::setAutoStartReason(EAllDone);
           Application::reset();
        }
        else
        {

            if (wasAutostart)
            {
                if (Application::getAutoStartReason()==EAllDone){ Application::note((ALL_DONE)); Application::setAutoStartReason(EUndefined); return 0;}
                if (Application::getAutoStartReason()==EPatchInstalled) { Application::note((PATCH_INSTALLED)); Application::setAutoStartReason(EUndefined); return 0;}
                else return 0;
            }
            if (Application::getMifFilesCountReadyToReplace()==0) {Application::note(NO_MIF_FOUND); return 0;}
            QString reqString=(Application::getS60Version()==EBelleRefresh||
                               Application::getS60Version()==EFeaturePack1)?INSTALL_REBOOT_ONCE:INSTALL_REBOOT_MULTIPLE;
            if (Application::confNote((reqString)))
            {
                if (Application::getS60Version()==EBelleRefresh||
                    Application::getS60Version()==EFeaturePack1){
                    // one reboot way for refresh/FP1 devices
                    Application::copyMIFs(); // and kill aknicon on copying
                    Application::setAutoStartReason(EAllDone);
                    Application::reset();
                }
                else{
                    Application::renameAknIcon(false);
                    Application::setAutoStartReason(EInstallingMifs);
                    Application::reset();
                }
            }
        }
    }
    else if (!Application::isUninstalling())
    {
//.........这里部分代码省略.........
开发者ID:kolayuk,项目名称:MIFMaster,代码行数:101,代码来源:main.cpp

示例7: main


//.........这里部分代码省略.........

            home.cd(localLibraryPath);

        } else {

            // YIKES !! The directory we should be using doesn't exist!
            home = QDir::home();
            if (home.exists(oldLibraryPath)) { // there is an old style path, lets fo there
                home.cd(oldLibraryPath);
            } else {

                if (!home.exists(libraryPath)) {
                    if (!home.mkpath(libraryPath)) {

                        // tell user why we aborted !
                        QMessageBox::critical(NULL, "Exiting", QString("Cannot create library directory (%1)").arg(libraryPath));
                        exit(0);
                    }
                }
                home.cd(libraryPath);
            }
        }

        // set global root directory
        gcroot = home.canonicalPath();

        // now redirect stderr
#ifndef WIN32
        if (!debug) nostderr(home.canonicalPath());
#endif

        // install QT Translator to enable QT Dialogs translation
        // we may have restarted JUST to get this!
        QTranslator qtTranslator;
        qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
        application->installTranslator(&qtTranslator);

        // Language setting (default to system locale)
        QVariant lang = appsettings->value(NULL, GC_LANG, QLocale::system().name());

        // Load specific translation
        QTranslator gcTranslator;
        gcTranslator.load(":translations/gc_" + lang.toString() + ".qm");
        application->installTranslator(&gcTranslator);

        // Initialize metrics once the translator is installed
        RideMetricFactory::instance().initialize();

        // Initialize global registry once the translator is installed
        GcWindowRegistry::initialize();

        // initialise the trainDB
        trainDB = new TrainDB(home);

        // lets do what the command line says ...
        QVariant lastOpened;
        if(args.count() == 2) { // $ ./GoldenCheetah Mark

            // athlete
            lastOpened = args.at(1);

        } else if (args.count() == 3) { // $ ./GoldenCheetah ~/Athletes Mark

            // first parameter is a folder that exists?
            if (QFileInfo(args.at(1)).isDir()) {
                home.cd(args.at(1));
开发者ID:AndyBryson,项目名称:GoldenCheetah,代码行数:67,代码来源:main.cpp

示例8: main

int
main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    //this is the path within the current directory where GC will look for
    //files to allow USB stick support
    QString localLibraryPath="Library/GoldenCheetah";

    //this is the path that used to be used for all platforms
    //now different platforms will use their own path
    //this path is checked first to make things easier for long-time users
    QString oldLibraryPath=QDir::home().path()+"/Library/GoldenCheetah";

    //these are the new platform-dependent library paths
#if defined(Q_OS_MACX)
    QString libraryPath="Library/GoldenCheetah";
#elif defined(Q_OS_WIN)
    QString libraryPath=QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/GoldenCheetah";
#else
    // Q_OS_LINUX et al
    QString libraryPath=".goldencheetah";
#endif

    //First check to see if the Library folder exists where the executable is (for USB sticks)
    QDir home = QDir();
    //if it does, create an ini file for settings and cd into the library
    if(home.exists(localLibraryPath))
    {
         home.cd(localLibraryPath);
    }
    //if it does not exist, let QSettings handle storing settings
    //also cd to the home directory and look for libraries
    else
    {
        home = QDir::home();
        //check if this users previously stored files in the old library path
        //if they did, use the existing library
        if (home.exists(oldLibraryPath))
        {
            home.cd(oldLibraryPath);
        }
        //otherwise use the new library path
        else
        {
            //first create the path if it does not exist
            if (!home.exists(libraryPath))
            {
                if (!home.mkpath(libraryPath))
                {
                    qDebug()<<"Failed to create library path\n";
                    assert(false);
                }
            }
            home.cd(libraryPath);
        }
    }
    boost::shared_ptr<QSettings> settings;
    settings = GetApplicationSettings();

#ifdef ENABLE_METRICS_TRANSLATION
    // install QT Translator to enable QT Dialogs translation
    QTranslator qtTranslator;
    qtTranslator.load("qt_" + QLocale::system().name(),
             QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    app.installTranslator(&qtTranslator);
#endif

    // Language setting (default to system locale)
    QVariant lang = settings->value(GC_LANG, QLocale::system().name());

    // Load specific translation
    QTranslator gcTranslator;
    gcTranslator.load(":translations/gc_" + lang.toString() + ".qm");
    app.installTranslator(&gcTranslator);
 
#ifdef ENABLE_METRICS_TRANSLATION
    RideMetricFactory::instance().initialize();
#endif

    QVariant lastOpened = settings->value(GC_SETTINGS_LAST);
    QVariant unit = settings->value(GC_UNIT);
#ifdef ENABLE_METRICS_TRANSLATION
    if (unit.isNull()) { // Default to system locale
        unit = QLocale::system().measurementSystem() == QLocale::MetricSystem ? "Metric" : "Imperial";
        settings->setValue(GC_UNIT, unit);
    }
#endif
    double crankLength = settings->value(GC_CRANKLENGTH).toDouble();
    if(crankLength<=0) {
       settings->setValue(GC_CRANKLENGTH,172.5);
    }

    bool anyOpened = false;
    if (lastOpened != QVariant()) {
        QStringList list = lastOpened.toStringList();
        QStringListIterator i(list);
        while (i.hasNext()) {
            QString cyclist = i.next();
            if (home.cd(cyclist)) {
//.........这里部分代码省略.........
开发者ID:bodylinksystems,项目名称:GoldenCheetah,代码行数:101,代码来源:main.cpp

示例9: main

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    int currentExitCode = 0;

    QScopedPointer<QSymbianApplication> app(new QSymbianApplication(argc, argv));

    // Set App Info:
    app->setApplicationName("Battery Status");
    app->setOrganizationName("Motaz Alnuweiri");
    app->setApplicationVersion(APP_Version);

    // QT_DEBUG or QT_NO_DEBUG
//    #ifdef QT_DEBUG
//        // Install Debug Msgs Handler:
//        ClearDebugFile();
//        qInstallMsgHandler(DebugFileHandler);
//    #endif

    // Install EventFilter in QApplication:
    //app->installEventFilter(new myEventFilter);

    // Set App Splash Screen:
    QSplashScreen *splash = new QSplashScreen(QPixmap(":qml/Images/JPG/Splash_Screen.jpg"),
                                              Qt::WindowStaysOnTopHint);
    splash->show();

    // Check System Language & Load App Translator:
    QString systemLang = QLocale::system().name();
    QTranslator appTranslator;

    systemLang.truncate(2); //truncate(2) to ignore the country code

    if (QFile::exists("Languages/batterystatus_" + systemLang + ".qm")) {
        appTranslator.load("batterystatus_" + systemLang, "Languages");
    } else {
        appTranslator.load("batterystatus_en", "Languages");
    }

    // Install QTranslator to QApplication:
    app->installTranslator(&appTranslator);

    // Hide The App If Deactive:
    if (!app->foreground())
        QSymbianHelper::hideInBackground();

    // Register QSettings:
    QAppSettings appSettings;

    // Register QmlApplicationViewer:
    QmlApplicationViewer *viewer = new QmlApplicationViewer();
    //viewer.setResizeMode(QmlApplicationViewer::SizeRootObjectToView);
    //viewer.setAutoFillBackground(false);
    //viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);

    // Register App HSWidget:
    QBatteryHSWidget *batteryHSWidget = new QBatteryHSWidget();
    batteryHSWidget->setBackgroundOpacity(appSettings.getWidgetOpacity());

    // Register QDeviceName:
    QDeviceName deviceName;

    // Register Class to QML:
    qmlRegisterType<QPSMode>("PSMode", 1, 0, "PSMode");
    qmlRegisterType<QGlobalNote>("GlobalNote", 1, 0, "GlobalNote");
    qmlRegisterType<QCBatteryInfo>("CBatteryInfo", 1, 0, "CBatteryInfo");
    qmlRegisterType<CommonType>("CommonType", 1, 0, "CommonType");

    // Set Propertys to QML:
    viewer->rootContext()->setContextProperty("APPName", QObject::tr("Battery Status"));
    viewer->rootContext()->setContextProperty("APPVersion", app->applicationVersion());
    viewer->rootContext()->setContextProperty("AppPath", app->applicationDirPath());
    viewer->rootContext()->setContextProperty("SymbianHelper", new QSymbianHelper);
    viewer->rootContext()->setContextProperty("AppSettings", &appSettings);
    viewer->rootContext()->setContextProperty("HSWidget", batteryHSWidget);
    viewer->rootContext()->setContextProperty("DeviceName", &deviceName);
    viewer->rootContext()->setContextProperty("QApp", app->instance());

    viewer->setSource(QUrl(QLatin1String("qrc:qml/main.qml")));
    //viewer.setSource(QUrl::fromLocalFile("qrc:qml/main.qml"));

    // Lock screen orientation in portrait only
    //viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);

    //viewer.setGeometry(app->desktop()->screenGeometry());
    viewer->showFullScreen();

    // Stop Splash Screen & Delete It:
    splash->finish(viewer);
    splash->deleteLater();

    //viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);

    // Enter App Event Loop:
    currentExitCode = app->exec();

    // Cleun Pointers:
    delete viewer;
    delete batteryHSWidget;

    // Check If App Is Restarting:
//.........这里部分代码省略.........
开发者ID:Motaz-Alnuweiri,项目名称:BatteryStatus,代码行数:101,代码来源:main.cpp

示例10: main


//.........这里部分代码省略.........
		if(startintray) {
			if(verbose) std::clog << "Starting minimised to tray" << std::endl;
			// If the option "Use Tray Icon" in the settings is not set, we set it
			QFile set(QDir::homePath() + "/.photoqt/settings");
			if(set.open(QIODevice::ReadOnly)) {
				QTextStream in(&set);
				QString all = in.readAll();
				if(!all.contains("TrayIcon=1")) {
					if(all.contains("TrayIcon=0"))
						all.replace("TrayIcon=0","TrayIcon=1");
					else
						all += "\n[Temporary Appended]\nTrayIcon=1\n";
					set.close();
					set.remove();
					if(!set.open(QIODevice::WriteOnly))
						std::cerr << "ERROR: Can't enable tray icon setting!" << std::endl;
					QTextStream out(&set);
					out << all;
					set.close();
				} else
					set.close();
			} else
				std::cerr << "Unable to ensure TrayIcon is enabled - make sure it is enabled!!" << std::endl;
		}

		QApplication a(argc, argv);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
		// Opt-in to High DPI usage of Pixmaps for larger screens with larger font DPI
		a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif

		// LOAD THE TRANSLATOR
		QTranslator trans;

		// We use two strings, since the system locale usually is of the form e.g. "de_DE"
		// and some translations only come with the first part, i.e. "de",
		// and some with the full string. We need to be able to find both!
		if(verbose) std::clog << "Checking for translation" << std::endl;
		QString code1 = "";
		QString code2 = "";
		if(settingsFileTxt.contains("Language=") && !settingsFileTxt.contains("Language=en") && !settingsFileTxt.contains("Language=\n")) {
			code1 = settingsFileTxt.split("Language=").at(1).split("\n").at(0).trimmed();
			code2 = code1;
		} else if(!settingsFileTxt.contains("Language=en")) {
			code1 = QLocale::system().name();
			code2 = QLocale::system().name().split("_").at(0);
		}
		if(verbose) std::clog << "Found following language: " << code1.toStdString()  << "/" << code2.toStdString() << std::endl;
		if(QFile(":/lang/photoqt_" + code1 + ".qm").exists()) {
			std::clog << "Loading Translation:" << code1.toStdString() << std::endl;
			trans.load(":/lang/photoqt_" + code1);
			a.installTranslator(&trans);
			code2 = code1;
		} else if(QFile(":/lang/photoqt_" + code2 + ".qm").exists()) {
			std::clog << "Loading Translation:" << code2.toStdString() << std::endl;
			trans.load(":/lang/photoqt_" + code2);
			a.installTranslator(&trans);
			code1 = code2;
		}

		// Check if thumbnail database exists. If not, create it
		QFile database(QDir::homePath() + "/.photoqt/thumbnails");
		if(!database.exists()) {

			if(verbose) std::clog << "Create Thumbnail Database" << std::endl;
开发者ID:JongHong,项目名称:photoqt-dev,代码行数:67,代码来源:main.cpp

示例11: main

int main(int argc, char *argv[])
{
    QString error;
    QString arg;
    QString compressedFile;
    QString projectFile;
    QString basePath;
    bool showHelp = false;
    bool showVersion = false;
    bool checkLinks = false;

    // don't require a window manager even though we're a QGuiApplication
    qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("minimal"));

    QGuiApplication app(argc, argv);
#ifndef Q_OS_WIN32
    QTranslator translator;
    QTranslator qtTranslator;
    QTranslator qt_helpTranslator;
    QString sysLocale = QLocale::system().name();
    QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
    if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
        && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
        && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
        app.installTranslator(&translator);
        app.installTranslator(&qtTranslator);
        app.installTranslator(&qt_helpTranslator);
    }
#endif // Q_OS_WIN32

    for (int i = 1; i < argc; ++i) {
        arg = QString::fromLocal8Bit(argv[i]);
        if (arg == QLatin1String("-o")) {
            if (++i < argc) {
                QFileInfo fi(QString::fromLocal8Bit(argv[i]));
                compressedFile = fi.absoluteFilePath();
            } else {
                error = QHG::tr("Missing output file name.");
            }
        } else if (arg == QLatin1String("-v")) {
            showVersion = true;
        } else if (arg == QLatin1String("-h")) {
            showHelp = true;
        } else if (arg == QLatin1String("-c")) {
            checkLinks = true;
        } else {
            QFileInfo fi(arg);
            projectFile = fi.absoluteFilePath();
            basePath = fi.absolutePath();
        }
    }

    if (showVersion) {
        fputs(qPrintable(QHG::tr("Qt Help Generator version 1.0 (Qt %1)\n")
                         .arg(QT_VERSION_STR)), stdout);
        return 0;
    }

    if (projectFile.isEmpty() && !showHelp)
        error = QHG::tr("Missing Qt help project file.");

    QString help = QHG::tr("\nUsage:\n\n"
        "qhelpgenerator <help-project-file> [options]\n\n"
        "  -o <compressed-file>   Generates a Qt compressed help\n"
        "                         file called <compressed-file>.\n"
        "                         If this option is not specified\n"
        "                         a default name will be used.\n"
        "  -c                     Checks whether all links in HTML files\n"
        "                         point to files in this help project.\n"
        "  -v                     Displays the version of \n"
        "                         qhelpgenerator.\n\n");

    if (showHelp) {
        fputs(qPrintable(help), stdout);
        return 0;
    }else if (!error.isEmpty()) {
        fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help));
        return -1;
    }

    QFile file(projectFile);
    if (!file.open(QIODevice::ReadOnly)) {
        fputs(qPrintable(QHG::tr("Could not open %1.\n").arg(projectFile)), stderr);
        return -1;
    }

    if (compressedFile.isEmpty()) {
        if (!checkLinks) {
            QFileInfo fi(projectFile);
            compressedFile = basePath + QDir::separator()
                             + fi.baseName() + QLatin1String(".qch");
        }
    } else {
        // check if the output dir exists -- create if it doesn't
        QFileInfo fi(compressedFile);
        QDir parentDir = fi.dir();
        if (!parentDir.exists()) {
            if (!parentDir.mkpath(QLatin1String("."))) {
                fputs(qPrintable(QHG::tr("Could not create output directory: %1\n")
                                 .arg(parentDir.path())), stderr);
//.........这里部分代码省略.........
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:101,代码来源:main.cpp

示例12: main

int main(int argc, char** argv)
{

  Q_INIT_RESOURCE(resource);

  QString nextTranslator;


  //const char* argv_2[]={"OpenBrf"}; int argc_2=1;

  //QApplication app(argc_2,argv_2); //argc, argv);
  QApplication app(argc, argv);
  QStringList arguments = QCoreApplication::arguments();
  app.setApplicationVersion(applVersion);
  app.setApplicationName("OpenBrf");
  app.setOrganizationName("Marco Tarini");
  app.setOrganizationDomain("Marco Tarini");


  bool useAlphaC = false;

  if ((arguments.size()>1)&&(arguments[1].startsWith("-"))) {
    if ((arguments[1] == "--dump")&&(arguments.size()==4)) {
      switch (MainWindow().loadModAndDump(arguments[2],arguments[3])) {
      case -1: printf("OpenBRF: invalid module folder\n"); break;
      case -2: printf("OpenBRF: error scanning brf data or ini file\n"); break;
      case -3: printf("OpenBRF: error writing output file\n"); break;
      default: return 0;
      }
      return -1;
    } else if ((arguments[1] == "--useAlphaCommands")&&(arguments.size()==2))  {
      useAlphaC = true;
      arguments.clear();
    } else {
      showUsage();
      return -1;
    }

  }

  while (1){
    QTranslator translator;
    QTranslator qtTranslator;

    if (nextTranslator.isEmpty()){
      QString loc;
      switch (MainWindow::getLanguageOption()) {
      default: loc = QLocale::system().name(); break;
      case 1: loc = QString("en");break;
      case 2: loc = QString("zh_CN");break;
      case 3: loc = QString("es");break;
      case 4: loc = QString("de");break;
      }
      translator.load(QString(":/translations/openbrf_%1.qm").arg(loc));

      qtTranslator.load(QString(":/translations/qt_%1.qm").arg(loc));
    } else {
      translator.load(nextTranslator);
    }
    app.installTranslator(&translator);
    app.installTranslator(&qtTranslator);

    MainWindow w;
    w.setUseAlphaCommands(useAlphaC);
    w.show();

    if (arguments.size()>1) w.loadFile(arguments[1]); arguments.clear();
    if (app.exec()==101) {
      nextTranslator = w.getNextTranslatorFilename();
      continue; // just changed language! another run
    }
    break;
  }

  return 0;
}
开发者ID:cfcohen,项目名称:openbrf,代码行数:76,代码来源:main.cpp

示例13: main

int main(int argc, char *argv[])
{
    VSingleInstanceGuard guard;
    bool canRun = guard.tryRun();

    QTextCodec *codec = QTextCodec::codecForName("UTF8");
    if (codec) {
        QTextCodec::setCodecForLocale(codec);
    }

    QApplication app(argc, argv);

    // The file path passed via command line arguments.
    QStringList filePaths = VUtils::filterFilePathsToOpen(app.arguments().mid(1));

    if (!canRun) {
        // Ask another instance to open files passed in.
        if (!filePaths.isEmpty()) {
            guard.openExternalFiles(filePaths);
        } else {
            guard.showInstance();
        }

        return 0;
    }

    VConfigManager vconfig;
    vconfig.initialize();
    g_config = &vconfig;

#if defined(QT_NO_DEBUG)
    for (int i = 1; i < argc; ++i) {
        if (!qstrcmp(argv[i], "-d")) {
            g_debugLog = true;
            break;
        }
    }

    initLogFile(vconfig.getLogFilePath());
#endif

    qInstallMessageHandler(VLogger);

    QString locale = VUtils::getLocale();
    // Set default locale.
    if (locale == "zh_CN") {
        QLocale::setDefault(QLocale(QLocale::Chinese, QLocale::China));
    }

    qDebug() << "command line arguments" << app.arguments();
    qDebug() << "files to open from arguments" << filePaths;

    // Check the openSSL.
    qDebug() << "openSSL" << QSslSocket::sslLibraryBuildVersionString()
             << QSslSocket::sslLibraryVersionNumber();

    // Load missing translation for Qt (QTextEdit/QPlainTextEdit/QTextBrowser).
    QTranslator qtTranslator1;
    if (qtTranslator1.load("widgets_" + locale, ":/translations")) {
        app.installTranslator(&qtTranslator1);
    }

    QTranslator qtTranslator2;
    if (qtTranslator2.load("qdialogbuttonbox_" + locale, ":/translations")) {
        app.installTranslator(&qtTranslator2);
    }

    QTranslator qtTranslator3;
    if (qtTranslator3.load("qwebengine_" + locale, ":/translations")) {
        app.installTranslator(&qtTranslator3);
    }

    // Load translation for Qt from resource.
    QTranslator qtTranslator;
    if (qtTranslator.load("qt_" + locale, ":/translations")) {
        app.installTranslator(&qtTranslator);
    }

    // Load translation for Qt from env.
    QTranslator qtTranslatorEnv;
    if (qtTranslatorEnv.load("qt_" + locale, "translations")) {
        app.installTranslator(&qtTranslatorEnv);
    }

    // Load translation for vnote.
    QTranslator translator;
    if (translator.load("vnote_" + locale, ":/translations")) {
        app.installTranslator(&translator);
    }

    VPalette palette(g_config->getThemeFile());
    g_palette = &palette;

    VMainWindow w(&guard);
    QString style = palette.fetchQtStyleSheet();
    if (!style.isEmpty()) {
        app.setStyleSheet(style);
    }

    w.show();
//.........这里部分代码省略.........
开发者ID:vscanf,项目名称:vnote,代码行数:101,代码来源:main.cpp

示例14: main

int main(int argc, char *argv[])
{
  ArgumentList *argList = new ArgumentList(argc, argv);

#if QT_VERSION < 0x050000
  QApplication::setGraphicsSystem(QLatin1String("raster"));
#endif

  QString packagesToInstall;
  QString arg;

  for (int c=1; c<argc; c++)
  {
    arg = argv[c];
    if (arg.contains("pkg.tar*"))
    {
      packagesToInstall += arg + ",";
    }
  }

  QtSingleApplication app( StrConstants::getApplicationName(), argc, argv );

  if (app.isRunning())
  {
    if (argList->getSwitch("-sysupgrade"))
    {
      app.sendMessage("SYSUPGRADE");
    }
    else if (argList->getSwitch("-sysupgrade-noconfirm"))
    {
      app.sendMessage("SYSUPGRADE_NOCONFIRM");
    }
    else if (argList->getSwitch("-close"))
    {
      app.sendMessage("CLOSE");
    }
    else if (argList->getSwitch("-hide"))
    {
      app.sendMessage("HIDE");
    }
    else if (!packagesToInstall.isEmpty())
    {
      app.sendMessage(packagesToInstall);
    }
    else
    {
      app.sendMessage("RAISE");
    }

    return 0;
  }

  //This sends a message just to enable the socket-based QtSingleApplication engine
  app.sendMessage("RAISE");

  QTranslator appTranslator;
  appTranslator.load(":/resources/translations/octopi_" +
                     QLocale::system().name());
  app.installTranslator(&appTranslator);

  if (argList->getSwitch("-help")){
    std::cout << StrConstants::getApplicationCliHelp().toLatin1().data() << std::endl;
    return(0);
  }
  else if (argList->getSwitch("-version")){
    std::cout << "\n" << StrConstants::getApplicationName().toLatin1().data() <<
                 " " << StrConstants::getApplicationVersion().toLatin1().data() << "\n" << std::endl;
    return(0);
  }

  if (UnixCommand::isRootRunning() && !WMHelper::isKDERunning()){
    QMessageBox::critical( 0, StrConstants::getApplicationName(), StrConstants::getErrorRunningWithRoot());
    return ( -2 );
  }

  MainWindow w;
  app.setActivationWindow(&w);
  app.setQuitOnLastWindowClosed(false);

#if QT_VERSION < 0x050000
  #ifndef NO_GTK_STYLE
  if (!argList->getSwitch("-style"))
  {
    if (UnixCommand::getLinuxDistro() == ectn_MANJAROLINUX &&
        (!WMHelper::isKDERunning() && (!WMHelper::isRazorQtRunning()) && (!WMHelper::isLXQTRunning())))
    {
      app.setStyle(new QGtkStyle());
    }
    else if(UnixCommand::getLinuxDistro() != ectn_CHAKRA)
    {
      app.setStyle(new QCleanlooksStyle());
    }
  }
  #endif
#endif

  if (argList->getSwitch("-sysupgrade-noconfirm"))
  {
    w.setCallSystemUpgradeNoConfirm();
  }
//.........这里部分代码省略.........
开发者ID:msys2,项目名称:octopi,代码行数:101,代码来源:main.cpp

示例15: main

int main(int argc, char *argv[])
{
#ifdef WITH_IMAGEMAGICK
	Magick::InitializeMagick(*argv);
#endif

	QCoreApplication *a = (argc == 1) ? new QApplication(argc, argv) : new QCoreApplication(argc, argv);

	if(a)
	{
		/* we need nice getDataHome */
		#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
		QCoreApplication::setApplicationName("luckygps");
		QCoreApplication::setOrganizationName(".");
		#endif

		QLocale locale = QLocale::system();
		QString locale_name = locale.name();
		QTranslator translator;

		/* Detect if luckyGPS is executed in "local mode" (no installation) */
		int local = 0;
		QDir dir(QCoreApplication::applicationDirPath());
		QFileInfoList fileList = dir.entryInfoList(QStringList("luckygps_*.qm"), QDir::AllEntries | QDir::NoDot | QDir::NoDotDot);
		if(fileList.length() > 0)
			local = 1;

#if defined(Q_OS_LINUX)
		translator.load(QString("luckygps_") + locale_name, "/usr/share/luckygps");
#else
		translator.load(QString("luckygps_") + locale_name, getDataHome(local));
#endif

		a->installTranslator(&translator);
		setlocale(LC_NUMERIC, "C");

		if(argc == 1)
		{
			MainWindow w(0, local);
			w.show();

			a->exec();
		}
#ifdef WITH_ROUTING
		else
		{
			/* check if 1 argument is given */
			if(argc > 3)
			{
				printf("\nUsage: luckygps FILE.osm.pbf [SETTINGS.spp]\n");
			}
			else
			{
				QString settingsFile;
				if(argc == 2)
					settingsFile = ":/data/motorcar.spp";
				else
					settingsFile = QString(argv[2]);

				/* import osm file into routing database */
				if(importOsmPbf(a, argv[1], settingsFile, local))
					qWarning() << "Import successfully.";
				else
					qWarning() << "Import failed.";
			}
		}
#endif

		delete a;
	}

	return true;
}
开发者ID:shujaatak,项目名称:luckygps2,代码行数:73,代码来源:main.cpp


注:本文中的QTranslator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。