Example #1
1
bool commandLineArgumentsValid(QStringList *positionalArgs,
                               QStringList *ignoreMasks)
{
  bool result = true;

  QCommandLineParser parser;
  parser.setApplicationDescription("Creates patches");
  parser.addHelpOption();
  parser.addVersionOption();
  parser.addPositionalArgument("old",     QCoreApplication::translate("main", "Path to a directory containing old version of files"));
  parser.addPositionalArgument("new",     QCoreApplication::translate("main", "Path to a directory containing new version of files"));
  parser.addPositionalArgument("result",  QCoreApplication::translate("main", "Path to a directory where resulting patch will be stored"));

  QCommandLineOption ignoreOption(QStringList() << "i" << "ignore",
                                  QCoreApplication::translate("main", "Specifies which file or folder to ignore during comparison. Can be used multiple times. e.g. -i .svn -i *.txt"),
                                  QCoreApplication::translate("main", "mask"));
  parser.addOption(ignoreOption);

  // Process the actual command line arguments given by the user
  parser.process(*qApp);

  *positionalArgs = parser.positionalArguments();
  if (positionalArgs->size() < 3)
  {
    fputs(qPrintable(parser.helpText()), stderr);
    result = false;
  }

  *ignoreMasks = parser.values(ignoreOption);

  return result;
}
Example #2
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QCoreApplication::setApplicationName("armadill");
    QCoreApplication::setApplicationVersion("0.1");

    QCommandLineParser parser;

    parser.setApplicationDescription("armadill- super secure IM");

    parser.addPositionalArgument("server", "Server ip to connect to");
    parser.addPositionalArgument("port", "port of that server");
    parser.addHelpOption();

    QCommandLineOption test(QStringList() << "t" << "test", "Run tests");
    parser.addOption(test);

    parser.process(a);

    if(parser.isSet(test))
    {
        UTest test;
        return test.makeTests(argc, argv);
    }

    //parse things, run test if test
	QTextStream out(stdout);
    ClientConsole n(parser.positionalArguments(), out, &a);
    QMetaObject::invokeMethod(&n, "init", Qt::QueuedConnection);

    return a.exec();
}
Example #3
0
int main(int argc, char **argv) {
	QApplication app(argc, argv);
	QApplication::setApplicationName("ViewDown");
	QApplication::setApplicationVersion("1.0");
	app.setWindowIcon(QIcon("qrc:///viewdown.ico"));

	QCommandLineParser parser;
	parser.setApplicationDescription("Markdown viewer, reloading on changes.");
	parser.addPositionalArgument("file", "markdown file to view and reload on change.");
	parser.addPositionalArgument("watch", "files or directories to watch as trigger for reload.", "[watch...]");
	const QCommandLineOption styleOption("s", "css file to use as stylesheet.", "css");
	parser.addOption(styleOption);
	parser.addHelpOption();
	parser.addVersionOption();

	parser.process(app);

	QUrl styleUrl;
	if (parser.isSet(styleOption)) {
		const QString path = parser.value(styleOption);
		QFileInfo info = QFileInfo(path);
		if (info.exists())
		        styleUrl = QUrl::fromLocalFile(info.canonicalFilePath());
		else
			qWarning("No such file: %s", qPrintable(path));
	}
	if (styleUrl.isEmpty())
		styleUrl = QUrl("qrc:///github.css");

	MainWindow *browser = new MainWindow(parser.positionalArguments(), styleUrl);
	browser->show();
	return app.exec();
}
//! 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 #5
0
void setupCommandLineParser(QCommandLineParser& parser)
{
    parser.setApplicationDescription("Command line tool to validate 1-n XML files against a given schema.");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("schemaFile", "The path to the schema file.");
    parser.addPositionalArgument("xmlFile", "The path to an .xml file");
}
Example #6
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QCoreApplication app(argc, argv);
    QCoreApplication::setApplicationName("evnav-cli");
    QCoreApplication::setApplicationVersion("0.1");

    QCommandLineParser parser;
    parser.setApplicationDescription("electric vehicule trip planner");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("osrm", "path to osrm file");
    parser.addPositionalArgument("charger", "path to json charger file");

    parser.process(app);
    const QStringList args = parser.positionalArguments();

    if (args.size() < 2) {
        qDebug() << "missing arguments";
        parser.showHelp(1);
    }

    qDebug() << "loading street data...";
    Evnav evnav(args.at(0));

    qDebug() << "loading chargers...";
    ChargerProvider provider;
    provider.loadJson(args.at(1));
    ChargerProvider dcfc = provider.filter(provider.fastChargerFilter());
    qDebug() << "fast chargers found:" << dcfc.size();

    evnav.setChargerProvider(&dcfc);
    evnav.initGraph();

    HttpServer httpd;
    EvnavServer handler;
    handler.setEngine(&evnav);

    HttpServerRequestRouter router {
        { QRegularExpression{"^/route/v1/evnav/.*"}, handler },
        { QRegularExpression{",*"}, NotFoundHandler::handler() },
    };

    QObject::connect(&httpd, &HttpServer::requestReady,
        &router, &HttpServerRequestRouter::handleRequest);

    httpd.listen(QHostAddress::Any, 8080);

    return a.exec();
}
Example #7
0
int main(int argc, char *argv[])
{
   QCoreApplication app(argc, argv);
   QCoreApplication::setApplicationName("Find_books");
   QCoreApplication::setApplicationVersion("1.0");

   QCommandLineParser parser;
   parser.addHelpOption();
   parser.addVersionOption();
   parser.setApplicationDescription(QCoreApplication::translate("main","Find books from Gornica.ru."));


   parser.addPositionalArgument("s_file", QCoreApplication::translate("main", "Source file from read."));
   parser.addPositionalArgument("t_delay", QCoreApplication::translate("main", "Delay time."));

   parser.process(app);

   QList<QString> args = parser.positionalArguments();

   d_time=0;


#ifdef Q_OS_WIN32
   QTextCodec::setCodecForLocale(QTextCodec::codecForName("IBM 866"));
#endif

#ifdef Q_OS_LINUX
   QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
#endif
   //QTextStream Qcout(stdout);

   downloader = new Downloader(); // Инициализируем Downloader

   if (((args.size() < 1))) {
      printf("%s\n", qPrintable(QCoreApplication::translate("main", "Error: Must specify one filename argument.")));
      parser.showHelp(1);
   }
   else
   {

      m_File.append(args.value(0));
      d_time = args.value(1,"8000").toInt();
      m_CreateLists(m_File);
   }

   qDebug()  <<m_File;

   m_ReadF();
   app.exit();
}
Example #8
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    app.setApplicationName(QStringLiteral("kiconfinder"));
    app.setApplicationVersion(KICONTHEMES_VERSION_STRING);
    QCommandLineParser parser;
    parser.setApplicationDescription(app.translate("main", "Finds an icon based on its name"));
    parser.addPositionalArgument(QStringLiteral("iconname"), app.translate("main", "The icon name to look for"));
    parser.addHelpOption();

    parser.process(app);
    if(parser.positionalArguments().isEmpty())
        parser.showHelp();

    Q_FOREACH(const QString& iconName, parser.positionalArguments()) {
        const QString icon = KIconLoader::global()->iconPath(iconName, KIconLoader::Desktop /*TODO configurable*/, true);
        if ( !icon.isEmpty() ) {
            printf("%s\n", icon.toLocal8Bit().constData());
        } else {
            return 1; // error
        }
    }

    return 0;
}
Example #9
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 #10
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 #11
0
int main(int argc, char **argv)
{
    PrintQueue app(argc, argv);
    app.setOrganizationDomain("org.kde");

    KAboutData about("PrintQueue",
                     i18n("Print Queue"),
                     PM_VERSION,
                     i18n("Print Queue"),
                     KAboutLicense::GPL,
                     i18n("(C) 2010-2013 Daniel Nicoletti"));

    about.addAuthor(QStringLiteral("Daniel Nicoletti"), QString(), "*****@*****.**");
    about.addAuthor(QStringLiteral("Lukáš Tinkl"), i18n("Port to Qt 5 / Plasma 5"), QStringLiteral("*****@*****.**"));

    KAboutData::setApplicationData(about);
    KDBusService service(KDBusService::Unique);

    QCommandLineParser parser;
    about.setupCommandLine(&parser);
    parser.addVersionOption();
    parser.addHelpOption();
    parser.addPositionalArgument("queue", i18n("Show printer queue(s)"));
    parser.process(app);
    about.processCommandLine(&parser);

    QObject::connect(&service, &KDBusService::activateRequested, &app, &PrintQueue::showQueues);

    app.showQueues(parser.positionalArguments());

    return app.exec();
}
int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    app.setApplicationName(QLatin1String("ThumbNailer"));
    app.setOrganizationDomain(QLatin1String("kde.org"));
    QCommandLineParser parser;
    parser.setApplicationDescription(app.translate("main", "ThreadWeaver ThumbNailer Example"));
    parser.addHelpOption();
    parser.addPositionalArgument(QLatin1String("mode"), QLatin1String("Benchmark or demo mode"));
    parser.process(app);
    const QStringList positionals = parser.positionalArguments();
    const QString mode = positionals.isEmpty() ? QLatin1String("demo") : positionals[0];
    if (mode == QLatin1String("benchmark")) {
        Benchmark benchmark;
        const QStringList arguments = app.arguments().mid(1); // remove mode selection
        return QTest::qExec(&benchmark, arguments);
    } else if (mode == QLatin1String("demo")){
        // demo mode
        MainWindow mainWindow;
        mainWindow.show();
        return app.exec();
    } else {
        wcerr << "Unknown mode " << mode.toStdWString() << endl << endl;
        parser.showHelp();
        Q_UNREACHABLE();
    }
    return 0;
}
Example #13
0
void parseCommandLine(QCoreApplication &app, CmdLineOptions *opts)
{
    QCommandLineParser parser;

    parser.setApplicationDescription("remove db key at specified path");
    parser.addHelpOption();
    parser.addVersionOption();

    parser.addPositionalArgument("key", QCoreApplication::translate("main", "key"));

    QCommandLineOption debugOption(QStringList() << "d" << "debug",
                                   QCoreApplication::translate("main", "enable debug/verbose logging"));
    parser.addOption(debugOption);

    parser.process(app);

    opts->debuggingEnabled = parser.isSet(debugOption);

    const QStringList posArgs = parser.positionalArguments();
    if (posArgs.size() < 1)
    {
        qCritical("invalid arguments");
        exit(1);
    }

    opts->key = posArgs.at(0);

    DbdLogging::logger()->debugMode =  opts->debuggingEnabled;

    qDebug() << "debugging enabled:" << opts->debuggingEnabled;
    qDebug() << "key:" << opts->key;
}
Example #14
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();
}
Example #15
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 #16
0
int main(int argc, char * argv[])
{
    QApplication app(argc, argv);

    QCommandLineParser commandLineParser;
    commandLineParser.addPositionalArgument(QStringLiteral("url"),
        QStringLiteral("The url to be loaded in the browser window."));
    commandLineParser.process(app);
    QStringList positionalArguments = commandLineParser.positionalArguments();

    QUrl url;
    QString year,month,outputPath;
    int day;
    if (positionalArguments.size() > 5) {
        showHelp(commandLineParser, QStringLiteral("Too many arguments."));
        return -1;
    } else if (positionalArguments.size() == 5) {
        url = QUrl::fromUserInput(positionalArguments.at(0));
        year = positionalArguments.at(1);
        month = positionalArguments.at(2);
        day = positionalArguments.at(3).toInt();
        outputPath = positionalArguments.at(4);
    }
    else
        url = QUrl("http://query.nytimes.com/search/sitesearch/#/crude+oil/from20100502to20100602/allresults/1/allauthors/relevance/business");

    if (!url.isValid()) {
        showHelp(commandLineParser, QString("%1 is not a valid url.").arg(positionalArguments.at(0)));
        return -1;
    }

    MainWindow browser(url,year,month,day,outputPath);
    browser.show();
    return app.exec();
}
Example #17
0
File: main.cpp Project: C-CINA/2dx
int main(int argc, char *argv[]) {

    QApplication app(argc, argv);
    qApp->setAttribute(Qt::AA_UseHighDpiPixmaps);
    QCoreApplication::setApplicationName("Focus");
    QCoreApplication::setOrganizationName("C-CINA");
    QCoreApplication::setOrganizationDomain("c-cina.org");

    QCommandLineParser parser;
    parser.setApplicationDescription("Focus Software Suite: Main Graphical User Interface & Project Manager");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("project_dir", "Path of the focus Project to be opened.");
    parser.process(app);
    
    UserPreferences().loadAllFontSettings();

    if (!parser.positionalArguments().isEmpty()) {
        loadMainWindow(parser.positionalArguments().first());
    } else {
        if(!openProject()) {
            QApplication::quit();
            return 0;
        }
    }

    return app.exec();
}
Example #18
0
int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(mdi);

    QApplication app(argc, argv);

    QCoreApplication::setApplicationName("lua_debug_ui");
    QCoreApplication::setOrganizationName("huangzhe");
    QCoreApplication::setApplicationVersion(QT_VERSION_STR);
    QCommandLineParser parser;
    parser.setApplicationDescription("lua_debug_ui");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("file", "The file to open.");
    parser.process(app);

    MainWindow mainWin;
    if(false == mainWin.checkAndOpenFile( parser.positionalArguments().at(0), parser.positionalArguments().length() > 0))
    {
        return 0;
    }

    mainWin.show();
    foreach (const QString &fileName, parser.positionalArguments())
        mainWin.openFile(fileName);
    return app.exec();
}
Example #19
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 #20
0
File: main.cpp Project: KDE/libqapt
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    app.setWindowIcon(QIcon::fromTheme("applications-other"));

    KLocalizedString::setApplicationDomain("qapt-gst-helper");

    KAboutData aboutData("qapt-gst-helper",
                         i18nc("@title", "QApt Codec Searcher"),
                         version,
                         i18nc("@info", description),
                         KAboutLicense::LicenseKey::GPL,
                         i18nc("@info:credit", "(C) 2011 Jonathan Thomas"));

    aboutData.addAuthor(i18nc("@info:credit", "Jonathan Thomas"),
                        QString(),
                        QStringLiteral("*****@*****.**"));
    aboutData.addAuthor(i18nc("@info:credit", "Harald Sitter"),
                        i18nc("@info:credit", "Qt 5 port"),
                        QStringLiteral("*****@*****.**"));
    KAboutData::setApplicationData(aboutData);

    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addVersionOption();
    QCommandLineOption transientOption(QStringLiteral("transient-for"),
                                       i18nc("@info:shell", "Attaches the window to an X app specified by winid"),
                                       i18nc("@info:shell value name", "winid"),
                                       QStringLiteral("0"));
    parser.addOption(transientOption);
    parser.addPositionalArgument("GStreamer Info",
                                 i18nc("@info:shell", "GStreamer install info"));
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);

    GError *error = nullptr;
    gst_init_check(&argc, &argv, &error);
    if (error) {
        // TODO: we should probably show an error message. API documention suggests
        // so at least. Then again explaining random init errors to the user
        // might be a bit tricky.
#warning FIXME 3.1 show error msgbox when gstreamer init fails
        return GST_INSTALL_PLUGINS_ERROR;
    }

    // do not restore!
    if (app.isSessionRestored()) {
        exit(0);
    }

    int winId = parser.value(transientOption).toInt();
    QStringList details = parser.positionalArguments();

    PluginHelper pluginHelper(0, details, winId);
    pluginHelper.run();

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

    tryInitDrMingw();

#ifdef HAVE_IMAGE_MAGICK
    InitializeMagick(nullptr);
#endif

#ifdef Q_OS_LINUX
    app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif

    // if we have some local breeze icon resource, prefer it
    DXmlGuiWindow::setupIconTheme();

    KLocalizedString::setApplicationDomain("digikam");

    KAboutData aboutData(QLatin1String("showfoto"), // component name
                         i18n("Showfoto"),          // display name
                         digiKamVersion());         // NOTE: showFoto version = digiKam version

    aboutData.setShortDescription(QString::fromUtf8("%1 - %2").arg(DAboutData::digiKamSlogan()).arg(DAboutData::digiKamFamily()));
    aboutData.setLicense(KAboutLicense::GPL);
    aboutData.setCopyrightStatement(DAboutData::copyright());
    aboutData.setOtherText(additionalInformation());
    aboutData.setHomepage(DAboutData::webProjectUrl().url());
    aboutData.setProductName(QByteArray("digikam/showfoto"));   // For bugzilla

    DAboutData::authorsRegistration(aboutData);

    QCommandLineParser parser;
    KAboutData::setApplicationData(aboutData);
    parser.addVersionOption();
    parser.addHelpOption();
    aboutData.setupCommandLine(&parser);
    parser.addPositionalArgument(QLatin1String("files"), i18n("File(s) or folder(s) to open"), QLatin1String("[file(s) or folder(s)]"));
    parser.process(app);
    aboutData.processCommandLine(&parser);

    KSharedConfig::Ptr config = KSharedConfig::openConfig();
    KConfigGroup group        = config->group(QLatin1String("ImageViewer Settings"));
    QString iconTheme         = group.readEntry(QLatin1String("Icon Theme"), QString());

    MetaEngine::initializeExiv2();

    // Force to use application icon for non plasma desktop as Unity for ex.
    QApplication::setWindowIcon(QIcon::fromTheme(QLatin1String("showfoto"), app.windowIcon()));

    QList<QUrl> urlList;
    QStringList urls = parser.positionalArguments();

    foreach (const QString& url, urls)
    {
        urlList.append(QUrl::fromLocalFile(url));
    }
Example #22
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 #23
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 #24
0
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);
    QCoreApplication::addLibraryPath(QStringLiteral(PLUGIN_DIR));
    QCoreApplication::setApplicationName(QStringLiteral("imagedump"));
    QCoreApplication::setApplicationVersion(QStringLiteral("1.0.0.0"));

    QCommandLineParser parser;
    parser.setApplicationDescription(QStringLiteral("Dumps the content of QImage::bits()"));
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument(QStringLiteral("image"), QStringLiteral("image file"));
    parser.addPositionalArgument(QStringLiteral("datafile"), QStringLiteral("file QImage data should be written to"));
    QCommandLineOption informat(
        QStringList() << QStringLiteral("f") << QStringLiteral("file-format"),
        QStringLiteral("Image file format"),
        QStringLiteral("format"));
    parser.addOption(informat);
    QCommandLineOption qimgformat(
        QStringList() << QStringLiteral("q") << QStringLiteral("qimage-format"),
        QStringLiteral("QImage data format"),
        QStringLiteral("format"));
    parser.addOption(qimgformat);
    QCommandLineOption listformats(
        QStringList() << QStringLiteral("l") << QStringLiteral("list-file-formats"),
        QStringLiteral("List supported image file formats"));
    parser.addOption(listformats);
    QCommandLineOption listqformats(
        QStringList() << QStringLiteral("p") << QStringLiteral("list-qimage-formats"),
        QStringLiteral("List supported QImage data formats"));
    parser.addOption(listqformats);

    parser.process(app);

    const QStringList files = parser.positionalArguments();

    if (parser.isSet(listformats)) {
        QTextStream out(stdout);
        out << "File formats:\n";
        foreach (const QByteArray &fmt, QImageReader::supportedImageFormats()) {
            out << "  " << fmt << '\n';
        }
        return 0;
    }
Example #25
0
int main(int argc, char ** argv) {
    QCoreApplication app(argc, argv);
#if defined(Q_OS_UNIX)
    catchUnixSignals({SIGQUIT, SIGINT, SIGTERM, SIGHUP});
#endif

    app.setApplicationName("helloworld");
    app.setApplicationVersion("1.0.0");

    QCommandLineParser parser;
    parser.setApplicationDescription("a HelloWorld example for http client and server.");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("mode",
            "working mode: server, client or weather. default: server");

//    parser.addOption({
//            {"l", "listen"},
//            "listening tcp port number in server mode (default 8080)",
//            "portNo", "8080"});
//    parser.addOption({
//            {"u", "url"},
//            "fetch url data in client mode",
//            "address", "http://www.google.com"});
//    parser.addOption({
//            {"g", "geolocation"},
//            "a city name [,country name] in weather mode, default: Tehran",
//            "city", "Tehran"});
    parser.process(app);


    QStringList posArgs = parser.positionalArguments();
    if ( posArgs.size() != 1 ) {
        parser.showHelp(0);

    } else {
        const auto& mode = posArgs.at(0);

        if ( mode == QLatin1Literal("server") )
            runServer(parser.value("listen"));

#if defined(QHTTP_HAS_CLIENT)
        else if ( mode == QLatin1Literal("client") )
            runClient(parser.value("url"));

        else if ( mode == QLatin1Literal("weather") )
            runWeatherClient(parser.value("geolocation"));
#else
        else if ( mode == QLatin1Literal("client")
                || mode == QLatin1Literal("weather") )
            qDebug("qhttp::client has not been enabled at build time");
#endif // QHTTP_HAS_CLIENT
    }

    return 0;
}
Example #26
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 #27
0
int main(int argc, char** argv) {
    QApplication app(argc, argv);
    app.setApplicationName("Tanglet");
    app.setApplicationVersion(VERSIONSTR);
    app.setApplicationDisplayName(Window::tr("Tanglet"));
    app.setOrganizationDomain("gottcode.org");
    app.setOrganizationName("GottCode");
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
    app.setWindowIcon(QIcon::fromTheme("tanglet", QIcon(":/tanglet.png")));
#endif
    app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);

    QString path = app.applicationDirPath();
    QStringList paths;
    paths.append(path + "/data/");
    paths.append(path + "/../share/tanglet/data/");
    paths.append(path + "/../Resources/data/");
    QDir::setSearchPaths("tanglet", paths);

    LocaleDialog::loadTranslator("tanglet_");

    QSettings settings;
    if (settings.value("Language", -1).toInt() == -1) {
        int default_count = 0;
        if (settings.value("Dice", ":/en_US/dice").toString() == ":/en_US/dice") {
            settings.setValue("Dice", "tanglet:en/dice");
            default_count++;
        }
        if (settings.value("Words", ":/en_US/words").toString() == ":/en_US/words") {
            settings.setValue("Words", "tanglet:en/words");
            default_count++;
        }
        if (settings.value("Dictionary").toString().isEmpty()) {
            settings.setValue("Dictionary", "http://en.wiktionary.org/wiki/%s");
            default_count++;
        }
        if (default_count == 3) {
            LanguageDialog::restoreDefaults();
        } else {
            settings.setValue("Language", 0);
        }
    }

    QCommandLineParser parser;
    parser.setApplicationDescription(QCoreApplication::translate("main", "Word finding game"));
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("file", QCoreApplication::translate("main", "A game file to play."), "[file]");
    parser.process(app);

    QStringList files = parser.positionalArguments();
    Window window(files.isEmpty() ? QString() : files.front());
    window.show();

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

    QCommandLineParser commandLineParser;
    commandLineParser.addPositionalArgument(QStringLiteral("url"),
        QStringLiteral("The url to be loaded in the browser window."));
    commandLineParser.process(app);
    QStringList positionalArguments = commandLineParser.positionalArguments();

    QUrl url;
    QString year("2010"),month("3"),outputPath("/home/dyz/MLProjData");
    int day=22;
    if (positionalArguments.size() > 5) {
        showHelp(commandLineParser, QStringLiteral("Too many arguments."));
        return -1;
    } else if (positionalArguments.size() == 5) {
        url = QUrl::fromUserInput(positionalArguments.at(0));
        year = positionalArguments.at(1);
        month = positionalArguments.at(2);
        day = positionalArguments.at(3).toInt();
        outputPath = positionalArguments.at(4);
    }
    else
        url = QUrl("http://query.nytimes.com/search/sitesearch/#/crude+oil/from20100502to20100602/allresults/1/allauthors/relevance/business");

    if (!url.isValid()) {
        showHelp(commandLineParser, QString("%1 is not a valid url.").arg(positionalArguments.at(0)));
        return -1;
    }
    MainWindowCreator *pMainWindowCreator = new MainWindowCreator();
//    qDebug() << "helllo";
//    do {
//    MainWindow *mainWin = pMainWindowCreator->create(url,year,month,day,outputPath);
//    mainWin->show();
//    app.exec();
//    pMainWindowCreator->destroy();
//    qDebug() << year;
//    } while (1);

    QList<QString> monthhrefs, dayhrefs;
    QString currentURL;
    int urlLevel = 0;
    do {
        MainWindow *mainWin = pMainWindowCreator->create(url,year,month,day,outputPath,monthhrefs,dayhrefs,currentURL,urlLevel);
        mainWin->show();
        app.exec();
        pMainWindowCreator->destroy();
        qDebug() << "reloading";
        QEventLoop loop;
        QTimer::singleShot(1000, &loop, SLOT(quit()));
        loop.exec();
        qDebug() << monthhrefs.count() << dayhrefs.count();
        } while (0);
    return 0;
}
Example #29
0
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();
}
Example #30
0
int main(int argc, char *argv[])
{
	qInstallMessageHandler(myMessageOutput);
	QCoreApplication app(argc, argv);

	QCoreApplication::setApplicationName("QRMC");
	QCoreApplication::setApplicationVersion("1.0");

	QCommandLineParser parser;
	parser.setApplicationDescription(description);
	parser.addHelpOption();
	parser.addVersionOption();

	QTranslator appTranslator;
	if (!app.arguments().contains("--no-locale")) {
		appTranslator.load(":/qrmc_" + QLocale::system().name());
		app.installTranslator(&appTranslator);
	}

	parser.addPositionalArgument("metamodel", QObject::tr("Metamodel file to be processed."));
	parser.addPositionalArgument("target-directory"
			, QObject::tr("Directory to which source code of the editor plugin shall be generated."));

	parser.process(app);

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

	const QString metamodel = positionalArgs.first();
	const QString targetDir = positionalArgs.at(1);

	qrRepo::RepoApi repoApi(metamodel);
	MetaCompiler metaCompiler(repoApi, targetDir);
	if (!metaCompiler.compile()) {
		qDebug() << "Compilation failed.";
		return 1;
	}

	qDebug() << "Compilation completed.";
	return 0;
}