not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / tools / engineexplorer / main.cpp
blob251e948a8e8bce6b32636163107c6a27ad9a8124
1 /*
2 * Copyright 2006 Aaron Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include <KApplication>
21 #include <KAboutData>
22 #include <KCmdLineArgs>
23 #include <KLocale>
25 #include "engineexplorer.h"
27 static const char description[] = I18N_NOOP("Explore the data published by Plasma DataEngines");
28 static const char version[] = "0.0";
30 int main(int argc, char **argv)
32 KAboutData aboutData("plasmaengineexplorer", 0, ki18n("Plasma Engine Explorer"),
33 version, ki18n(description), KAboutData::License_GPL,
34 ki18n("(c) 2006, The KDE Team"));
35 aboutData.addAuthor(ki18n("Aaron J. Seigo"),
36 ki18n( "Author and maintainer" ),
37 "aseigo@kde.org");
39 KCmdLineArgs::init(argc, argv, &aboutData);
41 KCmdLineOptions options;
42 options.add("height <pixels>", ki18n("The desired height in pixels"));
43 options.add("width <pixels>", ki18n("The desired width in pixels"));
44 options.add("x <pixels>", ki18n("The desired x position in pixels"));
45 options.add("y <pixels>", ki18n("The desired y position in pixels"));
46 options.add("engine <data engine>", ki18n("The data engine to use"));
47 options.add("source <data engine>", ki18n("The source to request"));
48 options.add("interval <ms>", ki18n("Update interval in milliseconds"));
49 options.add("app <application>", ki18n("Only show engines associated with the parent application; "
50 "maps to the X-KDE-ParentApp entry in the DataEngine's .desktop file."));
51 KCmdLineArgs::addCmdLineOptions(options);
53 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
55 KApplication app;
56 EngineExplorer* w = new EngineExplorer;
58 bool ok1, ok2 = false;
59 //get pos if available
60 int x = args->getOption("height").toInt(&ok1);
61 int y = args->getOption("width").toInt(&ok2);
62 if (ok1 && ok2) {
63 w->resize(x,y);
66 //get size
67 x = args->getOption("x").toInt(&ok1);
68 y = args->getOption("y").toInt(&ok2);
69 if (ok1 && ok2) {
70 w->move(x,y);
73 //set interval
74 int interval = args->getOption("interval").toInt(&ok1);
75 if (ok1) {
76 w->setInterval(interval);
79 //set engine
80 QString engine = args->getOption("engine");
81 if (!engine.isEmpty()) {
82 w->setEngine(engine);
84 QString source = args->getOption("source");
85 if (!source.isEmpty()) {
86 w->requestSource(source);
90 if (args->isSet("app")) {
91 w->setApp(args->getOption("app"));
94 args->clear();
96 w->show();
97 return app.exec();