コード例 #1
0
ファイル: main.cpp プロジェクト: crayonink/calligra-2
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();
}
コード例 #2
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();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: 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();
}
コード例 #4
0
ファイル: app.cpp プロジェクト: akhilo/cmplayer
	void addOption(LineCmd cmd, const QStringList &names, const QString desc, const char *valueName = "", const QString &def = QString()) {
		const QLatin1String vname = _L(valueName);
		if (desc.contains(_L("%1")))
			options.insert(cmd, QCommandLineOption(names, desc.arg(_L('<') % vname % _L('>')), vname, def));
		else
			options.insert(cmd, QCommandLineOption(names, desc, vname, def));
	}
コード例 #5
0
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());
}
コード例 #6
0
ファイル: test.cpp プロジェクト: cmacq2/plasma-workspace
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 ); */
}
コード例 #7
0
ファイル: main.cpp プロジェクト: 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();
}
コード例 #8
0
ファイル: main.cpp プロジェクト: haugerbr/zeal
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;
}
コード例 #9
0
/******************************************************************************
* 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")));
}
コード例 #10
0
ファイル: showcommand.cpp プロジェクト: 02JanDal/soqute
void ShowCommand::setupParser()
{
	parser = new QCommandLineParser();
	parser->setApplicationDescription(tr("Shows information about a package"));
	parser->addVersionOption();
	parser->addHelpOption();
	parser->addPositionalArgument(tr("package identifer"), tr("The identifier of the package"),
								  tr("<package-name>[/<version>][#<target>]"));
	parser->addOption(QCommandLineOption(
		QStringList() << "nativeDependencies",
		tr("Only outputs the native packages for piping to the package manager"),
		tr("package-manager"), configHandler->packageManager()));
	parser->addOption(QCommandLineOption("host", tr("Show packages for the <platform> instead of the current platform"), tr("platform"), Util::currentPlatform().toString()));
}
コード例 #11
0
ファイル: Application.cpp プロジェクト: AlexTalker/otter
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;
}
コード例 #12
0
ファイル: main.cpp プロジェクト: VirtualWalker/VRController
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;
}
コード例 #13
0
void tst_QCommandLineParser::testInvalidOptions()
{
    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    QTest::ignoreMessage(QtWarningMsg, "QCommandLineOption: Option names cannot start with a '-'");
    parser.addOption(QCommandLineOption(QStringLiteral("-v"), QStringLiteral("Displays version information.")));
}
コード例 #14
0
void Qt5CliParser::addArgument(const QString &longName, const AbstractCliParser::CliParserArg &arg)
{
    QStringList names(longName);
    if (arg.shortName != 0)
        names << QString(arg.shortName);

    switch(arg.type) {
    case CliParserArg::CliArgSwitch:
        _qCliParser.addOption(QCommandLineOption(names, arg.help));
        break;
    case CliParserArg::CliArgOption:
        _qCliParser.addOption(QCommandLineOption(names, arg.help, arg.valueName, arg.def));
        break;
    default:
        qWarning() << "Warning: Unrecognized argument:" << longName;
    }
}
コード例 #15
0
ファイル: Config.cpp プロジェクト: jotrk/quadro
QCommandLineOption
Config::makeOption(QStringList & list, const char * description, const char * valueName)
{
    return QCommandLineOption(
               list,
               QCoreApplication::translate("main", description),
               QCoreApplication::translate("main", valueName));
}
コード例 #16
0
void tst_QCommandLineParser::testMissingOptionValue()
{
    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    parser.addOption(QCommandLineOption(QStringLiteral("option"), QStringLiteral("An option"), "value"));
    QVERIFY(!parser.parse(QStringList() << "argv0" << "--option")); // the user forgot to pass a value for --option
    QCOMPARE(parser.value("option"), QString());
    QCOMPARE(parser.errorText(), QString("Missing value after '--option'."));
}
コード例 #17
0
ファイル: main.cpp プロジェクト: stepanmracek/icrc
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QCommandLineParser parser;
    parser.addOption(QCommandLineOption("directory", "Directory containing video files", "directory"));
    parser.addOption(QCommandLineOption("model", "Left Vebtricle model file", "model"));
    parser.addHelpOption();
    parser.process(app);
    
    QString directory, model;
    if (!parser.isSet("directory"))
        directory = QFileDialog::getExistingDirectory(0, "Select directory containing videos");
    else
        directory = parser.value("directory");
    
    if (!parser.isSet("model"))
        model = QFileDialog::getOpenFileName(0, "Select model");
    else
        model = parser.value("model");
    
    if (directory.isEmpty() || directory.isNull() || model.isEmpty() || model.isNull()) return 0;
    
    PCA *pca = new PCA();
    StatisticalShapeModel *shapeModel = new StatisticalShapeModel(pca);
    ShapeNormalizerBase *normalizer = new ShapeNormalizerIterativeStatisticalShape(shapeModel);
    LongitudinalStrain *strain = new LongitudinalStrain(normalizer, 0, 0);

    cv::FileStorage strainStorage(model.toStdString(), cv::FileStorage::READ);
    //cv::FileStorage strainStorage("potkani", cv::FileStorage::READ);
    strain->deserialize(strainStorage);

    ListOfImageProcessing processing;
    StrainResultProcessingBase *postProcessing = new StrainResProcFloatingAvg(3);
    PointTrackerBase *pointTracker = new PointTrackerOpticalFlow(21);
    VectorF weights; weights.push_back(1.0f);
    ShapeTracker *tracker = new ShapeTracker(strain, processing, pointTracker, postProcessing, weights);

    qDebug() << "Tracker initializated";

    // create GUI
    WindowAnotationManager w(directory, tracker);
    w.show();
    return app.exec();
}
コード例 #18
0
ファイル: main.cpp プロジェクト: hbirchtree/jason
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QApplication::setApplicationName("Jason");
    QApplication::setApplicationVersion("1.0");

    //Parse the command line
    QCommandLineParser cParse;
    cParse.setApplicationDescription("Jason launcher");
    cParse.addHelpOption();
    cParse.addPositionalArgument("file",QApplication::translate("init","File to open"));
    QCommandLineOption desktopAction = QCommandLineOption("action",QApplication::translate("init","Action within the Jason document to launch"),"action","");
    QCommandLineOption desktopGen = QCommandLineOption("desktop-file-generate",QApplication::translate("init","Create a desktop file"),"desktop-file-generate","");
    desktopAction.setValueName("action");
    desktopGen.setValueName(QApplication::translate("init","output %1 file").arg(".desktop"));
    cParse.addOption(desktopAction);
    cParse.addOption(desktopGen);
    //Actual processing
    cParse.process(a);

    //Required arguments
    QStringList posArgs = cParse.positionalArguments();
    QString filename;
    if (posArgs.length()>=1){
        filename = posArgs[0];
    }else
        return 0;

    //Optional arguments
    QStringList options = cParse.optionNames();
    QString actionToLaunch;
    QString desktopFile;
    foreach(QString option, options){
        if(option=="action")
            actionToLaunch = cParse.value(option);
        if(option=="desktop-file-generate")
            desktopFile = cParse.value(option);
    }

    JasonGui jasongui;
    jasongui.startParse(filename,actionToLaunch,desktopFile,a.arguments()[0]);

    return 0;
}
コード例 #19
0
void tst_QCommandLineParser::testProcessNotCalled()
{
    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("b"), QStringLiteral("a boolean option"))));
    QTest::ignoreMessage(QtWarningMsg, "QCommandLineParser: call process() or parse() before isSet");
    QVERIFY(!parser.isSet("b"));
    QTest::ignoreMessage(QtWarningMsg, "QCommandLineParser: call process() or parse() before values");
    QCOMPARE(parser.values("b"), QStringList());
}
コード例 #20
0
ファイル: main.cpp プロジェクト: emmanuel099/kio
int main( int argc, char **argv )
{
    QApplication app( argc, argv);
    KAboutData aboutData( QStringLiteral("kioexec"), i18n("KIOExec"), KIO_VERSION_STRING,
         i18n(description), KAboutLicense::GPL,
         i18n("(c) 1998-2000,2003 The KFM/Konqueror Developers"));
    aboutData.addAuthor(i18n("David Faure"),QString(), QStringLiteral("*****@*****.**"));
    aboutData.addAuthor(i18n("Stephan Kulow"),QString(), QStringLiteral("*****@*****.**"));
    aboutData.addAuthor(i18n("Bernhard Rosenkraenzer"),QString(), QStringLiteral("*****@*****.**"));
    aboutData.addAuthor(i18n("Waldo Bastian"),QString(), QStringLiteral("*****@*****.**"));
    aboutData.addAuthor(i18n("Oswald Buddenhagen"),QString(), QStringLiteral("*****@*****.**"));
    KAboutData::setApplicationData(aboutData);
    KDBusService service(KDBusService::Multiple);

    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("tempfiles") , i18n("Treat URLs as local files and delete them afterwards")));
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("suggestedfilename <file name>") , i18n("Suggested file name for the downloaded file")));
    parser.addPositionalArgument(QStringLiteral("command"), i18n("Command to execute"));
    parser.addPositionalArgument(QStringLiteral("urls"), i18n("URL(s) or local file(s) used for 'command'"));

    app.setQuitOnLastWindowClosed(false);

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

    if (parser.positionalArguments().count() < 1) {
        parser.showHelp(-1);
        return -1;
    }

    const bool tempfiles = parser.isSet(QStringLiteral("tempfiles"));
    const QString suggestedfilename = parser.value(QStringLiteral("suggestedfilename"));
    KIOExec exec(parser.positionalArguments(), tempfiles, suggestedfilename);

    // Don't go into the event loop if we already want to exit (#172197)
    if (exec.exited())
        return 0;

    return app.exec();
}
コード例 #21
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(false);
    app.setApplicationName("electric-webview");
    app.setApplicationVersion("1.0");

    QCommandLineParser cmdParser;
    cmdParser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsCompactedShortOptions);
    cmdParser.setApplicationDescription("Electric WebView is a scriptable WebView for developers.");
    cmdParser.addHelpOption();
    cmdParser.addVersionOption();
    cmdParser.addOption(QCommandLineOption(QStringList() << "t" << "transport", "Command Transport Layer to use.", "tcp|unixsocket|websocket"));
    cmdParser.addOption(QCommandLineOption(QStringList() << "r" << "reverse", "Enable reverse mode. The ID is used to identify your session in the server.", "ID"));
    cmdParser.addOption(QCommandLineOption(QStringList() << "s" << "script", "Script to run.", "path"));
    cmdParser.process(app);

    if (cmdParser.value("transport").isEmpty()) {
        qDebug().noquote() << "You must provide a command transport layer";
        return -1;
    }

    CommandServer *commandServer = new CommandServer();
    commandServer->setTransport(cmdParser.value("transport"));
    commandServer->setReverse(cmdParser.isSet("reverse"));
    commandServer->setReverseId(cmdParser.value("reverse"));
    commandServer->initialize();

    QWebEngineView *webView = new QWebEngineView;
    webView->setPage(new WebPage);

    ElectricWebView::instance()->setWebView(webView);

    ElectricWebView::instance()->initialize();

    QObject::connect(commandServer, &CommandServer::newCommand, ElectricWebView::instance()->commandHandler(), &CommandHandler::processCommand);

    if (cmdParser.isSet("script"))
        ElectricWebView::instance()->runScript(cmdParser.value("transport"), cmdParser.value("script"));

    return app.exec();
}
コード例 #22
0
ファイル: cmd.cpp プロジェクト: Elv13/sflphone-kde
///Setup command line options before passing them to the KUniqueApplication
void Cmd::parseCmd(int argc, char **argv, KAboutData& about)
{
   QApplication app(argc, argv);
   QCommandLineParser parser;
   KAboutData::setApplicationData(about);
   parser.addVersionOption();
   parser.addHelpOption();
   //PORTING SCRIPT: adapt aboutdata variable if necessary
   about.setupCommandLine(&parser);
   parser.process(app);
   about.processCommandLine(&parser);

   parser.addOption(QCommandLineOption(QStringList() << QLatin1String("call"), i18n("Place a call to a given number"                                        ), QLatin1String("number"), QLatin1String("")));
   parser.addOption(QCommandLineOption(QStringList() << QLatin1String("text"), i18n("Send a text to &lt;number&gt;, use --message to set the content, then hangup"), QLatin1String("number"), QLatin1String("")));
   parser.addOption(QCommandLineOption(QStringList() << QLatin1String("message"), i18n("Used in combination with --send-text"                                   ), QLatin1String("content"), QLatin1String("")));

//    QCommandLineParser::parsedArgs();

//    KUniqueApplication::addCmdLineOptions();
}
コード例 #23
0
ファイル: main.cpp プロジェクト: JIghtuse/zeal
CommandLineParameters parseCommandLine(const QCoreApplication &app)
{
    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.")));
    parser.addOption(QCommandLineOption({QStringLiteral("q"), QStringLiteral("query")},
                                        QObject::tr("Query <search term>."),
                                        QStringLiteral("term")));
    parser.process(app);

    return {
        parser.isSet(QStringLiteral("force")),
        parser.value(QStringLiteral("query"))
    };
}
コード例 #24
0
ファイル: mainwindow.cpp プロジェクト: KDE/kaffeine
MainWindow::MainWindow(KAboutData *aboutData, QCommandLineParser *parser)
{
	this->aboutData = aboutData;
	this->parser = parser;

	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("d") << QLatin1String("debug"), i18n("Enable debug messages")));
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("tempfile"), i18n("The files/URLs opened by the application will be deleted after use")));
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("f") << QLatin1String("fullscreen"), i18n("Start in full screen mode")));
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("audiocd"), i18n("Play Audio CD")));
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("videocd"), i18n("Play Video CD")));
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("dvd"), i18n("Play DVD")));

#if HAVE_DVB == 1
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("dumpdvb"), i18nc("command line option", "Dump dvb data (debug option)")));
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("channel"), i18nc("command line option", "Play TV channel"), QLatin1String("name / number")));
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("tv"), i18nc("command line option", "(deprecated option)"), QLatin1String("channel")));
	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("lastchannel"), i18nc("command line option", "Play last tuned TV channel")));
#endif
	parser->addPositionalArgument(QLatin1String("[file]"), i18n("Files or URLs to play"));
}
コード例 #25
0
ファイル: main.cpp プロジェクト: KDE/apper
int main(int argc, char** argv)
{
    KLocalizedString::setApplicationDomain("apper");

    KAboutData aboutData("apper-appsetup",
                "apper",
                APPER_VERSION,
                i18n("KDE Application Installer"),
                KAboutLicense::LicenseKey::GPL);

    aboutData.addAuthor(i18nc("@info:credit", "Daniel Nicoletti"), i18n("Developer"),
                        "*****@*****.**");
    aboutData.addAuthor(i18nc("@info:credit", "Matthias Klumpp"), i18n("Developer"),
                        "*****@*****.**");
    aboutData.setProductName("apper/limba");

    QApplication app(argc, argv);
    QCommandLineParser parser;
    KAboutData::setApplicationData(aboutData);
    parser.addVersionOption();
    parser.addHelpOption();
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);
    // Add --verbose as commandline option
    parser.addOption(QCommandLineOption(QStringList() << QLatin1String("verbose"), i18n("Show verbose information")));
    parser.addPositionalArgument(QLatin1String("file"), i18n("IPK package filename"));

    // Set if we are in verbose mode
    li_set_verbose_mode(parser.isSet("verbose"));

    QString fname;
    for(int i = 0; i < parser.positionalArguments().count(); i++) {
        fname = parser.positionalArguments()[i];
        QFileInfo file(fname);
        if (!file.exists())
            fname = "";
        else
            break;
    }
    
    // Check if we have a package
    if (fname.isEmpty()) {
        KMessageBox::sorry (0, i18n("We did not receive a path to an IPK package as parameter."),
                            i18n("Package not found!"));
        return 1;
    }

    // Create & run the setup wizard
    SetupWizard *wizard = new SetupWizard();
    wizard->initialize(fname);
    wizard->show();
    return app.exec();
}
コード例 #26
0
ファイル: removecommand.cpp プロジェクト: 02JanDal/soqute
void RemoveCommand::setupParser()
{
    parser = new QCommandLineParser();
    parser->setApplicationDescription(tr("Removes packages"));
    parser->addVersionOption();
    parser->addHelpOption();
    parser->addOption(QCommandLineOption(
                          QStringList() << "no-platform-behavior",
                          tr("Describes how I should behave if you don't give me a target platform. Possible options: "
                             "host (use the host platform, the default), abort"),
                          tr("behavior"), "host"));
    parser->addOption(QCommandLineOption(
                          QStringList() << "no-version-behavior",
                          tr("Describes how I should behave if you don't give me a version. Possible options: "
                             "clean (removes all except the newest), all (removes all), abort (the default)"),
                          tr("behavior"), "abort"));
    parser->addOption(
        QCommandLineOption(QStringList() << "silent", tr("Won't ask you for questions")));
    parser->addPositionalArgument(tr("package identifiers"),
                                  tr("Identifiers for all packages to remove"),
                                  tr("<package-name>[/<version>][#<target>]*"));
}
コード例 #27
0
void tst_QCommandLineParser::testSingleDashWordOptionModes()
{
    QFETCH(QCommandLineParser::SingleDashWordOptionMode, parsingMode);
    QFETCH(QStringList, commandLine);
    QFETCH(QStringList, expectedOptionNames);
    QFETCH(QStringList, expectedOptionValues);

    commandLine.prepend("tst_QCommandLineParser");

    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    parser.setSingleDashWordOptionMode(parsingMode);
    parser.addOption(QCommandLineOption("a", QStringLiteral("a option.")));
    parser.addOption(QCommandLineOption("b", QStringLiteral("b option.")));
    parser.addOption(QCommandLineOption(QStringList() << "c" << "abc", QStringLiteral("c option."), QStringLiteral("value")));
    parser.addOption(QCommandLineOption("nn", QStringLiteral("nn option.")));
    QVERIFY(parser.parse(commandLine));
    QCOMPARE(parser.optionNames(), expectedOptionNames);
    for (int i = 0; i < expectedOptionValues.count(); ++i)
        QCOMPARE(parser.value(parser.optionNames().at(i)), expectedOptionValues.at(i));
    QCOMPARE(parser.unknownOptionNames(), QStringList());
}
コード例 #28
0
ファイル: splashapp.cpp プロジェクト: cmacq2/plasma-workspace
SplashApp::SplashApp(int &argc, char ** argv)
    : QGuiApplication(argc, argv),
      m_stage(0),
      m_testing(false),
      m_window(false),
      m_startTime(QDateTime::currentDateTime())
{
    QCommandLineParser parser;
    parser.addOption(QCommandLineOption(QStringLiteral("test"), QStringLiteral("Run in test mode")));
    parser.addOption(QCommandLineOption(QStringLiteral("window"), QStringLiteral("Run in windowed mode")));
    parser.addOption(QCommandLineOption(QStringLiteral("nofork"), QStringLiteral("Don't fork")));
    parser.addOption(QCommandLineOption(QStringLiteral("pid"), QStringLiteral("Print the pid of the child process")));
    parser.addHelpOption();

    parser.process(*this);
    m_testing = parser.isSet(QStringLiteral("test"));
    m_window = parser.isSet(QStringLiteral("window"));

    foreach(QScreen* screen, screens())
        adoptScreen(screen);

    setStage(QStringLiteral("initial"));

    QPixmap cursor(32, 32);
    cursor.fill(Qt::transparent);
    setOverrideCursor(QCursor(cursor));

    if (m_testing) {
        m_timer.start(TEST_STEP_INTERVAL, this);
    }

    connect(this, &QGuiApplication::screenAdded, this, &SplashApp::adoptScreen);

    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.registerObject(QStringLiteral("/KSplash"), this, QDBusConnection::ExportScriptableSlots);
    dbus.registerService(QStringLiteral("org.kde.KSplash"));

}
コード例 #29
0
ファイル: main.cpp プロジェクト: caybro/QuickMaps
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    app.setAttribute(Qt::AA_UseHighDpiPixmaps);
    app.setWindowIcon(QIcon(":/osm.png"));
    app.setOrganizationName("KDE");
    app.setOrganizationDomain("kde.org");
    app.setApplicationName("QuickMaps");
    app.setApplicationVersion(VERSION_NUMBER);

    QTranslator appTrans;
    appTrans.load(QStringLiteral(":/translations/quickmaps_") + QLocale::system().name());
    app.installTranslator(&appTrans);

    QCommandLineParser parser;
    parser.setApplicationDescription(QApplication::tr("Simple maps application based on QML") + "\n(c) 2014 Lukáš Tinkl <*****@*****.**>");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addOption(QCommandLineOption("latitude",
                                        QApplication::tr("Latitude to start with, in decimal degrees"),
                                        "latitude"));
    parser.addOption(QCommandLineOption("longitude",
                                        QApplication::tr("Longitude to start with, in decimal degrees"),
                                        "longitude"));
    parser.process(app);

    GeoLocation * loc = new GeoLocation(qApp);

    QQmlApplicationEngine engine;
    engine.rootContext()->setContextProperty("initialLatitude", parser.isSet("latitude") ? parser.value("latitude").toDouble() : 49.6843842);
    engine.rootContext()->setContextProperty("initialLongitude", parser.isSet("longitude") ? parser.value("longitude").toDouble() : 17.2190358);
    engine.rootContext()->setContextProperty("GeoLocation", loc);

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}
コード例 #30
0
void tst_QCommandLineParser::testUnknownOptionErrorHandling()
{
    QFETCH(QCommandLineParser::SingleDashWordOptionMode, parsingMode);
    QFETCH(QStringList, args);
    QFETCH(QStringList, expectedUnknownOptionNames);
    QFETCH(QString, expectedErrorText);

    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    parser.setSingleDashWordOptionMode(parsingMode);
    QVERIFY(parser.addOption(QCommandLineOption(QStringList() << "b" << "bool", QStringLiteral("a boolean option"))));
    QCOMPARE(parser.parse(args), expectedErrorText.isEmpty());
    QCOMPARE(parser.unknownOptionNames(), expectedUnknownOptionNames);
    QCOMPARE(parser.errorText(), expectedErrorText);
}