1/*
2 * Copyright (C) 2000 Matthias Elter <elter@kde.org>
3 * Copyright (C) 2001-2002 Raffaele Sandrini <sandrini@kde.org)
4 * Copyright (C) 2008 Montel Laurent <montel@kde.org)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 */
21
22#include <KUniqueApplication>
23#include <KLocale>
24#include <KCmdLineArgs>
25#include <KAboutData>
26
27#include "kmenuedit.h"
28#ifndef Q_WS_WIN
29#include "khotkeys.h"
30#endif
31
32static const char description[] = I18N_NOOP("KDE menu editor");
33static const char version[] = "0.9";
34
35static KMenuEdit *menuEdit = 0;
36
37class KMenuApplication : public KUniqueApplication
38{
39public:
40 KMenuApplication() { }
41#ifndef Q_WS_WIN
42 virtual ~KMenuApplication() { KHotKeys::cleanup(); }
43#endif
44 virtual int newInstance()
45 {
46 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
47 if (args->count() > 0)
48 {
49 menuEdit->selectMenu(args->arg(0));
50 if (args->count() > 1)
51 {
52 menuEdit->selectMenuEntry(args->arg(1));
53 }
54 }
55 args->clear();
56 return KUniqueApplication::newInstance();
57 }
58};
59
60
61extern "C" int KDE_EXPORT kdemain( int argc, char **argv )
62{
63 KAboutData aboutData("kmenuedit", 0, ki18n("KDE Menu Editor"),
64 version, ki18n(description), KAboutData::License_GPL,
65 ki18n("(C) 2000-2003, Waldo Bastian, Raffaele Sandrini, Matthias Elter"));
66 aboutData.addAuthor(ki18n("Waldo Bastian"), ki18n("Maintainer"), "bastian@kde.org");
67 aboutData.addAuthor(ki18n("Raffaele Sandrini"), ki18n("Previous Maintainer"), "sandrini@kde.org");
68 aboutData.addAuthor(ki18n("Matthias Elter"), ki18n("Original Author"), "elter@kde.org");
69 aboutData.addAuthor(ki18n("Montel Laurent"), KLocalizedString(), "montel@kde.org");
70
71 KCmdLineArgs::init( argc, argv, &aboutData );
72 KUniqueApplication::addCmdLineOptions();
73
74 KCmdLineOptions options;
75 options.add("+[menu]", ki18n("Sub menu to pre-select"));
76 options.add("+[menu-id]", ki18n("Menu entry to pre-select"));
77 KCmdLineArgs::addCmdLineOptions( options );
78
79 if (!KUniqueApplication::start())
80 return 1;
81
82 KMenuApplication app;
83
84 menuEdit = new KMenuEdit();
85 menuEdit->show();
86
87 return app.exec();
88}
89