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


C++ KCmdLineArgs::getOption方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
    KAboutData aboutData("kappfinder", I18N_NOOP("KAppfinder"), "1.0", description, KAboutData::License_GPL,
                         "(c) 1998-2000, Matthias Hoelzer-Kluepfel");
    aboutData.addAuthor("Matthias Hoelzer-Kluepfel", 0, "[email protected]");
    aboutData.addAuthor("Tobias Koenig", 0, "[email protected]");

    KCmdLineArgs::init(argc, argv, &aboutData);
    KCmdLineArgs::addCmdLineOptions(options);
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    KApplication app;

    TopLevel *dlg = new TopLevel(args->getOption("dir"));
    app.setMainWidget(dlg);

    return dlg->exec();
}
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:18,代码来源:main.cpp

示例2: main

int main(int argc, char** argv)
{
    qInstallMsgHandler(messageOutput);
    KAboutData aboutData( "duchaintokross", 0, ki18n( "duchaintokross" ),
                          "33", ki18n("Wrapper generator from C++ to Kross"), KAboutData::License_GPL,
                          ki18n( "(c) 2008, The KDevelop developers" ), KLocalizedString(), "http://www.kdevelop.org" );
    KCmdLineArgs::init( argc, argv, &aboutData );
    KCmdLineOptions options;
    options.add("+file", ki18n("input .cpp file"), QByteArray());
    options.add("I <includes>", ki18n("include directories for the parser (colon separated)"), QByteArray());
    options.add("i <includes>", ki18n("include directories that the generated implementation file will have (colon separated)"), QByteArray());
    options.add("b <builddir>", ki18n("build dir where the Makefile for the input is added"), QByteArray());
    options.add("F <filename>", ki18n("filename to be used for the .moc and the .h file"), QByteArray());
    options.add("D <directory>", ki18n("directory where to put the .h output"), QByteArray());
    options.add("o <output>", ki18n("directory where to put the code output"), QByteArray());
    options.add("impl", ki18n("create implementation"), QByteArray());
    options.add("verbose", ki18n("Verbose output"), QByteArray());
    KCmdLineArgs::addCmdLineOptions( options );
    
    KApplication app;
    ConsoleIDEExtension::init();
    Core::initialize(0, Core::NoUi);
    
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    KUrl::List includes;
    KUrl input;
    
    for(int i=0; i<args->count(); i++)
    {
        QString arg=args->arg(i);
        input=KUrl(arg);
    }
    
    foreach(const QString& inc, args->getOption("I").split(':'))
        includes << KUrl(inc);
    KUrl builddir(args->getOption("b"));
    QString filename(args->getOption("F"));
    QString directory(args->getOption("D"));
    QStringList toinclude(args->getOption("i").split(':'));
    QString output(args->getOption("o"));
    verbose=args->isSet("verbose");
    bool createImpl=args->isSet("impl");
    args->clear();
    
    DUChainExtractor e;
    kDebug() << input << builddir << includes << toinclude;
    e.setWriteImpl(createImpl);
    e.start(input, builddir, includes, filename, directory, toinclude, output);
    
    return app.exec();
}
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:51,代码来源:mainduchain.cpp

示例3: handleXGeometry

void Widgets::handleXGeometry(QWidget * dlg)
{
#ifdef Q_WS_X11
	QString geometry;
	KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde");
	if (args && args->isSet("geometry"))
		geometry = args->getOption("geometry");
    if ( ! geometry.isEmpty()) {
	int x, y;
	int w, h;
	int m = XParseGeometry( geometry.toLatin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h);
	if ( (m & XNegative) )
	    x = KApplication::desktop()->width()  + x - w;
	if ( (m & YNegative) )
	    y = KApplication::desktop()->height() + y - h;
	dlg->setGeometry(x, y, w, h);
	// kDebug() << "x: " << x << "  y: " << y << "  w: " << w << "  h: " << h;
    }
#endif
}
开发者ID:vishesh,项目名称:kde-baseapps,代码行数:20,代码来源:widgets.cpp

示例4: main

int main(int argc, char **argv)
{
    KAboutData about("khotnewstuff", "KHotNewStuff", "0.2");
    KCmdLineArgs *args;

    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions(op);
    args = KCmdLineArgs::parsedArgs();

    KApplication i;

    KNS::DownloadDialog d;
    if(args->isSet("type"))
        d.setType(args->getOption("type"));
    if(args->count() == 1)
        d.setProviderList(args->arg(0));
    d.load();
    d.exec();

    return 0;
}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例5: main

int main(int argc, char *argv[])
{
    KAboutData about("reviewboardtest", 0, ki18n(("ReviewBoard Test")), "0.10", ki18n("Test ReviewBoard support"),
            KAboutData::License_GPL, ki18n("(C) 2010 Aleix Pol Gonzalez"));
    about.addAuthor( ki18n("Aleix Pol Gonzalez"), KLocalizedString(), "[email protected]" );
    
    KCmdLineArgs::init( argc, argv, &about );
    KCmdLineOptions options;
    options.add("+patch", ki18n( "Patch" ));
    options.add("basedir <dir>", ki18n( "Base Directory" ));
    KCmdLineArgs::addCmdLineOptions( options );
    KApplication app;
    
    KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
    
    ReviewPatchDialog d;
    
    KUrl patch(args->arg(0));
    QString basedir=args->getOption("basedir");
    
    qDebug() << "patch:" << patch << ", basedir:" << basedir;
    d.setServer(KUrl("https://git.reviewboard.kde.org"));
    d.setBaseDir(basedir);
    int ret=d.exec();
    if(ret==QDialog::Accepted) {
        KUrl url=d.server();
        ReviewBoard::NewRequest* job=new ReviewBoard::NewRequest(d.server(), patch, d.repository(), d.baseDir());
        bool corr = job->exec();
        if(corr) {
            url.setUserInfo(QString());
            QString requrl = QString("%1/r/%2/").arg(url.prettyUrl()).arg(job->requestId());
            
            KMessageBox::information(0, i18n("<qt>You can find the new request at:<br /><a href='%1'>%1</a> </qt>", requrl));
        } else {
            KMessageBox::error(0, job->errorText());
        }
    }
    
    return ret!=QDialog::Accepted;
}
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:40,代码来源:main.cpp

示例6: main

int main(int argc, char **argv)
{
    KAboutData aboutData("testdistlist", I18N_NOOP("Test Distribution Lists"), "0.1");
    KCmdLineArgs::init(argc, argv, &aboutData);
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if(args->isSet("list"))
    {
        QString name = args->getOption("list");

        DistributionListManager *manager = new DistributionListManager(StdAddressBook::self());
        manager->load();
        DistributionList *list = manager->list(name);
        if(!list)
        {
            kdDebug() << "No list with name '" << name << "'" << endl;
            return 1;
        }
        else
        {
            kdDebug() << "RESULT: " << list->emails().join(", ") << endl;
            return 0;
        }
    }

    DistributionListEditor *editor = new DistributionListEditor(StdAddressBook::self(), 0);

    editor->show();
    app.setMainWidget(editor);

    QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));

    app.exec();

    delete editor;
}
开发者ID:serghei,项目名称:kde3-kdelibs,代码行数:39,代码来源:testdistlist.cpp

示例7: main

int main(int argc, char **argv)
{
    KAboutData about("propertytest2", 0, ki18n("KoProperty Test"), version, ki18n(description),
                     KAboutData::License_GPL, ki18n("(C) 2005 Cedric Pasteur"), KLocalizedString(), 0, "[email protected]");
    about.addAuthor(ki18n("Cedric Pasteur"), KLocalizedString(), "[email protected]");
    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    options.add("flat",
        ki18n("Flat display: do not display groups\n"
              "(useful for testing)"));
    options.add("font-size <size>",
        ki18n("Set font size to <size> (in points)\n"
              "(useful for testing whether editors keep the font settings)"));
    options.add("property <name>",
        ki18n("Display only specified property\n"
              "(useful when we want to focus on testing a single\n"
              "property editor)"));
    options.add("ro",
        ki18n("Set all properties as read-only:\n"
              "(useful for testing read-only mode)"));
    KCmdLineArgs::addCmdLineOptions(options);
    KApplication app;

    TestWindow test;
    bool ok;
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    const int fontSize = args->getOption("font-size").toInt(&ok);
    if (fontSize > 0 && ok) {
        QFont f(test.font());
        f.setPointSize(fontSize);
        test.setFont(f);
    }
    test.show();

    return app.exec();
}
开发者ID:KDE,项目名称:calligra-history,代码行数:37,代码来源:main.cpp

示例8: main

int main(int argc, char **argv)
{
  KAboutData about("khello", I18N_NOOP("HelloWorld-KDE"), "1.0", 
                   I18N_NOOP("The Hello-World program for KDE"), KAboutData::License_GPL, 
		   "(c) 2000 Addison-Wesley", "http://www.addison.wesley.de", 
		   I18N_NOOP("Here is more text\neven more lines"), "[email protected]x.de");
  about.addAuthor("Burkhard Lehner", I18N_NOOP("Source and Testing"), 
                  "[email protected]", "http://www.burkhardlehner.de");
  about.addCredit("My mother", I18N_NOOP("cooking coffee"), "[email protected]", "http://www.mother.de");
  
  KCmdLineArgs::init(argc, argv, &about);
  KCmdLineArgs::addCmdLineOptions(options);
  KApplication app;

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
  if(args->isSet("b"))
    KApplication::beep();
    
  QLabel *l = new QLabel(args->getOption("message"), 0);

  l->show();
  app.setMainWidget(l);
  return app.exec();
}
开发者ID:acpanna,项目名称:coding,代码行数:24,代码来源:kcmdargs.cpp

示例9: aboutData

extern "C" KDE_EXPORT int kdemain( int argc, char **argv )
{
  // here we go, construct the Kate version
  QString kateVersion = KateApp::kateVersion();

  KAboutData aboutData ("kate", I18N_NOOP("Kate"), kateVersion.latin1(),
                        I18N_NOOP( "Kate - Advanced Text Editor" ), KAboutData::License_LGPL_V2,
                        I18N_NOOP( "(c) 2000-2005 The Kate Authors" ), 0, "http://kate.kde.org");

  aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "[email protected]", "http://www.babylon2k.de");
  aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "[email protected]", "http://www.alweb.dk");
  aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "[email protected]","http://stud3.tuwien.ac.at/~e9925371");
  aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "[email protected]");
  aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "[email protected]" );
  aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "[email protected]");
  aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "[email protected]");
  aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "[email protected]");
  aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "[email protected]");
  aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "[email protected]" );
  aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "[email protected]");
  aboutData.addAuthor ("Christian Gebauer", 0, "[email protected]" );
  aboutData.addAuthor ("Simon Hausmann", 0, "[email protected]" );
  aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "[email protected]");
  aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "[email protected]");
  aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "[email protected]");
  aboutData.addAuthor ("Dominik Haumann", I18N_NOOP("Developer & Highlight wizard"), "[email protected]");

  aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "[email protected]");
  aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "[email protected]");
  aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),"");
  aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),"");
  aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),"");
  aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),"");
  aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),"");
  aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),"");
  aboutData.addCredit ("Daniel Naber","","");
  aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),"");
  aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),"");
  aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), "");
  aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"","");

  aboutData.setTranslator(I18N_NOOP2("NAME OF TRANSLATORS","Your names"), I18N_NOOP2("EMAIL OF TRANSLATORS","Your emails"));

  // command line args init and co
  KCmdLineArgs::init (argc, argv, &aboutData);
  KCmdLineArgs::addCmdLineOptions (options);
  KCmdLineArgs::addTempFileOption();
  KateApp::addCmdLineOptions ();

  // get our command line args ;)
  KCmdLineArgs* args = KCmdLineArgs::parsedArgs();

  // now, first try to contact running kate instance if needed
  if ( args->isSet("use") || (::getenv("KATE_PID")!=0) )
  {
    DCOPClient client;
    client.attach ();

    // get all attached clients ;)
    QCStringList allClients = client.registeredApplications();

    // search for a kate app client, use the first found
    QCString kateApp;

    if ( args->isSet("start") )
    {
      for (unsigned int i=0; i < allClients.count(); i++)
      {
        if (allClients[i] == "kate" || allClients[i].left(5) == "kate-")
        {
          DCOPRef ref( allClients[i], "KateApplication" );
          QString s = ref.call( "session" );
          if ( QString(args->getOption("start")) == s )
          {
            kateApp = allClients[i];
            break;
          }
        }
      }
    }
    else if ( (args->isSet("pid")) || (::getenv("KATE_PID") !=0 ) )
    {
      QCString tryApp;
      if ( args->isSet("pid") )
        tryApp = args->getOption("pid");
      else
        tryApp = ::getenv("KATE_PID");

      if ( client.isApplicationRegistered( tryApp.prepend("kate-") ) )
        kateApp = tryApp;
    }
    else
    {
      for (unsigned int i=0; i < allClients.count(); ++i)
      {
        if (allClients[i] == "kate" || allClients[i].left(5) == "kate-")
        {
          kateApp = allClients[i];
          break;
        }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例10: about

int
main (int argc, char **argv)
{
    KWD::Decorator  *app;
    KCmdLineArgs    *args;
    KCmdLineOptions options;
    int		    status;
    Time	    timestamp;
    QString         appname;

    options.add ("replace", ki18n ("Replace existing window decorator"));
    options.add ("sm-disable", ki18n ("Disable connection to session manager"));
    options.add ("blur <type>", ki18n ("Blur type (none/titlebar/all)"), "none");

    KAboutData about("kde-window-decorator", "kwin", ki18n ("KDE Window Decorator"),
                     "0.0.1", KLocalizedString(), KAboutData::License_GPL,
                     KLocalizedString(), KLocalizedString(), "http://www.compiz.org", 
		     "[email protected]");
    KCmdLineArgs::init (argc, argv,
			"kde-window-decorator",
			"kwin",
			ki18n ("KDE Window Decorator"),
			"0.0.1");
    KCmdLineArgs::addCmdLineOptions (options);
    args = KCmdLineArgs::parsedArgs ();

    if (args->isSet ("blur"))
    {
	QString blur = args->getOption ("blur");

	if (blur == QString ("titlebar"))
	    blurType = BLUR_TYPE_TITLEBAR;
	else if (blur == QString ("all"))
	    blurType = BLUR_TYPE_ALL;
    }

    app = new KWD::Decorator ();

    if (args->isSet ("sm-disable"))
	app->disableSessionManagement ();

    status = decor_acquire_dm_session (QX11Info::display(),
				       QX11Info::appScreen (),
				       "kwd", args->isSet ("replace"),
				       &timestamp);
    if (status != DECOR_ACQUIRE_STATUS_SUCCESS)
    {
	if (status == DECOR_ACQUIRE_STATUS_FAILED)
	{
	    fprintf (stderr,
		     "%s: Could not acquire decoration manager "
		     "selection on screen %d display \"%s\"\n",
		     argv[0], QX11Info::appScreen (),
		     DisplayString (QX11Info::display()));
	}
	else if (status == DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING)
	{
	    fprintf (stderr,
		     "%s: Screen %d on display \"%s\" already "
		     "has a decoration manager; try using the "
		     "--replace option to replace the current "
		     "decoration manager.\n",
		     argv[0], QX11Info::appScreen (),
		     DisplayString (QX11Info::display()));
	}

	return 1;
    }

    decor_set_dm_check_hint (QX11Info::display(), QX11Info::appScreen ());

    if (!app->enableDecorations (timestamp))
    {
	fprintf (stderr,
		 "%s: Could not enable decorations on display \"%s\"\n",
		 argv[0], DisplayString (QX11Info::display()));

	return 1;
    }

    if (QX11Info::appScreen () == 0)
        appname = "org.kde.kwin";
    else
        appname.sprintf("org.kde.kwin-screen-%d", QX11Info::appScreen ());

    QDBusConnection::sessionBus ().interface ()->registerService
	(appname, QDBusConnectionInterface::DontQueueService);

    status = app->exec ();

    delete app;

    return status;
}
开发者ID:SubwayDesktop,项目名称:compiz-stable,代码行数:94,代码来源:main.cpp

示例11: slotLoadPlugins

void KopeteApplication::slotLoadPlugins()
{
	// we have to load the address book early, because calling this enters the Qt event loop when there are remote resources.
	// The plugin manager is written with the assumption that Kopete will not reenter the event loop during plugin load,
	// otherwise lots of things break as plugins are loaded, then contacts are added to incompletely initialised MCLVIs
	Kopete::KABCPersistence::self()->addressBook();

	//Create the command handler (looks silly)
	Kopete::CommandHandler::commandHandler();

	//Create the view manager
	KopeteViewManager::viewManager();

	Kopete::AccountManager::self()->load();
	Kopete::ContactList::self()->load();

	KConfig *config = KGlobal::config();

	// Parse command-line arguments
	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

	bool showConfigDialog = false;

	config->setGroup( "Plugins" );

	/* FIXME: This is crap, if something purged that groups but your accounts
	 * are still working kopete will load the necessary plugins but still show the
	 * stupid accounts dialog (of course empty at that time because account data
	 * gets loaded later on). [mETz - 29.05.2004]
	 */
	if ( !config->hasGroup( "Plugins" ) )
		showConfigDialog = true;

	// Listen to arguments
	/*
	// TODO: conflicts with emoticon installer and the general meaning
	// of %U in kopete.desktop
	if ( args->count() > 0 )
	{
		showConfigDialog = false;
		for ( int i = 0; i < args->count(); i++ )
			Kopete::PluginManager::self()->setPluginEnabled( args->arg( i ), true );
	}
	*/

	// Prevent plugins from loading? (--disable=foo,bar)
	QStringList disableArgs = QStringList::split( ',', args->getOption( "disable" ) );
	for ( QStringList::ConstIterator it = disableArgs.begin(); it != disableArgs.end(); ++it )
	{
		showConfigDialog = false;
		Kopete::PluginManager::self()->setPluginEnabled( *it, false );
	}

	// Load some plugins exclusively? (--load-plugins=foo,bar)
	if ( args->isSet( "load-plugins" ) )
	{
		config->deleteGroup( "Plugins", true );
		showConfigDialog = false;
		QStringList plugins = QStringList::split( ',', args->getOption( "load-plugins" ) );
		for ( QStringList::ConstIterator it = plugins.begin(); it != plugins.end(); ++it )
			Kopete::PluginManager::self()->setPluginEnabled( *it, true );
	}

	config->sync();

	// Disable plugins altogether? (--noplugins)
	if ( !args->isSet( "plugins" ) )
	{
		// If anybody reenables this I'll get a sword and make a nice chop-suy out
		// of your body :P [mETz - 29.05.2004]
		// This screws up kopeterc because there is no way to get the Plugins group back!
		//config->deleteGroup( "Plugins", true );

		showConfigDialog = false;
		// pretend all plugins were loaded :)
		QTimer::singleShot(0, this, SLOT( slotAllPluginsLoaded() ));
	}
	else
	{
		Kopete::PluginManager::self()->loadAllPlugins();
	}

	connect( Kopete::PluginManager::self(), SIGNAL( allPluginsLoaded() ),
		this, SLOT( slotAllPluginsLoaded() ));

	if( showConfigDialog )
	{
		// No plugins specified. Show the config dialog.
		// FIXME: Although it's a bit stupid it is theoretically possible that a user
		//        explicitly configured Kopete to not load plugins on startup. In this
		//        case we don't want this dialog. We need some other config setting
		//        like a bool hasRunKopeteBefore or so to trigger the loading of the
		//        wizard. Maybe using the last run version number is more useful even
		//        as it also allows for other features. - Martijn
		// FIXME: Possibly we need to influence the showConfigDialog bool based on the
		//        command line arguments processed below. But how exactly? - Martijn
		// NB: the command line args are completely broken atm.  
		// I don't want to fix them for 3.5 as plugin loading will change for KDE4.	- Will
		AddAccountWizard *m_addwizard = new AddAccountWizard( Kopete::UI::Global::mainWidget(), "addAccountWizard", true, true );
		m_addwizard->exec();
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:101,代码来源:kopeteapplication.cpp

示例12: slotPrint

void PrintWrapper::slotPrint()
{
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
    struct sigaction action;
#endif /* HAVE_SIGACTION && !HAVE_SIGSET*/

    // read variables from command line
    QString printer = args->getOption("d");
    QString title = args->getOption("t");
    int ncopies = QString(args->getOption("n")).toInt();
    QString job_mode = args->getOption("j");
    QString system = args->getOption("system");
    KStringList optlist = args->getOptionList("o");
    QMap< QString, QString > opts;
    KURL::List files;
    QStringList filestoprint;
    force_stdin = args->isSet("stdin");
    docopy = args->isSet("c");
    bool nodialog = !(args->isSet("dialog"));

    if(isatty(0))
    {
        kdDebug(500) << "stdin is a terminal, disabling it" << endl;
        check_stdin = false;
    }

    // parse options
    for(KStringList::ConstIterator it = optlist.begin(); it != optlist.end(); ++it)
    {
        QStringList l = QStringList::split('=', QString(*it), false);
        if(l.count() >= 1)
            opts[l[0]] = (l.count() == 2 ? l[1] : QString::null);
    }

    // read file list
    for(int i = 0; i < args->count(); i++)
        files.append(args->url(i));

    // some clean-up
    args->clear();

    // set default values if necessary
    if(job_mode == "console")
        job_output = 1;
    else if(job_mode == "none")
        job_output = 2;
    else
        job_output = 0;

    // some checking
    if(files.count() > 0)
    {
        check_stdin = false;

        if(force_stdin)
        {
            showmsg(i18n("A file has been specified on the command line. Printing from STDIN will be disabled."), 1);
            force_stdin = false;
        }
    }
    if(nodialog && files.count() == 0 && !force_stdin && !check_stdin)
    {
        errormsg(i18n("When using '--nodialog', you must at least specify one file to print or use the '--stdin' flag."));
    }

    if(check_stdin)
    { // check if there's any input on stdin
        fd_set in;
        struct timeval tm;
        tm.tv_sec = 0;
        tm.tv_usec = 0;
        FD_ZERO(&in);
        FD_SET(0, &in);
        if(select(1, &in, NULL, NULL, &tm))
        { // we have data on stdin
            if(read(0, &readchar, 1) > 0)
            {
                force_stdin = true;
                check_stdin = false;
                dataread = true;
                kdDebug(500) << "input detected on stdin" << endl;
            }
            else
            {
                force_stdin = check_stdin = false;
                kdDebug(500) << "stdin closed and empty" << endl;
            }
        }
        else
            kdDebug(500) << "no input on stdin at startup" << endl;
    }

    // force_stdin ? or also check_stdin ?
    KPrinter::ApplicationType dialog_mode = (force_stdin || nodialog ? KPrinter::StandAlone : KPrinter::StandAlonePersistent);
    KPrinter::setApplicationType(dialog_mode);
    if(!force_stdin)
        KPrinter::addStandardPage(KPrinter::FilesPage);

//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:101,代码来源:printwrapper.cpp

示例13: main

int main(int argc, char *argv[])
{
    KCmdLineOptions options;
    options.add("c <digest>", ki18n("compare <digest> with the calculated digest for a string or file."));
    options.add("d", ki18n("decode the given string or file using base64"));
    options.add("e", ki18n("encode the given string or file using base64"));
    options.add("f", ki18n("the filename to be used as input"), "default");
    options.add("p", ki18n("encode the given string or file using quoted-printable"));
    options.add("q", ki18n("decode the given string or file using quoted-printable"));
    options.add("r", ki18n("calculate the raw md5 for the given string or file"));
    options.add("s", ki18n("the string to be used as input"));
    options.add("t", ki18n("perform a timed message-digest test"));
    options.add("u", ki18n("uuencode the given string or file"));
    options.add("x", ki18n("uudecode the given string or file"));
    options.add("z", ki18n("run a preset message-digest test"));
    options.add("+command", ki18n("[input1, input2,...]"));

    KCmdLineArgs::init(argc, argv, "kmdcodectest", 0,
                       ki18n("KMDCodecTest"), "1.0",
                       ki18n("Unit test for md5, base64 encode/decode "
                             "and uuencode/decode facilities"));
    KCmdLineArgs::addCmdLineOptions(options);
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    int count = args->count();

    //QCoreApplication app;

    if (!count) {
        if (args->isSet("t")) {
            MD5_timeTrial();
        } else if (args->isSet("z")) {
            MD5_testSuite();
        } else {
            args->usage();
        }
    } else {
        bool isVerify = args->isSet("c");
        bool isString = args->isSet("s");
        bool isFile = args->isSet("f");
        Codec type = Unspecified;
        if (args->isSet("d")) {
            type = Base64Decode;
        } else if (args->isSet("e")) {
            type = Base64Encode;
        } else if (args->isSet("u")) {
            type = UUEncode;
        } else if (args->isSet("x")) {
            type = UUDecode;
        } else if (args->isSet("p")) {
            type = QPEncode;
        } else if (args->isSet("q")) {
            type = QPDecode;
        }
        if (isVerify) {
            const char *opt = args->getOption("c").toLocal8Bit().data();
            for (int i = 0; i < count; i++) {
                MD5_verify(args->arg(i).toLocal8Bit().constData(), opt, (isString || !isFile));
            }
        } else {
            for (int i = 0; i < count; i++) {
                if (type != Unspecified) {
                    testCodec(args->arg(i).toLocal8Bit().constData(), type, isFile);
                } else {
                    if (isString) {
                        MD5_string(args->arg(i).toLocal8Bit().constData(), 0, args->isSet("r"));
                    } else {
                        MD5_file(args->arg(i).toLocal8Bit().constData(), args->isSet("r"));
                    }
                }
            }
        }
    }
    args->clear();
    return (0);
}
开发者ID:KDE,项目名称:kdelibs4support,代码行数:75,代码来源:kmdcodectest.cpp

示例14: aboutData

extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
{
    KLocale::setMainCatalogue("konqueror");
    KAboutData aboutData("keditbookmarks", I18N_NOOP("Bookmark Editor"), VERSION, I18N_NOOP("Konqueror Bookmarks Editor"), KAboutData::License_GPL,
                         I18N_NOOP("(c) 2000 - 2003, KDE developers"));
    aboutData.addAuthor("David Faure", I18N_NOOP("Initial author"), "[email protected]");
    aboutData.addAuthor("Alexander Kellett", I18N_NOOP("Author"), "[email protected]");

    KCmdLineArgs::init(argc, argv, &aboutData);
    KApplication::addCmdLineOptions();
    KCmdLineArgs::addCmdLineOptions(options);

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    bool isGui =
        !(args->isSet("exportmoz") || args->isSet("exportns") || args->isSet("exporthtml") || args->isSet("exportie") || args->isSet("exportopera")
          || args->isSet("importmoz") || args->isSet("importns") || args->isSet("importie") || args->isSet("importopera"));

    bool browser = args->isSet("browser");

    KApplication::disableAutoDcopRegistration();
    KApplication app(isGui, isGui);

    bool gotArg = (args->count() == 1);

    QString filename = gotArg ? QString::fromLatin1(args->arg(0)) : locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));

    if(!isGui)
    {
        CurrentMgr::self()->createManager(filename);
        CurrentMgr::ExportType exportType = CurrentMgr::MozillaExport; // uumm.. can i just set it to -1 ?
        int got = 0;
        const char *arg, *arg2 = 0, *importType = 0;
        if(arg = "exportmoz", args->isSet(arg))
        {
            exportType = CurrentMgr::MozillaExport;
            arg2 = arg;
            got++;
        }
        if(arg = "exportns", args->isSet(arg))
        {
            exportType = CurrentMgr::NetscapeExport;
            arg2 = arg;
            got++;
        }
        if(arg = "exporthtml", args->isSet(arg))
        {
            exportType = CurrentMgr::HTMLExport;
            arg2 = arg;
            got++;
        }
        if(arg = "exportie", args->isSet(arg))
        {
            exportType = CurrentMgr::IEExport;
            arg2 = arg;
            got++;
        }
        if(arg = "exportopera", args->isSet(arg))
        {
            exportType = CurrentMgr::OperaExport;
            arg2 = arg;
            got++;
        }
        if(arg = "importmoz", args->isSet(arg))
        {
            importType = "Moz";
            arg2 = arg;
            got++;
        }
        if(arg = "importns", args->isSet(arg))
        {
            importType = "NS";
            arg2 = arg;
            got++;
        }
        if(arg = "importie", args->isSet(arg))
        {
            importType = "IE";
            arg2 = arg;
            got++;
        }
        if(arg = "importopera", args->isSet(arg))
        {
            importType = "Opera";
            arg2 = arg;
            got++;
        }
        if(!importType && arg2)
        {
            Q_ASSERT(arg2);
            // TODO - maybe an xbel export???
            if(got > 1) // got == 0 isn't possible as !isGui is dependant on "export.*"
                KCmdLineArgs::usage(I18N_NOOP("You may only specify a single --export option."));
            QString path = QString::fromLocal8Bit(args->getOption(arg2));
            CurrentMgr::self()->doExport(exportType, path);
        }
        else if(importType)
        {
            if(got > 1) // got == 0 isn't possible as !isGui is dependant on "import.*"
                KCmdLineArgs::usage(I18N_NOOP("You may only specify a single --import option."));
            QString path = QString::fromLocal8Bit(args->getOption(arg2));
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:101,代码来源:main.cpp

示例15: main


//.........这里部分代码省略.........
     * Set incidence type(s)
     */
    if (args->isSet("event")) {
        variables.setUseEvents(true);
        qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options | use Events";
    }
    if (args->isSet("todo")) {
        variables.setUseTodos(true);
        qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options | use To-dos";
        cout << i18n("Sorry, To-dos are not working yet.").toLocal8Bit().data()
             << endl;
        return 1;
    }
    if (args->isSet("journal")) {
        variables.setUseJournals(true);
        qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options | use Journals";
        cout << i18n("Sorry, Journals are not working yet.").toLocal8Bit().data()
             << endl;
        return 1;
    }
    // Use Events if no incidence type is specified on the command line
    if (!args->isSet("event") &&
            !args->isSet("todo") &&
            !args->isSet("journal")) {
        variables.setUseEvents(true);
        qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options | use Events (Default)";
    }

    /*
     * Switch on exporting
     */
    variables.setExportType(ExportTypeText);
    if (args->isSet("export-type")) {
        option = args->getOption("export-type");

        if (option.toUpper() == QLatin1String("HTML")) {
            qCDebug(KONSOLEKALENDAR_LOG) << "main | export-type | Export to HTML";
            variables.setExportType(ExportTypeHTML);
        } else if (option.toUpper() == QLatin1String("HTMLMONTH")) {
            qCDebug(KONSOLEKALENDAR_LOG) << "main | export-type | Export to HTML by Month";
            variables.setExportType(ExportTypeMonthHTML);
        } else if (option.toUpper() == QLatin1String("CSV")) {
            qCDebug(KONSOLEKALENDAR_LOG) << "main | export-type | Export to CSV";
            variables.setExportType(ExportTypeCSV);
        } else if (option.toUpper() == QLatin1String("TEXT")) {
            qCDebug(KONSOLEKALENDAR_LOG) << "main | export-type | Export to TEXT (default)";
            variables.setExportType(ExportTypeText);
        } else if (option.toUpper() == QLatin1String("SHORT")) {
            qCDebug(KONSOLEKALENDAR_LOG) << "main | export-type | Export to TEXT-SHORT";
            variables.setExportType(ExportTypeTextShort);
        } else {
            cout << i18n("Invalid Export Type Specified: %1", option).toLocal8Bit().data()
                 << endl;
            return 1;
        }
    }

    /*
     * Switch on export file name
     */
    if (args->isSet("export-file")) {
        option = args->getOption("export-file");

        qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options |"
                                     << "Export File:"
                                     << "(" << option << ")";
开发者ID:KDE,项目名称:kdepim,代码行数:67,代码来源:main.cpp


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