summaryrefslogtreecommitdiff
path: root/ui/qt5/runner/main.cc
blob: a54598285907a6c00a6636839f2bb42d80ec19fb (plain) (blame)
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
/*
 * main.cc - Implementation of the UI.Perform interface
 * horizon-run-qt5, the Qt 5 executor user interface for
 * Project Horizon
 *
 * Copyright (c) 2019 Adélie Linux and contributors.  All rights reserved.
 * This code is licensed under the AGPL 3.0 license, as noted in the
 * LICENSE-code file in the root directory of this repository.
 *
 * SPDX-License-Identifier: AGPL-3.0-only
 */

#include <QApplication>
#include <QCommandLineParser>
#include <QIcon>
#include <QLibraryInfo>
#include <QTranslator>

#include "executorwizard.hh"

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    app.setOrganizationName("Adélie Linux");
    app.setApplicationName("Horizon Runner GUI");
    app.setApplicationVersion(VERSTR);

    QString translatorFileName = QLatin1String("qt_");
    translatorFileName += QLocale::system().name();
    QTranslator *translator = new QTranslator(&app);
    if(translator->load(translatorFileName,
                        QLibraryInfo::location(
                                QLibraryInfo::TranslationsPath
                        ))) {
        app.installTranslator(translator);
    }

    app.setWindowIcon(QIcon(":/horizon-256.png"));

    QCommandLineParser parser;
    parser.setApplicationDescription(app.tr("Executes a HorizonScript with graphical progress indication."));
    QCommandLineOption help = parser.addHelpOption();
    QCommandLineOption version = parser.addVersionOption();
    QCommandLineOption automatic("automatic", app.tr("Runs the Executor in Automatic mode.  After installation, the system will be restarted automatically."));
    parser.addOption(automatic);

    if(!parser.parse(app.arguments())) {
        parser.showHelp(1);
        return 1;
    }

    if(parser.isSet(help)) {
        parser.showHelp();
        return 0;
    }

    if(parser.isSet(version)) {
        parser.showVersion();
        return 0;
    }

    ExecutorWizard wizard(nullptr, parser.isSet(automatic));
    wizard.show();

    return app.exec();
}