From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kommander/executor/main.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 kommander/executor/main.cpp (limited to 'kommander/executor/main.cpp') diff --git a/kommander/executor/main.cpp b/kommander/executor/main.cpp new file mode 100644 index 00000000..589ec1cd --- /dev/null +++ b/kommander/executor/main.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** + main.cpp - description + ------------------- + begin : Tue Aug 13 09:31:50 EST 2002 + copyright : (C) 2002 by Marc Britton + email : consume@optushome.com.au + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* KDE INCLUDES */ +#include +#include +#include +#include +#include +#include +#include + +/* QT INCLUDES */ +#include +#include +#include + +/* OTHER INCLUDES */ +#include +#include +#include "instance.h" +#include +#include + +using std::cout; +using std::endl; +using std::cerr; + + +static const char *description = + I18N_NOOP("Executor is a component of the Kommander dialog system that executes .kmdr files given as arguments or via stdin"); +// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE + +static KCmdLineOptions options[] = +{ + { "!stdin", I18N_NOOP("Read dialog from standard input"), 0}, + { "c ", I18N_NOOP("Use given catalog for translation"), 0}, + { "+[file]", I18N_NOOP("Dialog to open"), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char *argv[]) +{ + KAboutData aboutData( "kmdr-executor", I18N_NOOP("Kommander Executor"), + KOMMANDER_VERSION, description, KAboutData::License_GPL, + "(c) 2002, Marc Britton, (C) 2008 Andras Mantia", 0, 0, "http://kommander.kdewebdev.org"); + aboutData.addAuthor("Andras Mantia", I18N_NOOP("Current maintainer"), "amantia@kdewebdev.org"); + aboutData.addAuthor("Michal Rudolf", I18N_NOOP("Previous maintainer"), "mrudolf@kdewebdev.org"); + aboutData.addAuthor("Marc Britton", I18N_NOOP("Original author"), "consume@optusnet.com.au"); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + if (args->isSet("c")) + KLocale::setMainCatalogue(args->getOption("c")); + else if (args->count()) + { + char buf[200]; + QString baseFile = args->url(0).fileName(); + int ext = baseFile.findRev('.'); + if (ext != -1) + baseFile = baseFile.left(ext); + strcpy(buf, baseFile.latin1()); + KLocale::setMainCatalogue(buf); + } + else + KLocale::setMainCatalogue("kommander"); + KApplication app; + + QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); + if (!args->count()) + { + KMessageBox::sorry(0, i18n("Error: no dialog given. Use --stdin option to read dialog from standard input.\n")); + return -1; + } + Instance instance; + if (!instance.build(args->isSet("stdin") ? QString() : args->url(0))) + return -1; + + // Read command-line variables + QStringList cmdargs; + for (int i = !args->isSet("stdin"); icount(); i++) + cmdargs.append(args->arg(i)); + instance.addCmdlineArguments(cmdargs); + + instance.run(); + return 0; +} -- cgit v1.2.3