Debian Codegraph @

src/main.cc

raw
1 /*
2 This file is part of Icecream.
3
4 Copyright (c) 2003 Frerich Raabe <[email protected]>
5 Copyright (c) 2003,2004 Stephan Kulow <[email protected]>
6 Copyright (c) 2003,2004 Cornelius Schumacher <[email protected]>
7 Copyright (c) 2007 Dirk Mueller <[email protected]>
8 Copyright (c) 2014 Kevin Funk <[email protected]>
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License along
21 with this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 */
24
25 #include <QApplication>
26 #include <QCommandLineParser>
27
28 #include "mainwindow.h"
29 #include "version.h"
30
31 int main(int argc, char **argv)
32 {
33 QApplication app(argc, argv);
34 QApplication::setOrganizationDomain(QStringLiteral("kde.org"));
35 QApplication::setApplicationName(QLatin1String(Icemon::Version::appShortName));
36 QApplication::setApplicationVersion(QLatin1String(Icemon::Version::version));
37
38 QCommandLineParser parser;
39 parser.setApplicationDescription(QLatin1String(Icemon::Version::description));
40 parser.addHelpOption();
41 parser.addVersionOption();
42 QCommandLineOption netnameOption(QStringList() << QStringLiteral("n") << QStringLiteral("netname"),
43 QCoreApplication::translate("main", "Icecream network name."),
44 QCoreApplication::translate("main", "name", "network name"));
45 parser.addOption(netnameOption);
46 QCommandLineOption schednameOption(QStringList() << QStringLiteral("s") << QStringLiteral("scheduler"),
47 QCoreApplication::translate("main", "Icecream scheduler hostname"),
48 QCoreApplication::translate("main", "hostname", "scheduler hostname"));
49 parser.addOption(schednameOption);
50 QCommandLineOption schedportOption(QStringList() << QStringLiteral("p") << QStringLiteral("port"),
51 QCoreApplication::translate("main", "Icecream scheduler port"),
52 QCoreApplication::translate("main", "port", "scheduler port"));
53 parser.addOption(schedportOption);
54 QCommandLineOption testmodeOption(QStringLiteral("testmode"),
55 QCoreApplication::translate("main", "Testing mode."));
56 parser.addOption(testmodeOption);
57
58 parser.process(app);
59
60 const QByteArray netName = parser.value(netnameOption).toLatin1();
61 const QByteArray schedName = parser.value(schednameOption).toLatin1();
62
63 MainWindow mainWindow;
64 if (!netName.isEmpty()) {
65 mainWindow.setCurrentNet(netName);
66 }
67 if (!schedName.isEmpty()) {
68 mainWindow.setCurrentSched(schedName);
69 }
70 if (!parser.value(schedportOption).isEmpty())
71 {
72 mainWindow.setCurrentPort(parser.value(schedportOption).toUInt());
73 }
74 if (parser.isSet(testmodeOption)) {
75 mainWindow.setTestModeEnabled(true);
76 }
77 mainWindow.show();
78
79 return app.exec();
80 }