Example #1
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    app.setApplicationName("objects");
    app.setApplicationVersion("0.1");

    QCommandLineParser parser;
    parser.setApplicationDescription("OpenGL objects");
    parser.addHelpOption();
    parser.addVersionOption();

    QCommandLineOption objectOption(QStringList() << "o" << "object",
            QCoreApplication::translate("main", "Use object <object>."),
            QCoreApplication::translate("main", "object"),
            QString::fromLatin1("earth.obj"));
    parser.addOption(objectOption);
    QCommandLineOption shaderOption(QStringList() << "s" << "shader",
            QCoreApplication::translate("main", "Use shaders <shader>.[fv].glsl."),
            QCoreApplication::translate("main", "shader"),
            QString::fromLatin1("simple"));
    parser.addOption(shaderOption);
    
    parser.process(app);

#ifndef QT_NO_OPENGL
    MainWidget widget;
    widget.setObject(parser.value(objectOption));
    widget.setShader(parser.value(shaderOption));
    widget.show();
#else
    QLabel note("OpenGL Support required");
    note.show();
#endif
    return app.exec();
}
Example #2
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    KAboutData about(QStringLiteral("kapptest"), i18n("kapptest"), QStringLiteral("version"));
    KAboutData::setApplicationData(about);
    QCommandLineParser options;
    options.addOption(QCommandLineOption(QStringList(QStringLiteral("t")) << QStringLiteral("type"), i18n("The type of shutdown to emulate: Default, None, Reboot, Halt or Logout"), QStringLiteral("name"), QStringLiteral("None")));
    options.addOption(QCommandLineOption(QStringLiteral("choose"), i18n("Sets the mode where the user can choose between the different options. Use with --type.")));

    about.setupCommandLine(&options);
    options.process(app);
    about.processCommandLine(&options);

    KIconLoader::global()->addAppDir(QStringLiteral("ksmserver"));

    QString sdtypeOption = options.value(QStringLiteral("type")).toLower();
    KWorkSpace::ShutdownType sdtype = KWorkSpace::ShutdownTypeDefault;
    if (sdtypeOption == QStringLiteral("reboot")) {
        sdtype = KWorkSpace::ShutdownTypeReboot;
    } else if (sdtypeOption == QStringLiteral("halt")) {
        sdtype = KWorkSpace::ShutdownTypeHalt;
    } else if (sdtypeOption == QStringLiteral("logout")) {
        sdtype = KWorkSpace::ShutdownTypeNone;
    }

    QString bopt;
    (void)KSMShutdownDlg::confirmShutdown( true, options.isSet(QStringLiteral("choose")), sdtype, bopt, QString() );
/*   (void)KSMShutdownDlg::confirmShutdown( false, false, sdtype, bopt ); */
}
Example #3
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);


    QCommandLineParser parser;
    parser.setApplicationDescription("agar.io private server");
    parser.addHelpOption();

    QCommandLineOption dbgOption(QStringList() << "d" << "debug",
            QCoreApplication::translate("main", "Debug output [default: off]."));
    parser.addOption(dbgOption);
    QCommandLineOption portOption(QStringList() << "p" << "port",
            QCoreApplication::translate("main", "Port for server [default: 9000]."),
            QCoreApplication::translate("main", "port"), QLatin1Literal("9000"));
    parser.addOption(portOption);
    parser.process(a);
    bool debug = parser.isSet(dbgOption);
    int port = parser.value(portOption).toInt();

    GameServer *server = new GameServer(port, debug);
    QObject::connect(server, &GameServer::closed, &a, &QCoreApplication::quit);

    return a.exec();
}
Example #4
0
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    const QString description = QStringLiteral("Converts desktop files to json");
    const char version[] = "1.0";

    app.setApplicationVersion(version);

    const static QString _i = QStringLiteral("input");
    const static QString _o = QStringLiteral("output");
    const static QString _n = QStringLiteral("name");

    QCommandLineOption input = QCommandLineOption(QStringList() << QStringLiteral("i") << _i,
                                        QStringLiteral("Read input from file"), _n);
    QCommandLineOption output = QCommandLineOption(QStringList() << QStringLiteral("o") << _o,
                                        QStringLiteral("Write output to file"), _n);

    QCommandLineParser parser;
    parser.addVersionOption();
    parser.addHelpOption(description);
    parser.addOption(input);
    parser.addOption(output);

    KConfigToJson dtj(&parser, input, output);

    parser.process(app);
    return dtj.runMain();
}
Example #5
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setApplicationName(TARGET);
    a.setApplicationVersion("1");
#ifdef __linux__
    a.setWindowIcon(QIcon(":MoleGraph.png"));
#endif

    QCommandLineParser parser;
    parser.setApplicationDescription("Test helper");
    parser.addHelpOption();
    parser.addVersionOption();

    QCommandLineOption openOption(QStringList() << "o" << "open-file",
                QCoreApplication::translate("main", "Open file."), QCoreApplication::translate("main", "directory"));
    parser.addOption(openOption);

    QCommandLineOption withoutValuesOption(QStringList() << "w" << "without-values",
                QCoreApplication::translate("main", "Modifier for opening file without values (just measurement template)."));
    parser.addOption(withoutValuesOption);

    parser.addPositionalArgument("file", "file to open");

    parser.process(a);

    QString fileName = parser.value(openOption);
    const QStringList arguments = parser.positionalArguments();
    if (arguments.size() > 0)
        fileName = arguments[0];
    MainWindow w(a, fileName, parser.isSet(withoutValuesOption));
    w.show();

	return a.exec();
}
void tst_QCommandLineParser::testStdinArgument()
{
    QFETCH(QCommandLineParser::SingleDashWordOptionMode, parsingMode);

    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    parser.setSingleDashWordOptionMode(parsingMode);
    parser.addOption(QCommandLineOption(QStringList() << "i" << "input", QStringLiteral("Input file."), QStringLiteral("filename")));
    parser.addOption(QCommandLineOption("b", QStringLiteral("Boolean option.")));
    QVERIFY(parser.parse(QStringList() << "tst_qcommandlineparser" << "--input" << "-"));
    QCOMPARE(parser.value("input"), QString("-"));
    QCOMPARE(parser.positionalArguments(), QStringList());
    QCOMPARE(parser.unknownOptionNames(), QStringList());

    QVERIFY(parser.parse(QStringList() << "tst_qcommandlineparser" << "--input" << "-" << "-b" << "arg"));
    QCOMPARE(parser.value("input"), QString("-"));
    QVERIFY(parser.isSet("b"));
    QCOMPARE(parser.positionalArguments(), QStringList() << "arg");
    QCOMPARE(parser.unknownOptionNames(), QStringList());

    QVERIFY(parser.parse(QStringList() << "tst_qcommandlineparser" << "-"));
    QCOMPARE(parser.value("input"), QString());
    QVERIFY(!parser.isSet("b"));
    QCOMPARE(parser.positionalArguments(), QStringList() << "-");
    QCOMPARE(parser.unknownOptionNames(), QStringList());
}
//! Bereitet die Eingabeparameter vor
void createInputCommands(QCommandLineParser &cmdParser) {
  //! Befehle
  QCommandLineOption inputPath("i", "Path for input", "...");
  QCommandLineOption outputPath("o", "Path for output", "...");
  QCommandLineOption generateType("g", "Generating type", "[htmlbasic]");
  QCommandLineOption chartTitle("t", "Title for the chart", "...");
  QCommandLineOption minValueX("x", "Maximumvalue for the chart on the X-Axis", "...");
  QCommandLineOption minValueY("y", "Maximumvalue for the chart on the Y-Axis", "...");

  cmdParser.setApplicationDescription("Description");
  cmdParser.addHelpOption();
  cmdParser.addPositionalArgument("useLabel",
                                  "Use the label form json as label for the graph");
  cmdParser.addPositionalArgument("useScrolling", "Uses Scrolling with Highstock");
  cmdParser.addPositionalArgument("useInlineJS",
                                  "Uses JQuery and HighChart without seperate File");
  cmdParser.addPositionalArgument("useNavigator", "Adds a navigator to the chart");

  //! Optionen hinzuf├╝gen
  cmdParser.addOption(inputPath);
  cmdParser.addOption(outputPath);
  cmdParser.addOption(generateType);
  cmdParser.addOption(chartTitle);
  cmdParser.addOption(minValueX);
  cmdParser.addOption(minValueY);
}
Example #8
0
void ApplicationSettings::parse()
{
    QCommandLineParser parser;
    parser.setApplicationDescription(QObject::tr("i-score - An interactive sequencer for the intermedia arts."));
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("file", QCoreApplication::translate("main", "Scenario to load."));

    QCommandLineOption noGUI("no-gui", QCoreApplication::translate("main", "Disable GUI"));
    parser.addOption(noGUI);
    QCommandLineOption noRestore("no-restore", QCoreApplication::translate("main", "Disable auto-restore"));
    parser.addOption(noRestore);

    QCommandLineOption autoplayOpt("autoplay", QCoreApplication::translate("main", "Auto-play the loaded scenario"));
    parser.addOption(autoplayOpt);

    parser.process(*qApp);

    const QStringList args = parser.positionalArguments();

    tryToRestore = !parser.isSet(noRestore);
    gui = !parser.isSet(noGUI);
    autoplay = parser.isSet(autoplayOpt) && args.size() == 1;

    if(!args.empty() && QFile::exists(args[0]))
    {
        loadList.push_back(args[0]);
    }
}
Example #9
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    KAboutData aboutData(QStringLiteral("test"),
                         i18n("Test Application"),
                         QStringLiteral("1.0"));

    QCommandLineParser parser;
    KAboutData::setApplicationData(aboutData);
    parser.addVersionOption();
    parser.addHelpOption();
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("path"), i18n("IMAP destination path"), QStringLiteral("argument")));
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("mimetype"), i18n("Source mimetype"), QStringLiteral("argument"), QStringLiteral("application/octet-stream")));
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("file"), i18n("Source file"), QStringLiteral("argument")));
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("count"), i18n("Number of times this file is added"), QStringLiteral("argument"), QStringLiteral("1")));

    //PORTING SCRIPT: adapt aboutdata variable if necessary
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);

    QString path = parser.value(QStringLiteral("path"));
    QString mimetype = parser.value(QStringLiteral("mimetype"));
    QString file = parser.value(QStringLiteral("file"));
    int count = qMax(1, parser.value(QStringLiteral("count")).toInt());
    ItemDumper d(path, file, mimetype, count);
    return app.exec();
}
Example #10
0
int main(int argc, char** argv)
{
    if( loadSettingsOk(argc, argv) )
    {
        // If -l option is provided, settings are loaded and app is closed.
        QCoreApplication app(argc, argv);
        LoadSettings load;
        return app.exec();
    }

    LXQt::SingleApplication app(argc, argv);

    // Command line options
    QCommandLineParser parser;
    QCommandLineOption loadOption(QStringList() << "l" << "loadlast",
            app.tr("Load last settings."));
    parser.addOption(loadOption);
    QCommandLineOption helpOption = parser.addHelpOption();
    parser.addOption(loadOption);
    parser.addOption(helpOption);

    //parser.process(app);
    //bool loadLastSettings = parser.isSet(loadOption);

    MonitorSettingsDialog dlg;
    app.setActivationWindow(&dlg);
    dlg.setWindowIcon(QIcon::fromTheme("preferences-desktop-display"));
    dlg.show();

    return app.exec();

}
Example #11
0
File: main.cpp Project: kanocz/ujea
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    // some command line arguments parsing stuff
    QCoreApplication::setApplicationName("ujea");
    QCoreApplication::setApplicationVersion("1.2");

    QString hostname = QHostInfo::localHostName();

    QCommandLineParser parser;
    parser.setApplicationDescription("Universal job execution agent using AMQP queue");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addOption(QCommandLineOption("aliveInterval", "Interval in ms between alive messages (1000).", "aliveInterval", "1000"));
    parser.addOption(QCommandLineOption("aliveTTL", "TTL in queue for alive messages (1500).", "aliveTTL", "1500"));
    parser.addOption(QCommandLineOption("queueCmd", "Commands queue name ("+hostname+"_cmd).", "queueCmd", hostname+"_cmd"));
    parser.addOption(QCommandLineOption("queueRpl", "Replays queue name ("+hostname+"_rpl).", "queueRpl", hostname+"_rpl"));
    parser.addOption(QCommandLineOption("execRegex", "Regex for permited commands. (none)", "execRegex", ""));
    parser.addPositionalArgument("url", QCoreApplication::translate("main", "AMQP url"));
    parser.process(app);

    const QStringList args = parser.positionalArguments();

    // we need to have 1 argument and optional named arguments
    if (args.count() != 1) parser.showHelp(-1);

    // create and execure worker
    JobsExecuter qw{QUrl(args.value(0)), parser.value("queueCmd"), parser.value("queueRpl"),
                    parser.value("aliveInterval").toInt(), parser.value("aliveTTL").toInt(),
                    parser.value("execRegex")};

    return app.exec();
}
Example #12
0
int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    QCommandLineParser parser;
    parser.addVersionOption();
    parser.addHelpOption();
    parser.addOption(QCommandLineOption(QStringList() << QLatin1String("demopoints_single"), i18n("Add built-in demo points as single markers")));
    parser.addOption(QCommandLineOption(QStringList() << QLatin1String("demopoints_group"),  i18n("Add built-in demo points as groupable markers")));
    parser.addOption(QCommandLineOption(QStringList() << QLatin1String("single"),            i18n("Do not group the displayed images")));
    parser.addPositionalArgument(QString::fromLatin1("images"), i18n("List of images"), QString::fromLatin1("[images...]"));
    parser.process(app);

    // get the list of images to load on startup:
    QList<QUrl> imagesList;

    foreach(const QString& file, parser.positionalArguments())
    {
        const QUrl argUrl = QUrl::fromLocalFile(file);
        qDebug() << argUrl;
        imagesList << argUrl;
    }

    MainWindow* const myMainWindow = new MainWindow(&parser);
    myMainWindow->show();
    myMainWindow->slotScheduleImagesForLoading(imagesList);

    return app.exec();
}
Example #13
0
QT_USE_NAMESPACE

int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);

    QCoreApplication::setApplicationName(QStringLiteral("qtdiag"));
    QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
    QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
    QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));

    QCommandLineParser commandLineParser;
    const QCommandLineOption noGlOption(QStringLiteral("no-gl"), QStringLiteral("Do not output GL information"));
    const QCommandLineOption glExtensionOption(QStringLiteral("gl-extensions"), QStringLiteral("List GL extensions"));
    const QCommandLineOption fontOption(QStringLiteral("fonts"), QStringLiteral("Output list of fonts"));
    commandLineParser.setApplicationDescription(QStringLiteral("Prints diagnostic output about the Qt library."));
    commandLineParser.addOption(noGlOption);
    commandLineParser.addOption(glExtensionOption);
    commandLineParser.addOption(fontOption);
    commandLineParser.addHelpOption();
    commandLineParser.process(app);
    unsigned flags = commandLineParser.isSet(noGlOption) ? 0u : unsigned(QtDiagGl);
    if (commandLineParser.isSet(glExtensionOption))
        flags |= QtDiagGlExtensions;
    if (commandLineParser.isSet(fontOption))
        flags |= QtDiagFonts;

    std::wcout << qtDiag(flags).toStdWString();
    return 0;
}
Example #14
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	QCoreApplication::setApplicationName("empire-gui");

	// Configure parser for command line arguments
	QCommandLineParser parser;
	parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
	parser.addHelpOption();
	QCommandLineOption modeOption("obs", "Start the client as observer.");
	parser.addOption(modeOption);
	QCommandLineOption addressOption("saddr", "Server address.", "port", "localhost");
	parser.addOption(addressOption);
	QCommandLineOption portOption("sport", "Server port.", "port", "0");
	parser.addOption(portOption);

	// Get arguments values
	parser.process(a);

	MainWindow w;

	// Process arguments
	QStringList args = parser.positionalArguments();
	QString address = parser.value("saddr");
	int port = parser.value("sport").toInt();
	w.initialize(address, port, parser.isSet(modeOption));
	w.show();

	return a.exec();
}
Example #15
0
ParsedInfo parse(const QStringList & argv)
{
    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument( "input-files", "list of files to open", "[input files]");
    QCommandLineOption configFileOption(
        { "config", "cfg"}, "config file path", "configFilePath");
    parser.addOption( configFileOption);
    QCommandLineOption htmlPathOption(
        "html", "development option for desktop version, path to html to load", "htmlPath"
                );
    parser.addOption( htmlPathOption);
    QCommandLineOption scriptPortOption(
                "scriptPort", "port on which to listen for scripted commands", "scriptPort");
    parser.addOption( scriptPortOption);

    // Process the actual command line arguments given by the user, exit if
    // command line arguments have a syntax error, or the user asks for -h or -v
    parser.process( argv);

    // try to get config file path from command line
    ParsedInfo info;
    info.m_configFilePath = parser.value( configFileOption);
    // if command line was not used to set the config file path, try environment var
    if( info.m_configFilePath.isEmpty()) {
        info.m_configFilePath = cartaGetEnv( "CONFIG");
    }
    // if the config file was not specified neither through command line or environment
    // assign a default value
    if( info.m_configFilePath.isEmpty()) {
        info.m_configFilePath = QDir::homePath() + "/.cartavis/config.json";
    }


    // get html path
    if( parser.isSet( htmlPathOption)) {
        info.m_htmlPath = parser.value( htmlPathOption);
    }


    // get script port
    if( parser.isSet( scriptPortOption)) {
        QString portString = parser.value( scriptPortOption);
        bool ok;
        info.m_scriptPort = portString.toInt( & ok);
        if( ! ok || info.m_scriptPort < 0 || info.m_scriptPort > 65535) {
            parser.showHelp( -1);
        }

    }
    qDebug() << "script port=" << info.scriptPort();

    // get a list of files to open
    info.m_fileList = parser.positionalArguments();
    qDebug() << "list of files to open:" << info.m_fileList;

    return info;
}
Example #16
0
CommandLineParameters parseCommandLine(const QStringList &arguments)
{
    QCommandLineParser parser;
    parser.setApplicationDescription(QObject::tr("Zeal - Offline documentation browser."));
    parser.addHelpOption();
    parser.addVersionOption();

    /// TODO: [Qt 5.4] parser.addOption({{"f", "force"}, "Force the application run."});
    parser.addOption(QCommandLineOption({QStringLiteral("f"), QStringLiteral("force")},
                                        QObject::tr("Force the application run.")));
    /// TODO: [0.2.0] Remove --query support
    parser.addOption(QCommandLineOption({QStringLiteral("q"), QStringLiteral("query")},
                                        QObject::tr("[DEPRECATED] Query <search term>."),
                                        QStringLiteral("term")));
#ifdef Q_OS_WIN32
    parser.addOption(QCommandLineOption({QStringLiteral("register")},
                                        QObject::tr("Register protocol handlers")));
    parser.addOption(QCommandLineOption({QStringLiteral("unregister")},
                                        QObject::tr("Unregister protocol handlers")));
#endif
    parser.addPositionalArgument(QStringLiteral("url"), QObject::tr("dash[-plugin]:// URL"));
    parser.process(arguments);

    CommandLineParameters clParams;
    clParams.force = parser.isSet(QStringLiteral("force"));

#ifdef Q_OS_WIN32
    clParams.registerProtocolHandlers = parser.isSet(QStringLiteral("register"));
    clParams.unregisterProtocolHandlers = parser.isSet(QStringLiteral("unregister"));

    if (clParams.registerProtocolHandlers && clParams.unregisterProtocolHandlers) {
        QTextStream(stderr) << QObject::tr("Parameter conflict: --register and --unregister.\n");
        ::exit(EXIT_FAILURE);
    }
#endif

    if (parser.isSet(QStringLiteral("query"))) {
        clParams.query.setQuery(parser.value(QStringLiteral("query")));
    } else {
        /// TODO: Support dash-feed:// protocol
        const QString arg
                = QUrl::fromPercentEncoding(parser.positionalArguments().value(0).toUtf8());
        if (arg.startsWith(QLatin1String("dash:"))) {
            clParams.query.setQuery(stripParameterUrl(arg, QStringLiteral("dash")));
        } else if (arg.startsWith(QLatin1String("dash-plugin:"))) {
            const QUrlQuery urlQuery(stripParameterUrl(arg, QStringLiteral("dash-plugin")));
            const QString keys = urlQuery.queryItemValue(QStringLiteral("keys"));
            if (!keys.isEmpty())
                clParams.query.setKeywords(keys.split(QLatin1Char(',')));
            clParams.query.setQuery(urlQuery.queryItemValue(QStringLiteral("query")));
        } else {
            clParams.query.setQuery(arg);
        }
    }

    return clParams;
}
Example #17
0
void SetupEvents::addOptions(QCommandLineParser &clp)
{
// Squirrel for Windows event handlers
    clp.addOption(cloInstall);
    clp.addOption(cloFirstRun);
    clp.addOption(cloUpdated);
    clp.addOption(cloObsolete);
    clp.addOption(cloUninstall);
}
Example #18
0
File: main.cpp Project: KDE/okular
int main(int argc, char** argv)
{
    QApplication app(argc, argv);

    KLocalizedString::setApplicationDomain("okular");

    KAboutData aboutData = okularAboutData();

    app.setApplicationName(aboutData.applicationData().componentName());
    app.setApplicationDisplayName(aboutData.applicationData().displayName());
    app.setApplicationVersion(aboutData.version());
    app.setOrganizationDomain(QStringLiteral("kde.org"));

    QCommandLineParser parser;
    KAboutData::setApplicationData(aboutData);
    // The KDE4 version accepted flags such as -unique with a single dash -> preserve compatibility
    parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
    parser.addVersionOption();
    parser.addHelpOption();
    aboutData.setupCommandLine(&parser);

    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("p") << QStringLiteral("page"), i18n("Page of the document to be shown"), QStringLiteral("number")));
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("presentation"), i18n("Start the document in presentation mode")));
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("print"), i18n("Start with print dialog")));
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("unique"), i18n("\"Unique instance\" control")));
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("noraise"), i18n("Not raise window")));
    parser.addPositionalArgument(QStringLiteral("urls"), i18n("Documents to open. Specify '-' to read from stdin."));

    parser.process(app);
    aboutData.processCommandLine(&parser);

    // see if we are starting with session management
    if (app.isSessionRestored())
    {
        kRestoreMainWindows<Shell>();
    }
    else
    {
        // no session.. just start up normally
        QStringList paths;
        for ( int i = 0; i < parser.positionalArguments().count(); ++i )
            paths << parser.positionalArguments().at(i);
        Okular::Status status = Okular::main(paths, ShellUtils::serializeOptions(parser));
        switch (status)
        {
            case Okular::Error:
                return -1;
            case Okular::AttachedOtherProcess:
                return 0;
            case Okular::Success:
                // Do nothing
                break;
        }
    }

    return app.exec();
}
Example #19
0
Options::Options(const QStringList &arguments)
    : m_command(NO_COMMAND)
    , m_batteryThreshold(DEFAULT_BATTERY_THRESHOLD)
    , m_allocationThreshold(DEFAULT_ALLOCATION_TRESHOLD)
{
    QCommandLineParser parser;
    parser.addPositionalArgument("command",
                                 "One of the commands: server, balance, allocation");
    QCommandLineOption batteryThreshold("b",
                                        "Required battery threshold for balancing (10 - 100).",
                                        "battery threshold",
                                        QString::number(DEFAULT_BATTERY_THRESHOLD));
    parser.addOption(batteryThreshold);
    QCommandLineOption allocationThreshold("a",
                                           "Required filesystem allocation threshold for balancing (0 - 100). "
                                           "If given, balancing will stop once the threshold has been reached.",
                                           "allocation threshold",
                                           QString::number(DEFAULT_ALLOCATION_TRESHOLD));
    parser.addOption(allocationThreshold);
    parser.addHelpOption();

    parser.process(arguments);

    const QStringList positionalArgs = parser.positionalArguments();
    if (positionalArgs.size() > 0) {
        if (positionalArgs.at(0) == "server") {
            m_command = SERVER;
        } else if (positionalArgs.at(0) == "balance") {
            m_command = BALANCE;
        } else if (positionalArgs.at(0) == "allocation") {
            m_command = ALLOCATION;
        } else {
            parser.showHelp(1);
        }
    } else {
        parser.showHelp(1);
    }

    if (parser.isSet(batteryThreshold)) {
        bool ok = true;
        m_batteryThreshold = parser.value(batteryThreshold).toInt(&ok);
        if (!ok || m_batteryThreshold < 10 || m_batteryThreshold > 100) {
            std::cerr << "Battery threshold must be between 10 and 100."
                      << std::endl;
        }
    }

    if (parser.isSet(allocationThreshold)) {
        bool ok = true;
        m_allocationThreshold = parser.value(allocationThreshold).toInt(&ok);
        if (!ok || m_allocationThreshold < 0 || m_allocationThreshold > 100) {
            std::cerr << "Allocation threshold must be between 0 and 100."
                      << std::endl;
        }
    }
}
Example #20
0
CommandLineParseResult parseCommandLine(QCommandLineParser &parser, DnsQuery *query, QString *errorMessage)
{
    parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
    const QCommandLineOption nameServerOption("n", "The name server to use.", "nameserver");
    parser.addOption(nameServerOption);
    const QCommandLineOption typeOption("t", "The lookup type.", "type");
    parser.addOption(typeOption);
    parser.addPositionalArgument("name", "The name to look up.");
    const QCommandLineOption helpOption = parser.addHelpOption();
    const QCommandLineOption versionOption = parser.addVersionOption();

    if (!parser.parse(QCoreApplication::arguments())) {
        *errorMessage = parser.errorText();
        return CommandLineError;
    }

    if (parser.isSet(versionOption))
        return CommandLineVersionRequested;

    if (parser.isSet(helpOption))
        return CommandLineHelpRequested;

    if (parser.isSet(nameServerOption)) {
        const QString nameserver = parser.value(nameServerOption);
        query->nameServer = QHostAddress(nameserver);
        if (query->nameServer.isNull() || query->nameServer.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) {
            *errorMessage = "Bad nameserver address: " + nameserver;
            return CommandLineError;
        }
    }

    if (parser.isSet(typeOption)) {
        const QString typeParameter = parser.value(typeOption);
        const int type = typeFromParameter(typeParameter.toLower());
        if (type < 0) {
            *errorMessage = "Bad record type: " + typeParameter;
            return CommandLineError;
        }
        query->type = static_cast<QDnsLookup::Type>(type);
    }

    const QStringList positionalArguments = parser.positionalArguments();
    if (positionalArguments.isEmpty()) {
        *errorMessage = "Argument 'name' missing.";
        return CommandLineError;
    }
    if (positionalArguments.size() > 1) {
        *errorMessage = "Several 'name' arguments specified.";
        return CommandLineError;
    }
    query->name = positionalArguments.first();

    return CommandLineOk;
}
/******************************************************************************
* Registers plugin-specific command line options.
******************************************************************************/
void ScriptAutostarter::registerCommandLineOptions(QCommandLineParser& cmdLineParser)
{
	// Register the --script command line option.
	cmdLineParser.addOption(QCommandLineOption("script", tr("Runs a Python script file."), tr("FILE")));

	// Register the --scriptarg command line option.
	cmdLineParser.addOption(QCommandLineOption("scriptarg", tr("Passes a command line option to the Python script."), tr("ARG")));

	// Register the --exec command line option.
	cmdLineParser.addOption(QCommandLineOption("exec", tr("Executes a single Python statement."), tr("CMD")));
}
Example #22
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QCoreApplication::setApplicationName("2D-model");
	QCoreApplication::setApplicationVersion("1.0");
	setDefaultLocale();

	QCommandLineParser parser;
	parser.setApplicationDescription(description);
	parser.addHelpOption();
	parser.addVersionOption();
	parser.addPositionalArgument("qrs-file", QObject::tr("Save file to be interpreted."));
	QCommandLineOption backgroundOption({"b", "background"}, QObject::tr("Run emulation in background."));
	QCommandLineOption platformOption("platform"
			, QObject::tr("Use this option set to \"minimal\" to disable connection to X server"), "minimal");
	QCommandLineOption reportOption("report", QObject::tr("A path to file where checker results will be written (JSON)")
			, "path-to-report", "report.json");
	QCommandLineOption trajectoryOption("trajectory", QObject::tr("A path to file where robot`s trajectory will be"\
				" written. The writing will not be performed not immediately, each trajectory point will be written"\
				" just when obtained by checker, so FIFOs are recommended to be targets for this option.")
			, "path-to-trajectory", "trajectory.fifo");
	parser.addOption(backgroundOption);
	parser.addOption(platformOption);
	parser.addOption(reportOption);
	parser.addOption(trajectoryOption);

	qsrand(time(0));
	initLogging();
	QLOG_INFO() << "------------------- APPLICATION STARTED --------------------";
	QLOG_INFO() << "Running on" << qReal::PlatformInfo::prettyOsVersion();
	QLOG_INFO() << "Arguments:" << app.arguments();
	QLOG_INFO() << "Setting default locale to" << QLocale().name();

	parser.process(app);

	const QStringList positionalArgs = parser.positionalArguments();
	if (positionalArgs.size() != 1) {
		parser.showHelp();
	}

	const QString qrsFile = positionalArgs.first();
	const bool backgroundMode = parser.isSet(backgroundOption);
	const QString report = parser.isSet(reportOption) ? parser.value(reportOption) : QString();
	const QString trajectory = parser.isSet(trajectoryOption) ? parser.value(trajectoryOption) : QString();
	twoDModel::Runner runner(report, trajectory);
	if (!runner.interpret(qrsFile, backgroundMode)) {
		return 2;
	}

	const int exitCode = app.exec();
	QLOG_INFO() << "------------------- APPLICATION FINISHED -------------------";
	return exitCode;
}
Example #23
0
/**
* The function main marks the entry point of the program.
* By default, main has the storage class extern.
*
* @param [in] argc (argument count) is an integer that indicates how many arguments were entered on the command line when the program was started.
* @param [in] argv (argument vector) is an array of pointers to arrays of character objects. The array objects are null-terminated strings, representing the arguments that were entered on the command line when the program was started.
* @return the value that was set to exit() (which is 0 if exit() is called via quit()).
*/
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // Command Line Parser
    QCommandLineParser parser;
    parser.setApplicationDescription("Read Evoked Example");
    parser.addHelpOption();

    QCommandLineOption evokedFileOption("ave", "Path to the evoked/average <file>.", "file", "./MNE-sample-data/MEG/sample/sample_audvis-ave.fif");
    QCommandLineOption evokedIdxOption("aveIdx", "The average <index> to choose from the average file.", "index", "2");
    QCommandLineOption useCTFCompOption("useCTFComp", "Use the CTF compensator, if available.");

    parser.addOption(evokedFileOption);
    parser.addOption(evokedIdxOption);

    parser.process(a);

    //generate FiffEvoked object
    QFile t_sampleFile(parser.value(evokedFileOption));
    FiffEvoked p_FiffEvoked(t_sampleFile,QVariant(parser.value(evokedIdxOption)));

    //Select the head coordinate system
    bool use_ctf_head = parser.isSet(useCTFCompOption);
    FiffCoordTrans meg_trans;

    if(use_ctf_head) {
        if(p_FiffEvoked.info.ctf_head_t.isEmpty())
           std::cout << "\nNo CTF head transformation available" << std::endl;
        else {
            meg_trans = p_FiffEvoked.info.dev_ctf_t;
            FiffCoordTrans eeg_trans(meg_trans);
            eeg_trans.invert_transform();
            std::cout << "Employing the CTF/4D head coordinate system\n" << std::endl;
        }
    }
    else {
        meg_trans = p_FiffEvoked.info.dev_head_t;
        FiffCoordTrans eeg_trans;
        std::cout << "Employing the Neuromag head coordinate system\n" << std::endl;
    }

    //Transform coil and electrode locations to the desired coordinate frame
    //ToDo: MATLAB root fct fiff_transform_meg_chs and fiff_transform_eeg_chs needs to be implemented

    //Create the coil definitions
    //ToDo: MATLAB root fct mne_add_coil_defs needs to be implemented

    //N.B. If a nonstandard (in MNE sense) coil def file is used, do
    //ToDo: MATLAB root fct mne_load_coil_def, mne_add_coil_defs needs to be implemented

    return a.exec();
}
Example #24
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    // TODO: separate to module based on Server Configurator App
    // with options to turn on/off components/etc
    QCommandLineParser parser;
    parser.setApplicationDescription("SemIoT gateway");
    parser.addHelpOption();
    // TODO: miltiple devices
    QCommandLineOption dbgOption(QStringList() << "d" << "debug", QCoreApplication::translate("main", "Debug output [default: off]."));
    parser.addOption(dbgOption);
    // TODO: get rid of magic default port:
    QCommandLineOption portOption(QStringList() << "p" << "port", QCoreApplication::translate("main", "Port for gateway server [default: 57864]."), QCoreApplication::translate("main", "port"), QLatin1Literal("57864"));
    parser.addOption(portOption);
    parser.process(a);
    bool debug = parser.isSet(dbgOption);
    Q_UNUSED(debug); //TODO
    int port = parser.value(portOption).toInt();
    // Internal part
    //DataServer dataServer;
    //DevicesConfigsLoader devicesConfigsLoader;
    FrontModuleManager fMM(&a);
    // External Part
    WebSocketServer wsServer(port,&a);
    HttpServer httpServer(&a);
    fMM.connectFrontModule((FrontModule*)&wsServer);
    fMM.connectFrontModule((FrontModule*)&httpServer);
    //wsServer.setDataServer(&dataServer);
    //httpServer.setDataServer(&dataServer);
    // FIXME: for all the protocols
    /*
    QObject::connect(&devicesConfigsLoader,SIGNAL(newDataReady(QString,QString)),&wsServer,SLOT(processNewData(QString,QString)));
    QObject::connect(&httpServer,SIGNAL(newRequestReceived(QVariant)),&devicesConfigsLoader,SIGNAL(newRequestReceived(QVariant)));
    QObject::connect(&httpServer,SIGNAL(addDeviceDriverFromUrl(QUrl)),&devicesConfigsLoader,SLOT(addConfig(QUrl)));
    */
    // TODO: linux kernel driver
    // TODO: dbus
    // TODO: systemd?
    /*
    monarch::data::json::JsonLd jsonld();

    monarch::rt::DynamicObject input;
    QFile file("infile");
    file.open(QIODevice::ReadOnly);
    QByteArray ba(file.readAll());

    monarch::rt::DynamicObject options;
    monarch::rt::DynamicObject output;
    jsonld().fromRdf(input,options,output);
    */
    return a.exec();
}
Example #25
0
int main(int argc, char *argv[])
{
	Q_INIT_RESOURCE(resources);

// Enable high-DPI scaling with Qt 5.6+
#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
	QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
	
	QApplication app(argc, argv);	
	app.setOrganizationName(APPINFO::organization);
	app.setOrganizationDomain(APPINFO::oranizationDomain);
	app.setApplicationName(APPINFO::name);
	app.setApplicationVersion(APPINFO::version);

	QCommandLineParser parser;

	QCommandLineOption addTestsOption(QStringList() << "a" << "add", "Add tests executables (comma separated)", "tests", "");
	QCommandLineOption resetOption(QStringList() << "r" << "reset", "Reset gtest-runner to it's original factory settings. This removes all tests and test data.");

	parser.setApplicationDescription("An automated test runner and user interface for google test unit tests.");
	auto helpOption = parser.addHelpOption();
	auto versionOption = parser.addVersionOption();
	parser.addOption(addTestsOption);
	parser.addOption(resetOption);
	
	parser.process(app);

	if (parser.isSet(helpOption))
	{
		parser.showHelp();
		exit(0);
	}

	if (parser.isSet(versionOption))
	{
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
		parser.showVersion();
#else
		qDebug() << "gtest-runner" << APPINFO::version;
#endif
		exit(0);
	}

	bool reset = parser.isSet(resetOption);
	QStringList tests = parser.value(addTestsOption).split(',');

	MainWindow mainWin(tests, reset);
	mainWin.show();
	return app.exec();
}
Example #26
0
QCommandLineParser* Application::getParser() const
{
	QCommandLineParser *parser = new QCommandLineParser();
	parser->addHelpOption();
	parser->addVersionOption();
	parser->addPositionalArgument("url", QCoreApplication::translate("main", "URL to open"), QLatin1String("[url]"));
	parser->addOption(QCommandLineOption(QLatin1String("cache"), QCoreApplication::translate("main", "Uses <path> as cache directory"), QLatin1String("path"), QString()));
	parser->addOption(QCommandLineOption(QLatin1String("profile"), QCoreApplication::translate("main", "Uses <path> as profile directory"), QLatin1String("path"), QString()));
	parser->addOption(QCommandLineOption(QLatin1String("session"), QCoreApplication::translate("main", "Restores session <session> if it exists"), QLatin1String("session"), QString()));
	parser->addOption(QCommandLineOption(QLatin1String("privatesession"), QCoreApplication::translate("main", "Starts private session")));
	parser->addOption(QCommandLineOption(QLatin1String("portable"), QCoreApplication::translate("main", "Sets profile and cache paths to directories inside the same directory as that of application binary")));

	return parser;
}
Example #27
0
int main(int argc, char ** argv)
{
    QUrl source("qrc:view.qml");

    QGuiApplication app(argc, argv);

    QCommandLineParser parser;
#if QT_CONFIG(networkproxy)
    QCommandLineOption proxyHostOption("host", "The proxy host to use.", "host");
    parser.addOption(proxyHostOption);
    QCommandLineOption proxyPortOption("port", "The proxy port to use.", "port", "0");
    parser.addOption(proxyPortOption);
#endif // networkproxy
    parser.addPositionalArgument("file", "The file to use.");
    QCommandLineOption helpOption = parser.addHelpOption();
    parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
    QStringList arguments = QCoreApplication::arguments();
    if (!parser.parse(arguments)) {
        qWarning() << parser.helpText() << '\n' << parser.errorText();
        exit(1);
    }
    if (parser.isSet(helpOption)) {
        qWarning() << parser.helpText();
        exit(0);
    }
#if QT_CONFIG(networkproxy)
    if (parser.isSet(proxyHostOption))
        proxyHost = parser.value(proxyHostOption);
    if (parser.isSet(proxyPortOption)) {
        bool ok = true;
        proxyPort = parser.value(proxyPortOption).toInt(&ok);
        if (!ok || proxyPort < 1 || proxyPort > 65535) {
            qWarning() << parser.helpText() << "\nNo valid port given. It should\
                          be a number between 1 and 65535";
            exit(1);
        }
    }
#endif // networkproxy
    if (parser.positionalArguments().count() == 1)
        source = QUrl::fromLocalFile(parser.positionalArguments().first());

    QQuickView view;
    view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory);

    view.setSource(source);
    view.show();

    return app.exec();
}
Example #28
0
int main(int argc, char * argv[])
{
    QCoreApplication a(argc, argv);

    // Build the command-line options
    QCommandLineParser parser;
    QCommandLineOption addressOption(
        QStringList() << "a" << "address",
        "address to bind to",
        "address",
        "127.0.0.1"
    );
    parser.addOption(addressOption);
    QCommandLineOption portOption(
        QStringList() << "p" << "port",
        "port to listen on",
        "port",
        "8000"
    );
    parser.addOption(portOption);
    QCommandLineOption dirOption(
        QStringList() << "d" << "directory",
        "directory to serve",
        "directory",
        QDir::homePath()
    );
    parser.addOption(dirOption);
    parser.addHelpOption();

    // Parse the options that were provided
    parser.process(a);

    // Obtain the values
    QHostAddress address = QHostAddress(parser.value(addressOption));
    quint16 port = parser.value(portOption).toInt();
    QString dir = parser.value(dirOption);

    // Create the filesystem handler and server
    QFilesystemHandler handler(dir);
    QHttpServer server(&handler);

    // Attempt to listen on the specified port
    if(!server.listen(address, port)) {
        qCritical("Unable to listen on the specified port.");
        return 1;
    }

    return a.exec();
}
Example #29
0
int main(int argc, char *argv[])
{
    // Install the custom handler
    qInstallMessageHandler(messageOutput);

    QApplication app(argc, argv);
    QCoreApplication::setApplicationName(APPLICATION_NAME);
    QCoreApplication::setOrganizationName(APPLICATION_NAME);
    QCoreApplication::setApplicationVersion("0.0.1-alpha");

    // Load default Qt translations
    const QString locale = QLocale::system().name().section('_', 0, 0);
    QTranslator qtTranslator;
    qtTranslator.load(QStringLiteral("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    app.installTranslator(&qtTranslator);

    // Load translations in the "translations" dir
    loadTranslations(QCoreApplication::applicationDirPath() + QStringLiteral("/translations"), locale, &app);

    // Check the parameters
    QCommandLineParser parser;
    parser.setApplicationDescription(QCoreApplication::tr("Simple application that allow the control of an Android VR app with the Bluetooth and a 3D depth sensor."));
    parser.addHelpOption();
    parser.addVersionOption();

    parser.addOption(QCommandLineOption({"a", "auto-start"}, QCoreApplication::translate("options", "Auto start the bluetooth listening (don't wait for the user click).")));
    parser.addOption(QCommandLineOption({"c", "controller"}, QCoreApplication::translate("options", "The controller <controller-name> will be used."), QCoreApplication::translate("options", "controller-name")));
    parser.addOption(QCommandLineOption({"p", "port"}, QCoreApplication::translate("options", "The Bluetooth engine will listen on the specified <port-number>. The <port-number> must be in range 1-30. Set to 0 if you want to select the first available."), QCoreApplication::translate("options", "port-number")));
    parser.addOption(QCommandLineOption({"f", "frequency"}, QCoreApplication::translate("options", "Frequency for emitting data to the bluetooth device (number of data per second)"), QCoreApplication::translate("options", "number-per-second")));
    parser.addOption(QCommandLineOption("nologwidget", QCoreApplication::translate("options", "Don't show the log console in the bottom of the window.")));

    parser.process(app);

    const bool useLogWidget = !parser.isSet("nologwidget");
    if(useLogWidget)
        globalLogBrowser = new LogBrowser();

    MainWindow window(globalLogBrowser, parser.isSet("auto-start"), parser.value("controller"), intFromParser(parser, "port"), intFromParser(parser, "frequency"));
    window.show();

    // Execute the main loop
    const int result = app.exec();

    // Delete the log browser if needed
    if(useLogWidget)
        delete globalLogBrowser;

    return result;
}
Example #30
0
int main(int argc, char *argv[]) {
	QCoreApplication app(argc, argv);

	QCoreApplication::setOrganizationName("drawpile");
	QCoreApplication::setOrganizationDomain("drawpile.net");
	QCoreApplication::setApplicationName("dprectool");
	QCoreApplication::setApplicationVersion(DRAWPILE_VERSION);

	// Set up command line arguments
	QCommandLineParser parser;

	parser.setApplicationDescription("Convert Drawpile recordings between text and binary formats");
	parser.addHelpOption();

	// --version, -v
	QCommandLineOption versionOption(QStringList() << "v" << "version", "Displays version information.");
	parser.addOption(versionOption);

	// --out, -o
	QCommandLineOption outOption(QStringList() << "o" << "out", "Output file", "output");
	parser.addOption(outOption);

	// --format, -f
	QCommandLineOption formatOption(QStringList() << "f" << "format", "Output format (binary/text)", "format");
	parser.addOption(formatOption);

	// input file name
	parser.addPositionalArgument("input", "recording file", "<input.dprec>");

	// Parse
	parser.process(app);

	if(parser.isSet(versionOption)) {
		printVersion();
		return 0;
	}

	QStringList inputfiles = parser.positionalArguments();
	if(inputfiles.isEmpty()) {
		parser.showHelp(1);
		return 1;
	}

	if(!convertRecording(inputfiles.at(0), parser.value(outOption), parser.value(formatOption)))
		return 1;

	return 0;
}