[go: up one dir, main page]

File: main.cc

package info (click to toggle)
icecc-monitor 3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 580 kB
  • sloc: cpp: 4,389; xml: 73; makefile: 6; sh: 2
file content (80 lines) | stat: -rw-r--r-- 3,311 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
    This file is part of Icecream.

    Copyright (c) 2003 Frerich Raabe <raabe@kde.org>
    Copyright (c) 2003,2004 Stephan Kulow <coolo@kde.org>
    Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
    Copyright (c) 2007 Dirk Mueller <mueller@kde.org>
    Copyright (c) 2014 Kevin Funk <kfunk@kde.org>

    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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <QApplication>
#include <QCommandLineParser>

#include "mainwindow.h"
#include "version.h"

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QApplication::setOrganizationDomain(QStringLiteral("kde.org"));
    QApplication::setApplicationName(QLatin1String(Icemon::Version::appShortName));
    QApplication::setApplicationVersion(QLatin1String(Icemon::Version::version));

    QCommandLineParser parser;
    parser.setApplicationDescription(QLatin1String(Icemon::Version::description));
    parser.addHelpOption();
    parser.addVersionOption();
    QCommandLineOption netnameOption(QStringList() << QStringLiteral("n") << QStringLiteral("netname"),
        QCoreApplication::translate("main", "Icecream network name."),
        QCoreApplication::translate("main", "name", "network name"));
    parser.addOption(netnameOption);
    QCommandLineOption schednameOption(QStringList() << QStringLiteral("s") << QStringLiteral("scheduler"),
        QCoreApplication::translate("main", "Icecream scheduler hostname"),
        QCoreApplication::translate("main", "hostname", "scheduler hostname"));
    parser.addOption(schednameOption);
    QCommandLineOption schedportOption(QStringList() << QStringLiteral("p") << QStringLiteral("port"),
        QCoreApplication::translate("main", "Icecream scheduler port"),
        QCoreApplication::translate("main", "port", "scheduler port"));
    parser.addOption(schedportOption);
    QCommandLineOption testmodeOption(QStringLiteral("testmode"),
        QCoreApplication::translate("main", "Testing mode."));
    parser.addOption(testmodeOption);

    parser.process(app);

    const QByteArray netName = parser.value(netnameOption).toLatin1();
    const QByteArray schedName = parser.value(schednameOption).toLatin1();

    MainWindow mainWindow;
    if (!netName.isEmpty()) {
        mainWindow.setCurrentNet(netName);
    }
    if (!schedName.isEmpty()) {
        mainWindow.setCurrentSched(schedName);
    }
    if (!parser.value(schedportOption).isEmpty())
    {
        mainWindow.setCurrentPort(parser.value(schedportOption).toUInt());
    }
    if (parser.isSet(testmodeOption)) {
        mainWindow.setTestModeEnabled(true);
    }
    mainWindow.show();

    return app.exec();
}