本文整理汇总了C++中KCmdLineArgs::arg方法的典型用法代码示例。如果您正苦于以下问题:C++ KCmdLineArgs::arg方法的具体用法?C++ KCmdLineArgs::arg怎么用?C++ KCmdLineArgs::arg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KCmdLineArgs
的用法示例。
在下文中一共展示了KCmdLineArgs::arg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
KAboutData about("khotnewstuff", 0, ki18n("KHotNewStuff"), "0.4");
about.setProgramIconName("get-hot-new-stuff");
KCmdLineArgs *args;
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions op;
op.add("+filename", ki18n("Name of .knsrc file to use"));
op.add("+filename", ki18n("Name of file to upload"));
KCmdLineArgs::addCmdLineOptions(op);
args = KCmdLineArgs::parsedArgs();
KApplication i;
if (args->count() > 0) {
KNS3::UploadDialog dialog(args->arg(0));
if (args->count() > 1) {
dialog.setUploadFile(KUrl(args->arg(1)));
}
dialog.exec();
}
else
{
args->usage();
return -1;
}
return 0;
}
示例2: main
int main(int argc, char **argv)
{
KAboutData aboutData("kstartperf", 0, ki18n("KStartPerf"),
"1.0", ki18n("Measures start up time of a KDE application"),
KAboutData::License_Artistic,
ki18n("Copyright (c) 2000 Geert Jansen and libkmapnotify authors"));
aboutData.addAuthor(ki18n("Geert Jansen"), ki18n("Maintainer"),
"[email protected]", "http://www.stack.nl/~geertj/");
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions options;
options.add("+command", ki18n("Specifies the command to run"));
options.add("!+[args]", ki18n("Arguments to 'command'"));
KCmdLineArgs::addCmdLineOptions(options);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KComponentData componentData( &aboutData );
QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
// Check arguments
if (args->count() == 0)
{
fprintf(stderr, "No command specified!\n");
fprintf(stderr, "usage: kstartperf command [arguments]\n");
exit(1);
}
// Build command
char cmd[1024];
snprintf(cmd, sizeof(cmd), "LD_PRELOAD=%s %s",
qPrintable( libkstartperf() ), qPrintable(args->arg(0)));
for (int i=1; i<args->count(); i++)
{
strcat(cmd, " ");
strcat(cmd, args->arg(i).toLocal8Bit());
}
// Put the current time in the environment variable `KSTARTPERF'
struct timeval tv;
if (gettimeofday(&tv, 0L) != 0)
{
perror("gettimeofday()");
exit(1);
}
char env[100];
sprintf(env, "KSTARTPERF=%ld:%ld", tv.tv_sec, tv.tv_usec);
putenv(env);
// And exec() the command
execl("/bin/sh", "sh", "-c", cmd, (void *)0);
perror("execl()");
exit(1);
}
示例3: main
int main (int argc, char **argv)
{
KCmdLineOptions options;
options.add("+[directory ...]", ki18n("Directory(ies) to watch"));
KCmdLineArgs::init(argc, argv, "kdirwatchtest", 0, ki18n("KDirWatchTest"),
"1.0", ki18n("Test for KDirWatch"));
KCmdLineArgs::addCmdLineOptions( options );
KCmdLineArgs::addStdCmdLineOptions();
QCoreApplication a(argc, argv);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
myTest testObject;
KDirWatch *dirwatch1 = KDirWatch::self();
KDirWatch *dirwatch2 = new KDirWatch;
testObject.connect(dirwatch1, SIGNAL(dirty(QString)), SLOT(dirty(QString)) );
testObject.connect(dirwatch1, SIGNAL(created(QString)), SLOT(created(QString)) );
testObject.connect(dirwatch1, SIGNAL(deleted(QString)), SLOT(deleted(QString)) );
if (args->count() >0) {
for(int i = 0; i < args->count(); i++) {
kDebug() << "Watching: " << args->arg(i);
dirwatch2->addDir( args->arg(i));
}
}
QString home = QString(getenv ("HOME")) + '/';
QString desk = home + "Desktop/";
kDebug() << "Watching: " << home;
dirwatch1->addDir(home);
kDebug() << "Watching file: " << home << "foo ";
dirwatch1->addFile(home+"foo");
kDebug() << "Watching: " << desk;
dirwatch1->addDir(desk);
QString test = home + "test/";
kDebug() << "Watching: (but skipped) " << test;
dirwatch1->addDir(test);
dirwatch1->startScan();
dirwatch2->startScan();
if(!dirwatch1->stopDirScan(home))
kDebug() << "stopDirscan: " << home << " error!";
if(!dirwatch1->restartDirScan(home))
kDebug() << "restartDirScan: " << home << "error!";
if (!dirwatch1->stopDirScan(test))
kDebug() << "stopDirScan: error";
KDirWatch::statistics();
delete dirwatch2;
KDirWatch::statistics();
return a.exec();
}
示例4: main
int main(int argc, char **argv) {
static KCmdLineOptions options[] = {
{"show", I18N_NOOP("Show window on startup"), 0},
{"kwalletd", I18N_NOOP("For use by kwalletd only"), 0},
{"+name", I18N_NOOP("A wallet name"), 0},
KCmdLineLastOption
};
KAboutData about("kwalletmanager", I18N_NOOP("KDE Wallet Manager"), "1.1",
I18N_NOOP("KDE Wallet Management Tool"),
KAboutData::License_GPL,
I18N_NOOP("(c) 2003,2004 George Staikos"), 0,
"http://www.kde.org/");
about.addAuthor("George Staikos", I18N_NOOP("Primary author and maintainer"), "[email protected]");
about.addAuthor("Isaac Clerencia", I18N_NOOP("Developer"), "[email protected]");
KCmdLineArgs::init(argc, argv, &about);
KCmdLineArgs::addCmdLineOptions(options);
if (!KUniqueApplication::start()) {
return 0;
}
MyApp a;
KWalletManager wm;
wm.setCaption(i18n("KDE Wallet Manager"));
a.setMainWidget(&wm);
KGlobal::dirs()->addResourceType("kwallet", "share/apps/kwallet");
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->isSet("show")) {
wm.show();
}
if (args->isSet("kwalletd")) {
wm.kwalletdLaunch();
}
for (int i = 0; i < args->count(); ++i) {
QString fn = QFileInfo(args->arg(i)).absFilePath();
KMimeType::Ptr ptr;
if (QFile::exists(fn) &&
(ptr = KMimeType::findByFileContent(fn)) &&
ptr->is("application/x-kde-wallet")) {
wm.openWalletFile(fn);
} else {
wm.openWallet(args->arg(i));
}
}
args->clear();
return a.exec();
}
示例5: main
int main(int argc, char **argv)
{
KAboutData about(QByteArray("microbe"), QByteArray("languages"), ki18n("Microbe"),
QByteArray(version), ki18n(description),
KAboutData::License_GPL, ki18n("(C) 2004-2005, The KTechLab developers"),
KLocalizedString(), QByteArray("http://ktechlab.org"),
QByteArray("[email protected]") );
about.addAuthor( ki18n("Daniel Clarke"), KLocalizedString(),
QByteArray("[email protected]") );
about.addAuthor( ki18n("David Saxton"), KLocalizedString(),
QByteArray("[email protected]") );
about.addAuthor( ki18n("Modified to add pic 16f877,16f627 and 16f628 by George John"),
KLocalizedString(), QByteArray("[email protected]") );
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions o;
o.add( QByteArray("show-source"),
ki18n( "Show source code lines in assembly output") );
o.add( QByteArray("nooptimize"),
ki18n( "Do not attempt optimization of generated instructions.") );
o.add( QByteArray("+[Input URL]"),
ki18n( "Input filename" ) );
o.add( QByteArray("+[Output URL]"),
ki18n( "Output filename" ) );
KCmdLineArgs::addCmdLineOptions(o);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count() == 2 )
{
Microbe mb;
// QString s = mb.compile( args->arg(0), args->isSet("show-source"), args->isSet("optimize"));
QString s = mb.compile( args->arg(0), args->isSet("optimize"));
QString errorReport = mb.errorReport();
if ( !errorReport.isEmpty() )
{
kError() << errorReport;
return 1; // If there was an error, don't write the output to file.
}
else
{
QFile outFile(args->arg(1));
outFile.open(QIODevice::WriteOnly);
QDataStream out(&outFile);
out << s;
return 0;
}
}
else args->usage();
}
示例6: main
int main(int argc, char *argv[])
{
KCmdLineArgs::init(argc, argv, appName, I18N_NOOP("KXSConfig"), description, version);
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if(args->count()==0)
exit(1);
/* We must read exactly the same resources as xscreensaver.
That means we must have both the same progclass *and* progname,
at least as far as the resource database is concerned. So,
put "xscreensaver" in argv[0] while initializing Xt.
*/
const char *dummyargs[] = { "xscreensaver" };
int dummyargc = 1;
progname = dummyargs[0];
// Teach Xt to use the Display that TQt has already opened.
XtToolkitInitialize ();
XtAppContext xtApp = XtCreateApplicationContext ();
Display *dpy = qt_xdisplay();
XtAppSetFallbackResources (xtApp, const_cast<char**>(defaults));
XtDisplayInitialize (xtApp, dpy, progname, progclass, 0, 0,
&dummyargc,
const_cast<char**>(dummyargs));
Widget toplevel_shell = XtAppCreateShell (progname, progclass,
applicationShellWidgetClass,
dpy, 0, 0);
dpy = XtDisplay (toplevel_shell);
db = XtDatabase (dpy);
XtGetApplicationNameAndClass (dpy, const_cast<char**>(&progname),
const_cast<char**>(&progclass));
TQString name = TQString::fromLocal8Bit(args->arg(args->count() - 1));
KXSConfigDialog *dialog=new KXSConfigDialog(args->arg(0), name);
if ( dialog->create() ) {
dialog->show();
app.setMainWidget(dialog);
app.exec();
} else {
KMessageBox::sorry(0,
i18n("No configuration available for %1").tqarg(name),
name );
}
delete dialog;
}
示例7: newInstance
virtual int newInstance()
{
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count() > 0)
{
menuEdit->selectMenu(args->arg(0));
if (args->count() > 1)
{
menuEdit->selectMenuEntry(args->arg(1));
}
}
args->clear();
return KUniqueApplication::newInstance();
}
示例8: main
int main( int argc, char **argv )
{
KAboutData aboutData( "testvcalexport", 0,
ki18n( "Part of LibKCal's test suite. Checks if export "
"to vCalendar still works correctly." ), "0.1" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add( "verbose", ki18n( "Verbose output" ) );
options.add( "+input", ki18n( "Name of input file" ) );
options.add( "+output", ki18n( "Name of output file" ) );
KCmdLineArgs::addCmdLineOptions( options );
KComponentData componentData( &aboutData );
//QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if ( args->count() != 2 ) {
args->usage( "Wrong number of arguments." );
}
QString input = args->arg( 0 );
QString output = args->arg( 1 );
QFileInfo outputFileInfo( output );
output = outputFileInfo.absoluteFilePath();
kDebug() << "Input file:" << input;
kDebug() << "Output file:" << output;
MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );
FileStorage instore( cal, input );
if ( !instore.load() ) {
return 1;
}
QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
if ( !tz.isEmpty() ) {
cal->setViewTimeZoneId( tz );
}
FileStorage outstore( cal, output, new VCalFormat );
if ( !outstore.save() ) {
return 1;
}
return 0;
}
示例9: main
int main( int argc, char **argv )
{
KAboutData aboutData( "khc_indexbuilder", 0,
ki18n("KHelpCenter Index Builder"),
HELPCENTER_VERSION,
ki18n("The KDE Help Center"),
KAboutData::License_GPL,
ki18n("(c) 2003, The KHelpCenter developers") );
aboutData.addAuthor( ki18n("Cornelius Schumacher"), KLocalizedString(), "[email protected]" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add("+cmdfile", ki18n("Document to be indexed"));
options.add("+indexdir", ki18n("Index directory"));
KCmdLineArgs::addCmdLineOptions( options );
// Note: no KComponentData seems necessary
QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if ( args->count() != 2 ) {
kDebug(1402) << "Wrong number of arguments.";
return 1;
}
QString cmdFile = args->arg( 0 );
QString indexDir = args->arg( 1 );
kDebug(1402) << "cmdFile: " << cmdFile;
kDebug(1402) << "indexDir: " << indexDir;
QFile file( indexDir + "/testaccess" );
if ( !file.open( QIODevice::WriteOnly ) || !file.putChar( ' ' ) ) {
kDebug(1402) << "access denied";
return 2;
} else {
kDebug(1402) << "can access";
file.remove();
}
IndexBuilder builder(cmdFile);
QTimer::singleShot(0, &builder, SLOT(buildIndices()));
return app.exec();
}
示例10: kdemain
int KDE_EXPORT kdemain( int argc, char **argv )
{
// KApplication is necessary to use other ioslaves
putenv(strdup("SESSION_MANAGER="));
KCmdLineArgs::init(argc, argv, "kio_media", 0, 0, 0, 0);
KCmdLineArgs::addCmdLineOptions( options );
KApplication app( false, false );
// We want to be anonymous even if we use DCOP
app.dcopClient()->attach();
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
MediaProtocol slave( args->arg(0), args->arg(1), args->arg(2) );
slave.dispatchLoop();
return 0;
}
示例11: kdemain
int KDE_EXPORT kdemain(int argc, char **argv)
{
// KInstance instance( "kio_trash" );
// KApplication is necessary to use kio_file
putenv(strdup("SESSION_MANAGER="));
KApplication::disableAutoDcopRegistration();
KCmdLineArgs::init(argc, argv, "kio_trash", 0, 0, 0, 0);
KCmdLineArgs::addCmdLineOptions(options);
KApplication app(false, false);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
TrashProtocol slave(args->arg(0), args->arg(1), args->arg(2));
slave.dispatchLoop();
return 0;
}
示例12: newInstance
int Application::newInstance()
{
KUniqueApplication::newInstance();
// Open the basket archive or template file supplied as argument:
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args && args->count() >= 1) {
QString fileName = args->arg(args->count() - 1);
if (QFile::exists(fileName)) {
QFileInfo fileInfo(fileName);
if (fileInfo.absoluteFilePath().contains(Global::basketsFolder())) {
QString folder = fileInfo.absolutePath().split("/").last();
folder.append("/");
BNPView::s_basketToOpen = folder;
QTimer::singleShot(100, Global::bnpView, SLOT(delayedOpenBasket()));
} else if (!fileInfo.isDir()) { // Do not mis-interpret data-folder param!
// Tags are not loaded until Global::bnpView::lateInit() is called.
// It is called 0ms after the application start.
BNPView::s_fileToOpen = fileName;
QTimer::singleShot(100, Global::bnpView, SLOT(delayedOpenArchive()));
// Global::bnpView->openArchive(fileName);
args->clear();
}
}
}
return 0;
}
示例13: main
int main(int argc, char **argv)
{
const char *version = "0.5";
KLocalizedString description = ki18n("Unit test for .netrc and kionetrc parser.");
KCmdLineOptions options;
options.add("+command", ki18n("[url1,url2 ,...]"));
KCmdLineArgs::init( argc, argv, "kionetrctest", 0, ki18n("KIO-netrc-test"), version, description );
KCmdLineArgs::addCmdLineOptions( options );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
int count = args->count();
KApplication app;
if ( !count )
args->usage();
else
{
KUrl u;
for( int i=0 ; i < count; i++ )
{
u = args->arg(i);
if ( !u.isValid() )
{
kDebug() << u.url() << " is invalid! Ignoring...";
continue;
}
output( u );
}
}
args->clear();
return 0;
}
示例14: main
int main( int argc, char *argv[] )
{
KAboutData aboutData( "kopetewallettest", 0, ki18n("kopetewallettest"), "version" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions opts;
opts.add("+action");
KCmdLineArgs::addCmdLineOptions( opts );
KApplication app( "kopetewallettest" );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
// must register with DCOP or async callbacks will fail
_out << "DCOP registration returned " << app.dcopClient()->registerAs(app.name()) << endl;
for( int i = 0; i < args->count(); ++i )
{
QString arg = args->arg( i );
_out << "Processing " << arg << endl;
if( arg == QString::fromLatin1( "open" ) ) openWalletAsync();
if( arg == QString::fromLatin1( "close" ) ) closeWallet();
if( arg == QString::fromLatin1( "delay" ) ) delay();
_out << "Done." << endl;
}
WalletReciever *r = new WalletReciever;
QTimer timer;
r->connect( &timer, SIGNAL(timeout()), SLOT(timer()) );
timer.start( 1000 );
_out << "About to start 30 second event loop" << endl;
QTimer::singleShot( 30000, qApp, SLOT(quit()) );
return qApp->exec();
}
示例15: inst
int
main(int argc, char *argv[])
{
KCmdLineArgs::init(argc, argv, "krootimage", "kdmgreet",
ki18n("KRootImage"), QByteArray(),
ki18n("Fancy desktop background for kdm"));
KCmdLineOptions options;
options.add("+config", ki18n("Name of the configuration file"));
KCmdLineArgs::addCmdLineOptions(options);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (!args->count())
args->usage();
KComponentData inst(KCmdLineArgs::aboutData());
MyApplication app(args->arg(0).toLocal8Bit(),
KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv());
args->clear();
app.exec();
app.flush();
// Keep color resources after termination
XSetCloseDownMode(QX11Info::display(), RetainTemporary);
return 0;
}