本文整理汇总了C++中KCmdLineArgs类的典型用法代码示例。如果您正苦于以下问题:C++ KCmdLineArgs类的具体用法?C++ KCmdLineArgs怎么用?C++ KCmdLineArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KCmdLineArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_UNUSED
bool KoApplication::start()
{
ResetStarting resetStarting; // reset m_starting to false when we're done
Q_UNUSED(resetStarting);
// Find the *.desktop file corresponding to the kapp instance name
KoDocumentEntry entry = KoDocumentEntry(KoDocument::readNativeService());
if (entry.isEmpty()) {
kError(30003) << KGlobal::mainComponent().componentName() << "part.desktop not found." << endl;
kError(30003) << "Run 'kde4-config --path services' to see which directories were searched, assuming kde startup had the same environment as your current shell." << endl;
kError(30003) << "Check your installation (did you install KOffice in a different prefix than KDE, without adding the prefix to /etc/kderc ?)" << endl;
return false;
}
// Get the command line arguments which we have to parse
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
int argsCount = args->count();
KCmdLineArgs *koargs = KCmdLineArgs::parsedArgs("koffice");
QString dpiValues = koargs->getOption("dpi");
if (!dpiValues.isEmpty()) {
int sep = dpiValues.indexOf(QRegExp("[x, ]"));
int dpiX;
int dpiY = 0;
bool ok = true;
if (sep != -1) {
dpiY = dpiValues.mid(sep + 1).toInt(&ok);
dpiValues.truncate(sep);
}
if (ok) {
dpiX = dpiValues.toInt(&ok);
if (ok) {
if (!dpiY) dpiY = dpiX;
KoGlobal::setDPI(dpiX, dpiY);
}
}
}
// No argument -> create an empty document
if (!argsCount) {
QString errorMsg;
KoDocument* doc = entry.createDoc(&errorMsg);
if (!doc) {
if (!errorMsg.isEmpty())
KMessageBox::error(0, errorMsg);
return false;
}
KoMainWindow *shell = new KoMainWindow(doc->componentData());
shell->show();
QObject::connect(doc, SIGNAL(sigProgress(int)), shell, SLOT(slotProgress(int)));
// for initDoc to fill in the recent docs list
// and for KoDocument::slotStarted
doc->addShell(shell);
if (doc->checkAutoSaveFile()) {
shell->setRootDocument(doc);
} else {
doc->showStartUpWidget(shell);
}
// FIXME This needs to be moved someplace else
QObject::disconnect(doc, SIGNAL(sigProgress(int)), shell, SLOT(slotProgress(int)));
} else {
const bool print = koargs->isSet("print");
const bool exportAsPdf = koargs->isSet("export-pdf");
QString pdfFileName = koargs->getOption("export-filename");
const bool doTemplate = koargs->isSet("template");
koargs->clear();
// Loop through arguments
short int n = 0; // number of documents open
short int nPrinted = 0;
for (int i = 0; i < argsCount; i++) {
// For now create an empty document
QString errorMsg;
KoDocument* doc = entry.createDoc(&errorMsg, 0);
if (doc) {
// show a shell asap
KoMainWindow *shell = new KoMainWindow(doc->componentData());
shell->show();
// are we just trying to open a template?
if (doTemplate) {
QStringList paths;
if (args->url(i).isLocalFile() && QFile::exists(args->url(i).toLocalFile())) {
paths << QString(args->url(i).toLocalFile());
kDebug(30003) << "using full path...";
} else {
QString desktopName(args->arg(i));
QString appName = KGlobal::mainComponent().componentName();
paths = KGlobal::dirs()->findAllResources("data", appName + "/templates/*/" + desktopName);
if (paths.isEmpty()) {
paths = KGlobal::dirs()->findAllResources("data", appName + "/templates/" + desktopName);
}
if (paths.isEmpty()) {
KMessageBox::error(0L, i18n("No template found for: %1 ", desktopName));
delete shell;
} else if (paths.count() > 1) {
KMessageBox::error(0L, i18n("Too many templates found for: %1", desktopName));
//.........这里部分代码省略.........
示例2: main
int main(int argc, char **argv)
{
KAboutData about("kftpgrabber", 0, ki18n("KFTPgrabber"), version, ki18n(description),
KAboutData::License_GPL, ki18n("(C) 2008, The KFTPgrabber developers"), KLocalizedString(), "http://www.kftp.org");
about.addAuthor(ki18n("Jernej Kos"), ki18n("Lead developer"), "[email protected]");
about.addAuthor(ki18n("Markus Brüffer"), ki18n("Developer"), "[email protected]");
about.addCredit(ki18n("Lee Joseph"), ki18n("Fedora ambassador responsible for promotion, testing and debugging; also a package maintainer for Fedora-compatible distributions"), "[email protected]");
about.addCredit(ki18n("libssh2 Developers"), ki18n("SSH library"), "[email protected]");
about.addCredit(ki18n("Anthony D. Urso"), ki18n("otpCalc code"));
about.addCredit(ki18n("Kopete Developers"), ki18n("KopeteBalloon popup code"), "[email protected]");
about.addCredit(ki18n("KSysGuard Developers"), ki18n("Traffic graph widget"), "[email protected]");
about.addCredit(ki18n("Bob Ziuchkovski"), ki18n("Icon design"), "[email protected]");
about.addCredit(ki18n("Tobias Ussing"), ki18n("Testing and debugging"), "[email protected]");
about.addCredit(ki18n("Tim Kosse"), ki18n("Directory parser code"), "[email protected]");
about.addCredit(ki18n("Peter Penz"), ki18n("Listview column handling code"), "[email protected]");
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions options;
options.add("+[url]", ki18n("An optional URL to connect to"));
KCmdLineArgs::addCmdLineOptions(options);
KUniqueApplication app;
if (app.isSessionRestored()) {
RESTORE(MainWindow);
} else {
MainWindow *mainWindow = 0;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KSplashScreen *splash = 0L;
QString splashPath = KStandardDirs::locate("appdata", "kftpgrabber-logo.png");
if (!KFTPCore::Config::startMinimized() && KFTPCore::Config::showSplash()) {
// Show the splash screen
if (!splashPath.isNull()) {
QPixmap splashImage = QPixmap(splashPath);
splash = new KSplashScreen(splashImage);
splash->setMaximumWidth(400);
splash->show();
}
}
mainWindow = new MainWindow();
if (!KFTPCore::Config::startMinimized())
mainWindow->show();
// Check if an URL was passed as a command line argument
if (args->count() == 1) {
KUrl remoteUrl = args->url(0);
if (!remoteUrl.isLocalFile()) {
if (!remoteUrl.port())
remoteUrl.setPort(21);
if (!remoteUrl.hasUser())
remoteUrl.setUser("anonymous");
if (!remoteUrl.hasPass()) {
if (!KFTPCore::Config::anonMail().isEmpty())
remoteUrl.setPass(KFTPCore::Config::anonMail());
else
remoteUrl.setPass("[email protected]");
}
KFTPSession::Manager::self()->spawnRemoteSession(KFTPSession::IgnoreSide, remoteUrl);
}
}
if (splash != 0L) {
splash->finish(mainWindow);
delete splash;
}
args->clear();
}
return app.exec();
}
示例3: kdemain
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));
//.........这里部分代码省略.........
示例4: main
int main( int argc, char *argv[] )
{
KAboutData aboutData( "kopetepasswordtest", 0, ki18n("kopetepasswordtest"), "version" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions opts;
opts.add("id <id>", ki18n("Config group to store password in"), "TestAccount");
opts.add("set <new>", ki18n("Set password to new"));
opts.add("error", ki18n("Claim password was erroneous"));
opts.add("prompt <prompt>", ki18n("Password prompt"), "Enter a password");
opts.add("image <filename>", ki18n("Image to display in password dialog"));
KCmdLineArgs::addCmdLineOptions( opts );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KApplication app( "kopetepasswordtest" );
bool setPassword = args->isSet("set");
QString newPwd = args->getOption("set");
QString passwordId = args->getOption("id");
bool error = args->isSet("error");
QString prompt = args->getOption("prompt");
QPixmap image = QString(args->getOption("image"));
_out << (image.isNull() ? "image is null" : "image is valid") << endl;
Password pwd( passwordId, 0, false );
pwd.setWrong( error );
_out << "Cached value is null: " << pwd.cachedValue().isNull() << endl;
QString pass = retrieve( pwd, image, prompt );
if ( !pass.isNull() )
_out << "Read password: " << pass << endl;
else
_out << "Could not read a password" << endl;
_out << "Cached value: " << (pwd.cachedValue().isNull() ? "null" : pwd.cachedValue()) << endl;
if ( setPassword )
{
if ( newPwd.isEmpty() )
{
_out << "Clearing password" << endl;
newPwd.clear();
}
else
{
_out << "Setting password to " << newPwd << endl;
}
pwd.set( newPwd );
}
// without this, setting passwords will fail since they're
// set asynchronously.
QTimer::singleShot( 0, &app, SLOT(deref()) );
app.exec();
if ( setPassword )
{
pass = retrieve( pwd, image, i18n("Hopefully this popped up because you set the password to the empty string.") );
if( pass == newPwd )
_out << "Password successfully set." << endl;
else
_out << "Failed: password ended up as " << pass << endl;
}
return 0;
}
示例5: kScreenSaverMain
int kScreenSaverMain( int argc, char** argv, KScreenSaverInterface& screenSaverInterface )
{
KLocale::setMainCatalog("libkscreensaver");
KCmdLineArgs::init(argc, argv, screenSaverInterface.aboutData());
KCmdLineOptions options;
options.add("setup", ki18n("Setup screen saver"));
options.add("window-id wid", ki18n("Run in the specified XWindow"));
options.add("root", ki18n("Run in the root XWindow"));
options.add("demo", ki18n("Start screen saver in demo mode"), "default");
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
// Set a useful default icon.
app.setWindowIcon(KIcon("preferences-desktop-screensaver"));
if (!pipe(termPipe))
{
#ifndef Q_WS_WIN
struct sigaction sa;
sa.sa_handler = termHandler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGTERM, &sa, 0);
#endif
QSocketNotifier *sn = new QSocketNotifier(termPipe[0], QSocketNotifier::Read, &app);
QObject::connect(sn, SIGNAL(activated(int)), &app, SLOT(quit()));
}
#ifdef Q_WS_X11
oldXErrorHandler = XSetErrorHandler(xErrorHandler);
#endif
KCrash::setCrashHandler( crashHandler );
KGlobal::locale()->insertCatalog("klock");
KGlobal::locale()->insertCatalog("kscreensaver");
DemoWindow *demoWidget = 0;
Window saveWin = 0;
KScreenSaver *target;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->isSet("setup"))
{
QDialog *dlg = screenSaverInterface.setup();
args->clear();
dlg->exec();
delete dlg;
return 0;
}
if (args->isSet("window-id"))
{
#ifdef Q_WS_WIN
saveWin = (HWND)(args->getOption("window-id").toULong());
#else
saveWin = args->getOption("window-id").toInt();
#endif
}
#ifdef Q_WS_X11 //FIXME
if (args->isSet("root"))
{
QX11Info inf;
saveWin = RootWindow(QX11Info::display(), inf.screen());
}
#endif
if (args->isSet("demo"))
{
saveWin = 0;
}
if (saveWin == 0)
{
demoWidget = new DemoWindow();
demoWidget->setAttribute(Qt::WA_NoSystemBackground);
demoWidget->setAttribute(Qt::WA_PaintOnScreen);
demoWidget->show();
app.processEvents();
saveWin = demoWidget->winId();
}
target = screenSaverInterface.create( saveWin );
target->setAttribute(Qt::WA_PaintOnScreen);
target->show();
if (demoWidget)
{
target->installEventFilter( demoWidget );
}
//.........这里部分代码省略.........
示例6: startApp
static int startApp()
{
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
// Stop daemon and exit?
if (args->isSet("s"))
{
KDEsuClient client;
if (client.ping() == -1)
{
kdError(1206) << "Daemon not running -- nothing to stop\n";
exit(1);
}
if (client.stopServer() != -1)
{
kdDebug(1206) << "Daemon stopped\n";
exit(0);
}
kdError(1206) << "Could not stop daemon\n";
exit(1);
}
QString icon;
if ( args->isSet("i"))
icon = args->getOption("i");
bool prompt = true;
if ( args->isSet("d"))
prompt = false;
// Get target uid
QCString user = args->getOption("u");
QCString auth_user = user;
struct passwd *pw = getpwnam(user);
if (pw == 0L)
{
kdError(1206) << "User " << user << " does not exist\n";
exit(1);
}
bool change_uid = (getuid() != pw->pw_uid);
// If file is writeable, do not change uid
QString file = QFile::decodeName(args->getOption("f"));
if (change_uid && !file.isEmpty())
{
if (file.at(0) != '/')
{
KStandardDirs dirs;
dirs.addKDEDefaults();
file = dirs.findResource("config", file);
if (file.isEmpty())
{
kdError(1206) << "Config file not found: " << file << "\n";
exit(1);
}
}
QFileInfo fi(file);
if (!fi.exists())
{
kdError(1206) << "File does not exist: " << file << "\n";
exit(1);
}
change_uid = !fi.isWritable();
}
// Get priority/scheduler
QCString tmp = args->getOption("p");
bool ok;
int priority = tmp.toInt(&ok);
if (!ok || (priority < 0) || (priority > 100))
{
KCmdLineArgs::usage(i18n("Illegal priority: %1").arg(tmp));
exit(1);
}
int scheduler = SuProcess::SchedNormal;
if (args->isSet("r"))
scheduler = SuProcess::SchedRealtime;
if ((priority > 50) || (scheduler != SuProcess::SchedNormal))
{
change_uid = true;
auth_user = "root";
}
// Get command
if (args->isSet("c"))
{
command = args->getOption("c");
for (int i=0; i<args->count(); i++)
{
QString arg = QFile::decodeName(args->arg(i));
KRun::shellQuote(arg);
command += " ";
command += QFile::encodeName(arg);
}
}
else
{
if( args->count() == 0 )
{
KCmdLineArgs::usage(i18n("No command specified."));
exit(1);
//.........这里部分代码省略.........
示例7: main
int main(int argc, char **argv)
{
KLocalizedString::setApplicationDomain( "koconverter" );
K4AboutData aboutData("calligraconverter", 0, ki18n("CalligraConverter"), CalligraVersionWrapper::versionString().toLatin1(),
ki18n("Calligra Document Converter"),
K4AboutData::License_GPL,
ki18n("(c) 2001-2011 Calligra developers"));
aboutData.addAuthor(ki18n("David Faure"), KLocalizedString(), "[email protected]");
aboutData.addAuthor(ki18n("Nicolas Goutte"), KLocalizedString(), "[email protected]");
aboutData.addAuthor(ki18n("Dan Leinir Turthra Jensen"), KLocalizedString(), "[email protected]");
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions options;
options.add("+in", ki18n("Input file"));
options.add("+out", ki18n("Output file"));
options.add("backup", ki18n("Make a backup of the destination file"));
options.add("batch", ki18n("Batch mode: do not show dialogs"));
options.add("interactive", ki18n("Interactive mode: show dialogs (default)"));
options.add("mimetype <mime>", ki18n("Mimetype of the output file"));
// PDF related options.
options.add("print-orientation <name>", ki18n("The print orientation. This could be either Portrait or Landscape."));
options.add("print-papersize <name>", ki18n("The paper size. A4, Legal, Letter, ..."));
options.add("print-margin <size>", ki18n("The size of the paper margin. By default this is 0.2."));
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
// Get the command line arguments which we have to parse
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count() != 2) {
KCmdLineArgs::usageError(i18n("Two arguments required"));
return 3;
}
const QUrl urlIn = args->url(0);
const QUrl urlOut = args->url(1);
// Are we in batch mode or in interactive mode.
bool batch = args->isSet("batch");
if (args->isSet("interactive")) {
batch = false;
}
if (args->isSet("backup")) {
// Code form koDocument.cc
KIO::UDSEntry entry;
if (KIO::NetAccess::stat(urlOut, entry, 0L)) { // this file exists => backup
kDebug() << "Making backup...";
QUrl backup(urlOut);
backup.setPath(urlOut.path() + '~');
KIO::FileCopyJob *job = KIO::file_copy(urlOut, backup, -1, KIO::Overwrite | KIO::HideProgressInfo);
job->exec();
}
}
QMimeDatabase db;
QMimeType inputMimetype = db.mimeTypeForUrl(urlIn);
if (!inputMimetype.isValid() || inputMimetype.isDefault()) {
kError() << i18n("Mimetype for input file %1 not found!", urlIn.toDisplayString()) << endl;
return 1;
}
QMimeType outputMimetype;
if (args->isSet("mimetype")) {
QString mime = args->getOption("mimetype");
outputMimetype = db.mimeTypeForName(mime);
if (! outputMimetype.isValid()) {
kError() << i18n("Mimetype not found %1", mime) << endl;
return 1;
}
} else {
outputMimetype = db.mimeTypeForUrl(urlOut);
if (!outputMimetype.isValid() || outputMimetype.isDefault()) {
kError() << i18n("Mimetype not found, try using the -mimetype option") << endl;
return 1;
}
}
QApplication::setOverrideCursor(Qt::WaitCursor);
QString outputFormat = outputMimetype.name();
bool ok = false;
if (outputFormat == "application/pdf") {
QString orientation = args->getOption("print-orientation");
QString papersize = args->getOption("print-papersize");
QString margin = args->getOption("print-margin");
ok = convertPdf(urlIn, inputMimetype.name(), urlOut, outputFormat, orientation, papersize, margin);
} else {
ok = convert(urlIn, inputMimetype.name(), urlOut, outputFormat, batch);
}
QTimer::singleShot(0, &app, SLOT(quit()));
app.exec();
QApplication::restoreOverrideCursor();
if (!ok) {
//.........这里部分代码省略.........
示例8: gpgPath
int KGpgApp::newInstance()
{
if (!running) {
running = true;
const QString gpgPath(KGpgSettings::gpgConfigPath());
const QString gpgError = GPGProc::getGpgStartupError(KGpgSettings::gpgBinaryPath());
if (!gpgError.isEmpty()) {
KMessageBox::detailedError(0, i18n("GnuPG failed to start.<br />You must fix the GnuPG error first before running KGpg."), gpgError, i18n("GnuPG error"));
KApplication::quit();
}
s_keyManager = new KeysManager();
w = new KGpgExternalActions(s_keyManager, s_keyManager->getModel());
connect(s_keyManager, SIGNAL(readAgainOptions()), w, SLOT(readOptions()));
connect(w, SIGNAL(updateDefault(QString)), SLOT(assistantOver(QString)));
connect(w, SIGNAL(createNewKey()), s_keyManager, SLOT(slotGenerateKey()));
if (!gpgPath.isEmpty()) {
if ((KgpgInterface::getGpgBoolSetting(QLatin1String( "use-agent" ), gpgPath)) && (qgetenv("GPG_AGENT_INFO").isEmpty()))
KMessageBox::sorry(0, i18n("<qt>The use of <b>GnuPG Agent</b> is enabled in GnuPG's configuration file (%1).<br />"
"However, the agent does not seem to be running. This could result in problems with signing/decryption.<br />"
"Please disable GnuPG Agent from KGpg settings, or fix the agent.</qt>", gpgPath));
}
}
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
// parsing of command line args
if (args->isSet("k") || (!KGpgSettings::showSystray() && (args->count() == 0) && !args->isSet("d"))) {
s_keyManager->show();
KWindowSystem::setOnDesktop(s_keyManager->winId(), KWindowSystem::currentDesktop()); //set on the current desktop
KWindowSystem::unminimizeWindow(s_keyManager->winId()); //de-iconify window
s_keyManager->raise(); // set on top
} else if (args->isSet("d")) {
s_keyManager->slotOpenEditor();
s_keyManager->hide();
} else {
KUrl::List urlList;
for (int ct = 0; ct < args->count(); ct++)
urlList.append(args->url(ct));
bool directoryInside = false;
foreach (const KUrl &url, urlList)
if (KMimeType::findByUrl(url)->name() == QLatin1String( "inode/directory" )) {
directoryInside = true;
break;
}
if (args->isSet("e")) {
if (urlList.isEmpty())
KMessageBox::sorry(0, i18n("No files given."));
else if (!directoryInside)
KGpgExternalActions::encryptFiles(s_keyManager, urlList);
else
KGpgExternalActions::encryptFolders(s_keyManager, urlList);
} else if (args->isSet("s")) {
if (urlList.isEmpty())
KMessageBox::sorry(0, i18n("No files given."));
else if (!directoryInside)
w->showDroppedFile(urlList.first());
else
KMessageBox::sorry(0, i18n("Cannot decrypt and show folder."));
} else if (args->isSet("S")) {
if (urlList.isEmpty())
KMessageBox::sorry(0, i18n("No files given."));
else if (!directoryInside)
KGpgExternalActions::signFiles(s_keyManager, urlList);
else
KMessageBox::sorry(0, i18n("Cannot sign folder."));
} else if (args->isSet("V") != 0) {
if (urlList.isEmpty())
KMessageBox::sorry(0, i18n("No files given."));
else if (!directoryInside)
w->verifyFile(urlList.first());
else
KMessageBox::sorry(0, i18n("Cannot verify folder."));
} else {
if (directoryInside && (urlList.count() > 1)) {
KMessageBox::sorry(0, i18n("Unable to perform requested operation.\nPlease select only one folder, or several files, but do not mix files and folders."));
return 0;
}
if (urlList.isEmpty()) {
/* do nothing */
} else if (urlList.first().fileName().endsWith(QLatin1String(".sig"))) {
w->verifyFile(urlList.first());
} else {
bool haskeys = false;
bool hastext = false;
foreach (const KUrl &url, urlList) {
QFile qfile(url.path());
if (qfile.open(QIODevice::ReadOnly)) {
const int probelen = 4096;
QTextStream t(&qfile);
QString probetext(t.read(probelen));
//.........这里部分代码省略.........
示例9: main
int main(int argc, char *argv[])
{
KCmdLineArgs::init(argc, argv, "Testkhtml", "a basic web browser using the KHTML library", "1.0");
KCmdLineArgs::addCmdLineOptions(options);
KApplication a;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs( );
if ( args->count() == 0 ) {
KCmdLineArgs::usage();
::exit( 1 );
}
KHTMLFactory *fac = new KHTMLFactory();
KMainWindow *toplevel = new KMainWindow();
KHTMLPart *doc = new KHTMLPart( toplevel, 0, toplevel, 0, KHTMLPart::BrowserViewGUI );
Dummy *dummy = new Dummy( doc );
QObject::connect( doc->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ),
dummy, SLOT( slotOpenURL( const KURL&, const KParts::URLArgs & ) ) );
if (args->url(0).url().right(4).find(".xml", 0, false) == 0) {
KParts::URLArgs ags(doc->browserExtension()->urlArgs());
ags.serviceType = "text/xml";
doc->browserExtension()->setURLArgs(ags);
}
doc->openURL( args->url(0) );
// DOMTreeView * dtv = new DOMTreeView(0, doc, "DomTreeView");
// dtv->show();
toplevel->setCentralWidget( doc->widget() );
toplevel->resize( 640, 800);
// dtv->resize(toplevel->width()/2, toplevel->height());
QDomDocument d = doc->domDocument();
QDomElement viewMenu = d.documentElement().firstChild().childNodes().item( 2 ).toElement();
QDomElement e = d.createElement( "action" );
e.setAttribute( "name", "debugRenderTree" );
viewMenu.appendChild( e );
e = d.createElement( "action" );
e.setAttribute( "name", "debugDOMTree" );
viewMenu.appendChild( e );
QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement();
e = d.createElement( "action" );
e.setAttribute( "name", "reload" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "print" );
toolBar.insertBefore( e, toolBar.firstChild() );
(void)new KAction( "Reload", "reload", Qt::Key_F5, dummy, SLOT( reload() ), doc->actionCollection(), "reload" );
KAction* kprint = new KAction( "Print", "print", 0, doc->browserExtension(), SLOT( print() ), doc->actionCollection(), "print" );
kprint->setEnabled(true);
toplevel->guiFactory()->addClient( doc );
doc->setJScriptEnabled(true);
doc->setJavaEnabled(true);
doc->setURLCursor(QCursor(Qt::PointingHandCursor));
a.setTopWidget(doc->widget());
QWidget::connect(doc, SIGNAL(setWindowCaption(const QString &)),
doc->widget(), SLOT(setCaption(const QString &)));
doc->widget()->show();
toplevel->show();
((QScrollView *)doc->widget())->viewport()->show();
int ret = a.exec();
//delete doc;
//delete dtv;
khtml::Cache::clear();
khtml::CSSStyleSelector::clear();
khtml::RenderStyle::cleanup();
delete fac;
return ret;
}
示例10: main
int main(int argc, char *argv[])
{
KCmdLineOptions options;
options.add("+file", ki18n("URL to open"));
KCmdLineArgs::init(argc, argv, "testkhtml", 0, ki18n("Testkhtml"),
"1.0", ki18n("a basic web browser using the KHTML library"));
KCmdLineArgs::addCmdLineOptions(options);
KApplication a;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs( );
if ( args->count() == 0 ) {
KCmdLineArgs::usage();
::exit( 1 );
}
new KHTMLGlobal;
KXmlGuiWindow *toplevel = new KXmlGuiWindow();
KHTMLPart *doc = new KHTMLPart( toplevel, toplevel, KHTMLPart::BrowserViewGUI );
Dummy *dummy = new Dummy( doc );
QObject::connect( doc->browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
dummy, SLOT(slotOpenURL(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );
QObject::connect( doc, SIGNAL(completed()), dummy, SLOT(handleDone()) );
if (args->url(0).url().right(4).toLower() == ".xml") {
KParts::OpenUrlArguments args(doc->arguments());
args.setMimeType("text/xml");
doc->setArguments(args);
}
doc->openUrl( args->url(0) );
toplevel->setCentralWidget( doc->widget() );
toplevel->resize( 800, 600);
QDomDocument d = doc->domDocument();
QDomElement viewMenu = d.documentElement().firstChild().childNodes().item( 2 ).toElement();
QDomElement e = d.createElement( "action" );
e.setAttribute( "name", "debugRenderTree" );
viewMenu.appendChild( e );
e = d.createElement( "action" );
e.setAttribute( "name", "debugDOMTree" );
viewMenu.appendChild( e );
e = d.createElement( "action" );
e.setAttribute( "name", "debugDoBenchmark" );
viewMenu.appendChild( e );
QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement();
e = d.createElement( "action" );
e.setAttribute( "name", "editable" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "navigable" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "reload" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "print" );
toolBar.insertBefore( e, toolBar.firstChild() );
KAction *action = new KAction(KIcon("view-refresh"), "Reload", doc );
doc->actionCollection()->addAction( "reload", action );
QObject::connect(action, SIGNAL(triggered(bool)), dummy, SLOT(reload()));
action->setShortcut(Qt::Key_F5);
KAction *bench = new KAction( KIcon(), "Benchmark...", doc );
doc->actionCollection()->addAction( "debugDoBenchmark", bench );
QObject::connect(bench, SIGNAL(triggered(bool)), dummy, SLOT(doBenchmark()));
KAction *kprint = new KAction(KIcon("document-print"), "Print", doc );
doc->actionCollection()->addAction( "print", kprint );
QObject::connect(kprint, SIGNAL(triggered(bool)), doc->browserExtension(), SLOT(print()));
kprint->setEnabled(true);
KToggleAction *ta = new KToggleAction( KIcon("edit-rename"), "Navigable", doc );
doc->actionCollection()->addAction( "navigable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(doc->isCaretMode());
QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleNavigable(bool)));
ta = new KToggleAction( KIcon("document-properties"), "Editable", doc );
doc->actionCollection()->addAction( "editable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(doc->isEditable());
QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleEditable(bool)));
toplevel->guiFactory()->addClient( doc );
doc->setJScriptEnabled(true);
doc->setJavaEnabled(true);
doc->setPluginsEnabled( true );
doc->setURLCursor(QCursor(Qt::PointingHandCursor));
a.setTopWidget(doc->widget());
QWidget::connect(doc, SIGNAL(setWindowCaption(QString)),
doc->widget()->topLevelWidget(), SLOT(setCaption(QString)));
doc->widget()->show();
toplevel->show();
doc->view()->viewport()->show();
doc->view()->widget()->show();
//.........这里部分代码省略.........
示例11: main
int main(int argc, char **argv)
{
KAboutData about("kwinstartmenu", 0, ki18n("kwinstartmenu"), "1.4",
ki18n("An application to create/update or remove Windows Start Menu entries"),
KAboutData::License_GPL,
ki18n("(C) 2008-2011 Ralf Habacker"));
KCmdLineArgs::init( argc, argv, &about);
KCmdLineOptions options;
options.add("remove", ki18n("remove installed start menu entries"));
options.add("install", ki18n("install start menu entries"));
options.add("update", ki18n("update start menu entries"));
options.add("cleanup", ki18n("remove start menu entries from unused kde installation"));
options.add("query-path", ki18n("query root path of start menu entries"));
options.add("enable-categories", ki18n("use categories for start menu entries (default)"));
options.add("disable-categories", ki18n("don't use categories for start menu entries"));
options.add("categories", ki18n("query current value of categories in start menu"));
options.add("set-custom-string <argument>", ki18n("set custom string for root start menu entry"));
// @TODO unset-custom-string is required because args->isSet("set-root-custom-string") do not
// detect --set-custom-string "" as present set-root-custom-string option and
options.add("unset-custom-string", ki18n("remove custom string from root start menu entry"));
options.add("custom-string", ki18n("query current value of root start menu entry custom string"));
options.add("set-name-string <argument>", ki18n("set custom name string for root start menu entry"));
options.add("unset-name-string", ki18n("remove custom name string from root start menu entry"));
options.add("name-string", ki18n("query current value of start menu entry custom name string"));
options.add("set-version-string <argument>", ki18n("set custom version string for root start menu entry"));
options.add("unset-version-string", ki18n("remove custom version string from root start menu entry"));
options.add("version-string", ki18n("query current value of root start menu entry version string"));
KCmdLineArgs::addCmdLineOptions( options ); // Add my own options.
KComponentData a(&about);
// Get application specific arguments
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KApplication app(false);
// override global settings from command line
if (args->isSet("categories"))
fprintf(stdout,"%s",settings.useCategories() ? "on" : "off");
else if (args->isSet("enable-categories"))
{
settings.setUseCategories(true);
}
else if (args->isSet("disable-categories"))
{
settings.setUseCategories(false);
}
if (args->isSet("custom-string"))
fprintf(stdout,"%s",qPrintable(settings.customString()));
else if (args->isSet("unset-custom-string"))
{
settings.setCustomString("");
}
else if (args->isSet("set-custom-string"))
{
settings.setCustomString(args->getOption("set-custom-string"));
}
if (args->isSet("name-string"))
fprintf(stdout,"%s",qPrintable(settings.nameString()));
else if (args->isSet("unset-name-string"))
{
settings.setNameString("");
}
else if (args->isSet("set-name-string"))
{
settings.setNameString(args->getOption("set-name-string"));
}
if (args->isSet("version-string"))
fprintf(stdout,"%s",qPrintable(settings.versionString()));
else if (args->isSet("unset-version-string"))
{
settings.setVersionString("");
}
else if (args->isSet("set-version-string"))
{
settings.setVersionString(args->getOption("set-version-string"));
}
// determine initial values on fresh install or remove
if (settings.nameString().isEmpty() && settings.versionString().isEmpty() && settings.customString().isEmpty())
{
if (args->isSet("install"))
{
QString version = KDE::versionString();
QStringList versions = version.split(' ');
settings.setVersionString(versions[0]);
settings.setNameString("KDE");
kWarning() << "no name, version or custom string set, using default values for install" << settings.nameString() << settings.versionString();
}
else if (args->isSet("remove") || args->isSet("update"))
{
//.........这里部分代码省略.........
示例12: main
int main( int argc, char **argv )
{
KAboutData aboutData(
"testrecurrencenew", 0,
ki18n( "Load recurrence rules with the new class and print out debug messages" ), "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( "optional name of output file for the recurrence dates" ) );
KCmdLineArgs::addCmdLineOptions( options );
KComponentData componentData( &aboutData );
//QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if ( args->count() < 1 ) {
args->usage( "Wrong number of arguments." );
}
QString input = args->arg( 0 );
kDebug() << "Input file:" << input;
QTextStream *outstream;
outstream = 0;
QString fn( "" );
if ( args->count() > 1 ) {
fn = args->arg( 1 );
kDebug() << "We have a file name given:" << fn;
}
QFile outfile( fn );
if ( !fn.isEmpty() && outfile.open( QIODevice::WriteOnly ) ) {
kDebug() << "Opened output file!!!";
outstream = new QTextStream( &outfile );
}
MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );
KDateTime::Spec viewSpec;
FileStorage store( cal, input );
if ( !store.load() ) return 1;
QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
if ( !tz.isEmpty() ) {
viewSpec = KDateTime::Spec( KSystemTimeZones::zone( tz ) );
}
Incidence::List inc = cal->incidences();
for ( Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it ) {
Incidence::Ptr incidence = *it;
kDebug() << "*+*+*+*+*+*+*+*+*+*";
kDebug() << " ->" << incidence->summary() << "<-";
incidence->recurrence()->dump();
KDateTime dt( incidence->recurrence()->endDateTime() );
int i = 0;
if ( outstream ) {
if ( !dt.isValid() ) {
if ( viewSpec.isValid() ) {
dt = KDateTime( QDate( 2011, 1, 1 ), QTime( 0, 0, 1 ), viewSpec );
} else {
dt = KDateTime( QDate( 2011, 1, 1 ), QTime( 0, 0, 1 ) );
}
} else {
dt = dt.addYears( 2 );
}
kDebug() << "-------------------------------------------";
kDebug() << " *~*~*~*~ Starting with date:" << dumpTime( dt, viewSpec );
// Output to file for testing purposes
while ( dt.isValid() && i < 500 ) {
++i;
dt = incidence->recurrence()->getPreviousDateTime( dt );
if ( dt.isValid() ) {
(*outstream) << dumpTime( dt, viewSpec ) << endl;
}
}
} else {
if ( !dt.isValid() ) {
dt = KDateTime( QDate( 2005, 7, 31 ), QTime( 23, 59, 59 ), KDateTime::Spec::UTC() );
} else {
dt = dt.addYears( 2 );
}
incidence->recurrence()->dump();
kDebug() << "-------------------------------------------";
kDebug() << " *~*~*~*~ Starting with date:" << dumpTime( dt, viewSpec );
// Output to konsole
while ( dt.isValid() && i < 50 ) {
++i;
kDebug() << "-------------------------------------------";
dt = incidence->recurrence()->getPreviousDateTime( dt );
if ( dt.isValid() ) {
kDebug() << " *~*~*~*~ Previous date is:" << dumpTime( dt, viewSpec );
}
}
}
}
//.........这里部分代码省略.........
示例13: main
int main( int argc, char *argv[] )
{
QList<QByteArray> argvOrig; //We copy the original argv here, as it seems that KCmdLineArgs changes the arguments ("--style" becomes "-style")
for(int a = 0; a < argc; ++a)
argvOrig << argv[a];
static const char description[] = I18N_NOOP( "The KDevelop Integrated Development Environment" );
KAboutData aboutData( "kdevelop", 0, ki18n( "KDevelop" ),
i18n("%1", QString(VERSION) ).toUtf8(), ki18n(description), KAboutData::License_GPL,
ki18n( "Copyright 1999-2010, The KDevelop developers" ), KLocalizedString(), "http://www.kdevelop.org/" );
aboutData.addAuthor( ki18n("Andreas Pakulat"), ki18n( "Maintainer, Architecture, VCS Support, Project Management Support, QMake Projectmanager" ), "[email protected]" );
aboutData.addAuthor( ki18n("Alexander Dymo"), ki18n( "Architecture, Sublime UI, Ruby support" ), "[email protected]" );
aboutData.addAuthor( ki18n("David Nolden"), ki18n( "Definition-Use Chain, C++ Support, Code Navigation, Code Completion, Coding Assistance, Refactoring" ), "[email protected]" );
aboutData.addAuthor( ki18n("Aleix Pol Gonzalez"), ki18n( "CMake Support, Run Support, Kross Support" ), "[email protected]" );
aboutData.addAuthor( ki18n("Vladimir Prus"), ki18n( "GDB integration" ), "[email protected]" );
aboutData.addAuthor( ki18n("Hamish Rodda"), ki18n( "Text editor integration, definition-use chain" ), "[email protected]" );
aboutData.addAuthor( ki18n("Amilcar do Carmo Lucas"), ki18n( "Website admin, API documentation, Doxygen and autoproject patches" ), "[email protected]" );
aboutData.addAuthor( ki18n("Niko Sams"), ki18n( "GDB integration, Webdevelopment Plugins" ), "[email protected]" );
aboutData.addAuthor( ki18n("Milian Wolff"), ki18n( "Generic manager, Webdevelopment Plugins, Snippets, Performance" ), "[email protected]" );
aboutData.addCredit( ki18n("Matt Rogers"), KLocalizedString(), "[email protected]");
aboutData.addCredit( ki18n("Cédric Pasteur"), ki18n("astyle and indent support"), "[email protected]" );
aboutData.addCredit( ki18n("Evgeniy Ivanov"), ki18n("Distributed VCS, Git, Mercurial"), "[email protected]" );
// QTest integration is separate in playground currently.
//aboutData.addCredit( ki18n("Manuel Breugelmanns"), ki18n( "Veritas, QTest integration"), "[email protected]" );
aboutData.addCredit( ki18n("Robert Gruber") , ki18n( "SnippetPart, debugger and usability patches" ), "[email protected]" );
aboutData.addCredit( ki18n("Dukju Ahn"), ki18n( "Subversion plugin, Custom Make Manager, Overall improvements" ), "[email protected]" );
aboutData.addCredit( ki18n("Harald Fernengel"), ki18n( "Ported to Qt 3, patches, valgrind, diff and perforce support" ), "[email protected]" );
aboutData.addCredit( ki18n("Roberto Raggi"), ki18n( "C++ parser" ), "[email protected]" );
aboutData.addCredit( ki18n("The KWrite authors"), ki18n( "Kate editor component" ), "[email protected]" );
aboutData.addCredit( ki18n("Nokia Corporation/Qt Software"), ki18n( "Designer code" ), "[email protected]" );
aboutData.addCredit( ki18n("Contributors to older versions:"), KLocalizedString(), "" );
aboutData.addCredit( ki18n("The KHTML authors"), ki18n( "HTML documentation component" ), "[email protected]" );
aboutData.addCredit( ki18n("Bernd Gehrmann"), ki18n( "Initial idea, basic architecture, much initial source code" ), "[email protected]" );
aboutData.addCredit( ki18n("Caleb Tennis"), ki18n( "KTabBar, bugfixes" ), "[email protected]" );
aboutData.addCredit( ki18n("Richard Dale"), ki18n( "Java & Objective C support" ), "[email protected]" );
aboutData.addCredit( ki18n("John Birch"), ki18n( "Debugger frontend" ), "[email protected]" );
aboutData.addCredit( ki18n("Sandy Meier"), ki18n( "PHP support, context menu stuff" ), "[email protected]" );
aboutData.addCredit( ki18n("Kurt Granroth"), ki18n( "KDE application templates" ), "[email protected]" );
aboutData.addCredit( ki18n("Ian Reinhart Geiser"), ki18n( "Dist part, bash support, application templates" ), "[email protected]" );
aboutData.addCredit( ki18n("Matthias Hoelzer-Kluepfel"), ki18n( "Several components, htdig indexing" ), "[email protected]" );
aboutData.addCredit( ki18n("Victor Roeder"), ki18n( "Help with Automake manager and persistent class store" ), "[email protected]" );
aboutData.addCredit( ki18n("Simon Hausmann"), ki18n( "Help with KParts infrastructure" ), "[email protected]" );
aboutData.addCredit( ki18n("Oliver Kellogg"), ki18n( "Ada support" ), "[email protected]" );
aboutData.addCredit( ki18n("Jakob Simon-Gaarde"), ki18n( "QMake projectmanager" ), "[email protected]" );
aboutData.addCredit( ki18n("Falk Brettschneider"), ki18n( "MDI modes, QEditor, bugfixes" ), "[email protected]" );
aboutData.addCredit( ki18n("Mario Scalas"), ki18n( "PartExplorer, redesign of CvsPart, patches, bugs(fixes)" ), "[email protected]" );
aboutData.addCredit( ki18n("Jens Dagerbo"), ki18n( "Replace, Bookmarks, FileList and CTags2 plugins. Overall improvements and patches" ), "[email protected]" );
aboutData.addCredit( ki18n("Julian Rockey"), ki18n( "Filecreate part and other bits and patches" ), "[email protected]" );
aboutData.addCredit( ki18n("Ajay Guleria"), ki18n( "ClearCase support" ), "[email protected]" );
aboutData.addCredit( ki18n("Marek Janukowicz"), ki18n( "Ruby support" ), "[email protected]" );
aboutData.addCredit( ki18n("Robert Moniot"), ki18n( "Fortran documentation" ), "[email protected]" );
aboutData.addCredit( ki18n("Ka-Ping Yee"), ki18n( "Python documentation utility" ), "[email protected]" );
aboutData.addCredit( ki18n("Dimitri van Heesch"), ki18n( "Doxygen wizard" ), "[email protected]" );
aboutData.addCredit( ki18n("Hugo Varotto"), ki18n( "Fileselector component" ), "[email protected]" );
aboutData.addCredit( ki18n("Matt Newell"), ki18n( "Fileselector component" ), "[email protected]" );
aboutData.addCredit( ki18n("Daniel Engelschalt"), ki18n( "C++ code completion, persistent class store" ), "[email protected]" );
aboutData.addCredit( ki18n("Stephane Ancelot"), ki18n( "Patches" ), "[email protected]" );
aboutData.addCredit( ki18n("Jens Zurheide"), ki18n( "Patches" ), "[email protected]" );
aboutData.addCredit( ki18n("Luc Willems"), ki18n( "Help with Perl support" ), "[email protected]" );
aboutData.addCredit( ki18n("Marcel Turino"), ki18n( "Documentation index view" ), "[email protected]" );
aboutData.addCredit( ki18n("Yann Hodique"), ki18n( "Patches" ), "[email protected]" );
aboutData.addCredit( ki18n("Tobias Gl\303\244\303\237er") , ki18n( "Documentation Finder, qmake projectmanager patches, usability improvements, bugfixes ... " ), "[email protected]" );
aboutData.addCredit( ki18n("Andreas Koepfle") , ki18n( "QMake project manager patches" ), "[email protected]" );
aboutData.addCredit( ki18n("Sascha Cunz") , ki18n( "Cleanup and bugfixes for qEditor, AutoMake and much other stuff" ), "[email protected]" );
aboutData.addCredit( ki18n("Zoran Karavla"), ki18n( "Artwork for the ruby language" ), "[email protected]", "http://the-error.net" );
//we can't use KCmdLineArgs as it doesn't allow arguments for the debugee
//so lookup the --debug switch and eat everything behind by decrementing argc
//debugArgs is filled with args after --debug <debuger>
QStringList debugArgs;
{
bool debugFound = false;
int c = argc;
for (int i=0; i < c; ++i) {
if (debugFound) {
debugArgs << argv[i];
} else if (QString(argv[i]) == "--debug") {
if (argc <= i+1) {
argc = i + 1;
} else {
i++;
argc = i + 1;
}
debugFound = true;
} else if (QString(argv[i]).startsWith("--debug=")) {
argc = i + 1;
debugFound = true;
}
}
}
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add("project <project>", ki18n( "Url to project to load" ));
options.add("+files", ki18n( "Files to load" ));
options.add("debug <debugger>", ki18n( "Start debugger, for example gdb. The binary that should be debugged must follow - including arguments." ));
options.add("cs <name>", ki18n("Create new session with given name."));
//.........这里部分代码省略.........
示例14: 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();
}
示例15: KMainWindow
KuickShow::KuickShow( const char *name )
: KMainWindow( 0L, name ),
m_slideshowCycle( 1 ),
fileWidget( 0L ),
dialog( 0L ),
id( 0L ),
m_viewer( 0L ),
oneWindowAction( 0L ),
m_accel( 0L ),
m_delayedRepeatItem( 0L ),
m_slideShowStopped(false)
{
aboutWidget = 0L;
kdata = new KuickData;
kdata->load();
initImlib();
resize( 400, 500 );
m_slideTimer = new QTimer( this );
connect( m_slideTimer, SIGNAL( timeout() ), SLOT( nextSlide() ));
KConfig *kc = KGlobal::config();
bool isDir = false; // true if we get a directory on the commandline
// parse commandline options
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
// files to display
// either a directory to display, an absolute path, a relative path, or a URL
KURL startDir;
startDir.setPath( QDir::currentDirPath() + '/' );
int numArgs = args->count();
if ( numArgs >= 10 )
{
// Even though the 1st i18n string will never be used, it needs to exist for plural handling - mhunter
if ( KMessageBox::warningYesNo(
this,
i18n("Do you really want to display this 1 image at the same time? This might be quite resource intensive and could overload your computer.<br>If you choose %1, only the first image will be shown.",
"Do you really want to display these %n images at the same time? This might be quite resource intensive and could overload your computer.<br>If you choose %1, only the first image will be shown.", numArgs).arg(KStdGuiItem::no().plainText()),
i18n("Display Multiple Images?"))
!= KMessageBox::Yes )
{
numArgs = 1;
}
}
for ( int i = 0; i < numArgs; i++ ) {
KURL url = args->url( i );
KFileItem item( KFileItem::Unknown, KFileItem::Unknown, url, false );
// for remote URLs, we don't know if it's a file or directory, but
// FileWidget::isImage() should correct in most cases.
// For non-local non-images, we just assume directory.
if ( FileWidget::isImage( &item ) )
{
showImage( &item, true, false, true ); // show in new window, not fullscreen-forced and move to 0,0
// showImage( &item, true, false, false ); // show in new window, not fullscreen-forced and not moving to 0,0
}
else if ( item.isDir() )
{
startDir = url;
isDir = true;
}
// need to check remote files
else if ( !url.isLocalFile() )
{
KMimeType::Ptr mime = KMimeType::findByURL( url );
QString name = mime->name();
if ( name == "application/octet-stream" ) // unknown -> stat()
name = KIO::NetAccess::mimetype( url, this );
// text/* is a hack for bugs.kde.org-attached-images urls.
// The real problem here is that NetAccess::mimetype does a HTTP HEAD, which doesn't
// always return the right mimetype. The rest of KDE start a get() instead....
if ( name.startsWith( "image/" ) || name.startsWith( "text/" ) )
{
FileWidget::setImage( item, true );
showImage( &item, true, false, true );
}
else // assume directory, KDirLister will tell us if we can't list
{
startDir = url;
isDir = true;
}
}
// else // we don't handle local non-images
}
if ( (kdata->startInLastDir && args->count() == 0) || args->isSet( "lastfolder" )) {
kc->setGroup( "SessionSettings");
startDir = kc->readPathEntry( "CurrentDirectory", startDir.url() );
}
if ( s_viewers.isEmpty() || isDir ) {
//.........这里部分代码省略.........