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.
22
#include <KApplication>
24
#include <KCmdLineArgs>
27
#include <Plasma/DataEngineManager>
29
#include "engineexplorer.h"
31
static const char description[] = I18N_NOOP("Explore the data published by Plasma DataEngines");
32
static const char version[] = "0.2";
37
QMap<QString, QString> engines;
38
foreach (const KPluginInfo &info, Plasma::DataEngineManager::listEngineInfo()) {
39
if (info.property("NoDisplay").toBool()) {
43
int len = info.pluginName().length();
48
QString name = info.pluginName();
49
QString comment = info.comment();
51
if (comment.isEmpty()) {
52
comment = i18n("No description available");
55
engines.insert(name, comment);
58
QMap<QString, QString>::const_iterator it;
59
for (it = engines.constBegin(); it != engines.constEnd(); it++) {
60
QString engine("%1 - %2");
61
engine = engine.arg(it.key().leftJustified(maxLen, ' ')).arg(it.value());
62
std::cout << engine.toLocal8Bit().data() << std::endl;
66
int main(int argc, char **argv)
68
KAboutData aboutData("plasmaengineexplorer", 0, ki18n("Plasma Engine Explorer"),
69
version, ki18n(description), KAboutData::License_GPL,
70
ki18n("(c) 2006, The KDE Team"));
71
aboutData.addAuthor(ki18n("Aaron J. Seigo"),
72
ki18n( "Author and maintainer" ),
74
aboutData.setProgramIconName("plasma");
76
KCmdLineArgs::init(argc, argv, &aboutData);
78
KCmdLineOptions options;
79
options.add("list", ki18n("Displays a list of known engines and their descriptions"));
80
options.add("height <pixels>", ki18n("The desired height in pixels"));
81
options.add("width <pixels>", ki18n("The desired width in pixels"));
82
options.add("x <pixels>", ki18n("The desired x position in pixels"));
83
options.add("y <pixels>", ki18n("The desired y position in pixels"));
84
options.add("engine <data engine>", ki18n("The data engine to use"));
85
options.add("source <data engine>", ki18n("The source to request"));
86
options.add("interval <ms>", ki18n("Update interval in milliseconds"));
87
options.add("app <application>", ki18n("Only show engines associated with the parent application; "
88
"maps to the X-KDE-ParentApp entry in the DataEngine's .desktop file."));
90
KCmdLineArgs::addCmdLineOptions(options);
91
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
93
if (args->isSet("list")) {
99
EngineExplorer* w = new EngineExplorer;
101
bool ok1, ok2 = false;
103
int x = args->getOption("height").toInt(&ok1);
104
int y = args->getOption("width").toInt(&ok2);
109
//get pos if available
110
x = args->getOption("x").toInt(&ok1);
111
y = args->getOption("y").toInt(&ok2);
117
int interval = args->getOption("interval").toInt(&ok1);
119
w->setInterval(interval);
123
QString engine = args->getOption("engine");
124
if (!engine.isEmpty()) {
125
w->setEngine(engine);
127
QString source = args->getOption("source");
128
if (!source.isEmpty()) {
129
w->requestSource(source);
133
if (args->isSet("app")) {
134
w->setApp(args->getOption("app"));