示例#1
19
文件: main.cpp 项目: Ribtoks/heap
int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);

    QCommandLineParser optionsParser;
    optionsParser.setApplicationDescription("Tool for generating pkg file for ministaller");
    ParsedOptions options;

    switch (parseCommandLine(optionsParser, app.arguments(), options)) {
    case CommandLineOk:
        break;
    case CommandLineError:
        std::cout << optionsParser.helpText().toStdString() << std::endl;
        return 1;
    case CommandLineHelpRequested:
        std::cout << optionsParser.helpText().toStdString() << std::endl;
        return 0;
    }

    DiffGenerator diffGenerator(options.m_BaseDir, options.m_NewDir);

    diffGenerator.generateDiffs();

    std::cout << "Done" << std::endl;

    auto json = diffGenerator.generateJson();

    if (!saveJson(options.m_JsonPath, json)) {
        if (!saveJson(DEFAULT_OUTPUT_NAME, json)) {
            std::cerr << "Failed to save json to file" << std::endl;
            return 1;
        }
    }

    return 0;
}
示例#2
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();
}
示例#3
0
文件: main.cpp 项目: rbuj/lxqt-config
int main(int argc, char **argv)
{
    LXQt::SingleApplication app(argc, argv);
    app.setOrganizationName(QStringLiteral("lxqt"));
    app.setApplicationName(QStringLiteral("lxqt-config"));
    app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);

    QCommandLineParser parser;
    parser.setApplicationDescription(QStringLiteral("LXQt Config"));
    const QString VERINFO = QStringLiteral(LXQT_CONFIG_VERSION
                                           "\nliblxqt   " LXQT_VERSION
                                           "\nQt        " QT_VERSION_STR);
    app.setApplicationVersion(VERINFO);
    parser.addVersionOption();
    parser.addHelpOption();
    parser.process(app);

    // ensure that we use lxqt-config.menu file.
    qputenv("XDG_MENU_PREFIX", "lxqt-");

    LXQtConfig::MainWindow w;
    app.setActivationWindow(&w);
    QSize s = QSettings{}.value("size").toSize();
    if (!s.isEmpty())
        w.resize(s);
    w.show();

    int ret = app.exec();

    QSettings{}.setValue("size", w.size());

    return ret;
}
void tst_QCommandLineParser::testPositionalArguments()
{
    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    QVERIFY(parser.parse(QStringList() << "tst_qcommandlineparser" << "file.txt"));
    QCOMPARE(parser.positionalArguments(), QStringList() << QStringLiteral("file.txt"));
}
示例#5
0
文件: main.cpp 项目: KDE/kleopatra
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
    KCrash::initialize();
    Kdelibs4ConfigMigrator migrate(QStringLiteral("kwatchgnupg"));
    migrate.setConfigFiles(QStringList() << QStringLiteral("kwatchgnupgrc"));
    migrate.setUiFiles(QStringList() << QStringLiteral("kwatchgnupgui.rc"));
    migrate.migrate();

    KLocalizedString::setApplicationDomain("kwatchgnupg");
    AboutData aboutData;

    KAboutData::setApplicationData(aboutData);
    QCommandLineParser parser;
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);

    KUniqueService service;

    KWatchGnuPGMainWindow *mMainWin = new KWatchGnuPGMainWindow();
    mMainWin->show();
    return app.exec();
}
示例#6
0
int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);
    QCommandLineParser p;
    configureParse(p,app);

    try{
        FeaturesComplexNetwork cn1;
        FeaturesComplexNetwork cn2;

        auto f  = getFactories(p);
        cn1.load(p.positionalArguments()[0].toStdString().c_str(), f);
        cn2.load(p.positionalArguments()[1].toStdString().c_str(), f);



        if(compareCn(cn1, cn2, p.isSet("t")) == 0){
            puts("Equals");
        }else{
            puts("Differents");
        }
        clearFactories(f);

    }catch (std::exception *e){
        puts(e->what());
    }
    return 0;
}
示例#7
0
int main(int argc, char **argv)
{
    qDebug() << "Test kinvocation by desktop name.";

    KAboutData aboutData(QStringLiteral("testKInvocation"), i18n("Test for KMail invocation"), QStringLiteral("0.0"));
    QCoreApplication app(argc, argv);
    QCommandLineParser parser;
    KAboutData::setApplicationData(aboutData);
    parser.addVersionOption();
    parser.addHelpOption();
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);

    QString errmsg;
    if (KToolInvocation::startServiceByDesktopName(QStringLiteral("org.kde.kmail"), QString(), &errmsg)) {
        qDebug() << " Can not start kmail" << errmsg;
    }

    const QString desktopFile = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, QStringLiteral("org.kde.korganizer.desktop"));
    if (KToolInvocation::startServiceByDesktopPath(desktopFile) > 0) {
        qDebug() << " Can not start korganizer";
    }

    qDebug() << "kinvocation done.";

    return 0;
}
示例#8
0
文件: main.cpp 项目: cornelius/polka
int main(int argc, char **argv)
{
  QApplication app(argc, argv);

  KLocalizedString::setApplicationDomain("polka");

  KAboutData about( QStringLiteral("polka"), i18n("Polka"), version,
    i18n("The humane address book for the cloud"), KAboutLicense::GPL,
    i18n("(c) 2009-2015 Cornelius Schumacher"), QStringLiteral(),
    QStringLiteral("http://cornelius-schumacher.de/polka/"),
    QStringLiteral("*****@*****.**"));

  about.addAuthor(i18n("Cornelius Schumacher"), i18n("Creator"),
    QStringLiteral("*****@*****.**"));

  KAboutData::setApplicationData(about);

  QCommandLineParser parser;
  parser.addHelpOption();
  parser.addVersionOption();
  about.setupCommandLine(&parser);
  parser.process(app);
  about.processCommandLine(&parser);

  MainWindow *widget = new MainWindow;
  widget->show();

  return app.exec();
}
示例#9
0
文件: main.cpp 项目: xiaojianwu/qgo
int main(int argc, char *argv[])
{
	Q_INIT_RESOURCE(application);
    QApplication * app = new QApplication(argc, argv);
	QTranslator translator;

    app->setOrganizationName("qGo");
    app->setApplicationName("qGo");

    QCommandLineParser parser;
    parser.process(*app);
    const QStringList args = parser.positionalArguments();
    translatorPtr = &translator;
	
	startqGo();
    mainwindow->show();

    QStringList::const_iterator filename;
    for ( filename = args.begin(); filename != args.end(); ++filename )
	{
        mainwindow->openSGF(*filename);
    }

	//srand(time(NULL));

    return app->exec();
}
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.")));
}
示例#11
0
int main(int argc, char **argv)
{
    dtkDistributedApplication *app = dtkDistributed::create(argc, argv);
    app->setApplicationName("dtkDistributedSlave");
    app->setApplicationVersion("1.0.0");
    app->setOrganizationName("inria");

    QCommandLineParser *parser = app->parser();
    parser->setApplicationDescription("DTK distributed slave example application: it connect to the DTK distributed server and waits for 1 minute before exiting.");

    QCommandLineOption serverOption("server", "DTK distributed server URL", "URL");
    parser->addOption(serverOption);

    app->initialize();

     if (!parser->isSet(serverOption)) {
         qCritical() << "Error: no server set ! Use --server <url> " ;
         return 1;
     }


    // work
    slaveWork work;
    work.server = parser->value(serverOption);

    app->spawn();
    app->exec(&work);
    app->unspawn();

    return 0;
}
void tst_QCommandLineParser::testEmptyArgsList()
{
    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    QTest::ignoreMessage(QtWarningMsg, "QCommandLineParser: argument list cannot be empty, it should contain at least the executable name");
    QVERIFY(!parser.parse(QStringList())); // invalid call, argv[0] is missing
}
示例#13
0
文件: main.cpp 项目: UIKit0/calligra
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    KAboutData about = newBrainDumpAboutData();
    KAboutData::setApplicationData(about);

    QCommandLineParser parser;

    parser.addVersionOption();
    parser.addHelpOption();

    parser.process(app);

    about.setupCommandLine(&parser);
    about.processCommandLine(&parser);

    KIconLoader::global()->addAppDir("calligra");
    KoGlobal::initialize();

    RootSection* doc = new RootSection;

    MainWindow* window = new MainWindow(doc);
    window->setVisible(true);

    app.exec();

    // Ensure the root section is saved
    doc->sectionsIO()->save();

    delete doc;
    app.exit(0);
}
示例#14
0
文件: main.cpp 项目: KDE/ktp-text-ui
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    KLocalizedString::setApplicationDomain("ktp-log-viewer");

    KAboutData aboutData("ktp-log-viewer",
                         i18n("KDE IM Log Viewer"),
                         QStringLiteral(KTP_TEXT_UI_VERSION_STRING));
    aboutData.addAuthor(i18n("David Edmundson"), i18n("Developer"), "*****@*****.**");
    aboutData.addAuthor(i18n("Daniele E. Domenichelli"), i18n("Developer"), "*****@*****.**");
    aboutData.addAuthor(i18n("Dan Vrátil"), i18n("Developer"), "*****@*****.**");
    aboutData.setProductName("telepathy/log-viewer"); //set the correct name for bug reporting
    aboutData.setOrganizationDomain(QByteArray("kde.org"));
    aboutData.setLicense(KAboutLicense::GPL_V2);

    KAboutData::setApplicationData(aboutData);

    // register to DBus
    const KDBusService dbusService(KDBusService::Multiple);

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

    QCommandLineOption accountId(QStringLiteral("accountID"), i18n("The UID of the account to preselect"));
    QCommandLineOption contactId(QStringLiteral("contactID"), i18n("The UID of the contact to preselect"));

    parser.addOption(accountId);
    parser.addOption(contactId);

    parser.process(app);

    Tp::registerTypes();

    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(
                                                QDBusConnection::sessionBus(),
                                                Tp::Features() << Tp::Account::FeatureCore
                                                    << Tp::Account::FeatureAvatar
                                                    << Tp::Account::FeatureProfile);

    Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(
                                                QDBusConnection::sessionBus(),
                                                Tp::Features() << Tp::Connection::FeatureCore
                                                    << Tp::Connection::FeatureSelfContact
                                                    << Tp::Connection::FeatureRoster);

    Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(
                                                Tp::Features()  << Tp::Contact::FeatureAlias
                                                    << Tp::Contact::FeatureAvatarData
                                                    << Tp::Contact::FeatureSimplePresence
                                                    << Tp::Contact::FeatureCapabilities);

    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());

    LogViewer *logViewer = new LogViewer(accountFactory, connectionFactory, channelFactory, contactFactory);
    logViewer->show();

    return app.exec();
}
示例#15
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");
}
示例#16
0
void CoreApplication::parseArgs()
{
    QCommandLineParser parser;
    parser.setApplicationDescription(QLatin1String("Tarsnap GUI - Online backups for the truly lazy"));
    parser.addHelpOption();
    parser.addVersionOption();
    parser.process(*this);
}
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'."));
}
示例#18
0
文件: win.cpp 项目: markwal/GpxUi
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);
}
示例#19
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;
}
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());
}
示例#21
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();
}
示例#22
0
///////////////////////////////////////////////////////////
// メイン
///////////////////////////////////////////////////////////
int main( int argc, char *argv[] )
{
#ifdef PANDORA
	//VALGRIND実行時用の環境変数
	setenv("DISPLAY", ":0.0", 1);
	//GlibのOSと開発環境のバージョン不一致に対する暫定対応
	//setenv("QT_NO_GLIB", "0", 1);
	//EGLFS対応
	setenv("EGLFS_X11_SIZE", "800x480", 1);
	setenv("EGLFS_X11_FULLSCREEN", "1", 1);
	setenv("QT_QPA_EGLFS_DEPTH", "16", 1);
	setenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", "200", 1);
	setenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", "150", 1);
#endif

	//X11の場合用
	QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
#if QT_VERSION >= 0x050700
	QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

	P6VXApp app(argc, argv);

	QCommandLineParser parser;
	QCommandLineOption safeModeOption(QStringList() << "s" << "safemode", "Safe Mode");
	parser.addOption(safeModeOption);
	parser.process(app);
	bool safeMode = parser.isSet(safeModeOption);
	app.enableSafeMode(safeMode);

#ifdef ANDROID
	app.setCustomRomPath(CUSTOMROMPATH);
#endif

	QLocale locale;
    QString lang = locale.uiLanguages()[0];
    QTranslator myappTranslator;

    //表示言語が日本語でない場合は英語リソースを読み込む
	if(lang != "ja-JP" && lang != "ja"){
		qDebug() << "LANG = " << lang;
        myappTranslator.load(":/translation/PC6001VX_en");
        app.installTranslator(&myappTranslator);
	} else {
#ifdef ANDROID
		app.setFont(QFont("MotoyaLMaru"));
#endif
	}

	//イベントループが始まったらp6vxapp::startup()を実行
    QMetaObject::invokeMethod(&app, "startup", Qt::QueuedConnection);

    //イベントループを開始
	return app.exec();
}
示例#23
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();
}
示例#24
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();
}
示例#25
0
    void Arguments::parse()
    {
        QCommandLineParser parser;
        parser.setApplicationDescription("Unit tests");
        parser.addHelpOption();

        static const QString rootOptionName = "r";
        static const QString dbOptionName   = "d";
        parser.addOptions({
            {{rootOptionName, "test_root"}, "Set tests root path. Have to be specified"   , "root"},
            {{dbOptionName  , "db_path"  }, "Set main database path. Have to be specified", "db"  },
            {"gtest_shuffle", "Shuffle tests"},
        });

        if (!parser.parse(qApp->arguments()))
            parser.showHelp();

        auto tmpRootPath = parser.value(rootOptionName);
        auto tmpDbPath   = parser.value(dbOptionName);

        if (tmpRootPath.isEmpty() || tmpDbPath.isEmpty())
            parser.showHelp();

        m_rootPath = tmpRootPath;
        m_dbPath   = tmpDbPath;
    }
示例#26
0
文件: main.cpp 项目: cjp256/qtdbd
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;
}
示例#27
0
文件: kdf.cpp 项目: KDE/kdf
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    KLocalizedString::setApplicationDomain("kdf");

    KAboutData aboutData(QStringLiteral("kdf"),
                         i18n("KDiskFree"),
                         QStringLiteral(KDF_VERSION_STRING),
                         i18n(description),
                         KAboutLicense::GPL,
                         i18n("(c) 1998-2001, Michael Kropfberger"),
                         QString(),
                         QStringLiteral("http://utils.kde.org/projects/kdf"),
                         QString()
                        );

    aboutData.setOrganizationDomain("kde.org");
    aboutData.addAuthor(i18n("Michael Kropfberger"),
                        QString(),
                        QStringLiteral("*****@*****.**"));

    QCommandLineParser parser;
    parser.setApplicationDescription(aboutData.shortDescription());
    parser.addHelpOption();
    parser.addVersionOption();

    aboutData.setupCommandLine(&parser);

    KAboutData::setApplicationData(aboutData);

    // do the command line parsing
    parser.process(app);

    // handle standard options
    aboutData.processCommandLine(&parser);

    if( app.isSessionRestored() ) //SessionManagement
    {
        for( int n=1; KDFTopLevel::canBeRestored(n); n++ )
        {
            KDFTopLevel *ktl = new KDFTopLevel();
            Q_CHECK_PTR(ktl);
            ktl->restore(n);
        }
    }
    else
    {
        KDFTopLevel *ktl = new KDFTopLevel();
        Q_CHECK_PTR(ktl);
        ktl->show();
    }

    return app.exec();
}
示例#28
0
Toerstein::Toerstein(QWidget *parent) : QMainWindow(parent)
{
    toersteBase = new ToersteBase(this);
    toerstelliSense = new ToerstelliSense(this,toersteBase);

    connect(this,SIGNAL(fileLoaded(QString)),toerstelliSense->worker(),SLOT(indexFile(QString)));

    createMenuBar();
    createShortcuts();

    /* Create tab view */
    tabView = new TabView(this);
    tabView->setTabsClosable(true);
    setCentralWidget(tabView);

    connect(tabView,SIGNAL(tabCloseRequested(int)),this,SLOT(closeTab(int)));

    QCommandLineOption diffMode(QStringList() << "d" << "diff");
    QCommandLineParser parser;

    parser.addOption(diffMode);
    parser.process(QCoreApplication::arguments());

    const QStringList args = parser.positionalArguments();

    if ( args.length() > 0 )
    {
        if ( parser.isSet(diffMode) )
        {
            createNewFile();

            if ( args.length() > 1 )
            {
                open(args.at(0), args.at(1));
            }
            else
            {
                open(args.at(0));
            }
        }
        else
        {
            for(int i=0; i < args.length(); i++)
            {
                createNewFile();
                open(args.at(i));
            }
        }
    }
    else
    {
        createNewFile();
    }
}
/******************************************************************************
* 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")));
}
示例#30
0
int main(int argc, char **argv)
{
    qunsetenv("QT_DEVICE_PIXEL_RATIO");
    QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);

    KLocalizedString::setApplicationDomain("krunner");

    QQuickWindow::setDefaultAlphaBuffer(true);
    QApplication app(argc, argv);

    KQuickAddons::QtQuickSettings::init();

//     TODO: Make it a QGuiApplication once we don't depend on KDELibs4Support
//     QGuiApplication app(argc, argv);
    app.setApplicationName(QStringLiteral("krunner"));
    app.setOrganizationDomain(QStringLiteral("kde.org"));
    app.setApplicationVersion(QStringLiteral(PROJECT_VERSION));
    app.setQuitOnLastWindowClosed(false);
    parser.setApplicationDescription(i18n("Run Command interface"));

    parser.addHelpOption();
    parser.addVersionOption();
    parser.process(app);

    if (!KAuthorized::authorize(QStringLiteral("run_command"))) {
        return -1;
    }

    KDBusService service(KDBusService::Unique);

    KAboutData aboutData(QStringLiteral("krunner"),
        i18n("krunner"),
        QStringLiteral(PROJECT_VERSION),
        i18n("Run Command interface"),
        KAboutLicense::GPL);

    KAboutData::setApplicationData(aboutData);

    QGuiApplication::setFallbackSessionManagementEnabled(false);

    auto disableSessionManagement = [](QSessionManager &sm) {
        sm.setRestartHint(QSessionManager::RestartNever);
    };
    QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement);
    QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement);

    View view;
    view.setVisible(false);

    QObject::connect(&service, &KDBusService::activateRequested, &view, &View::display);

    return app.exec();
}