main.cpp 3.32 KB
Newer Older
1
/*************************************************************************************
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
2
 *  Copyright (C) 2010 by Aleix Pol <aleixpol@kde.org>                               *
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 *                                                                                   *
 *  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   *
 *************************************************************************************/

19
#include <QGuiApplication>
20

21
#include <KLocalizedContext>
22
23
#include <KLocalizedString>
#include <KAboutData>
24

25
#include <QDebug>
26
27
#include <QFileInfo>
#include <QDir>
28
29
30
31
#include <QStandardPaths>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
32
#include <QQmlApplicationEngine>
33
#include <QCommandLineParser>
34
#include <QIcon>
35
36

#include "kalgebramobile.h"
37
#include "kalgebra_version.h"
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
38
#include "pluginsmodel.h"
39

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
40
Q_DECL_EXPORT int main(int argc, char *argv[])
41
{
42
#ifdef __ANDROID__
43
    qputenv("QT_QUICK_CONTROLS_STYLE", "Material");
44
45
#endif
    QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
46
    QGuiApplication app(argc, argv);
47
    KLocalizedString::setApplicationDomain("kalgebramobile");
48
    KAboutData about(QStringLiteral("kalgebramobile"), QStringLiteral("KAlgebra"), QStringLiteral(KALGEBRA_VERSION_STRING), i18n("A portable calculator"),
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
49
             KAboutLicense::GPL, i18n("(C) 2006-2020 Aleix Pol i Gonzalez"));
50
    about.addAuthor( QStringLiteral("Aleix Pol i Gonzalez"), QString(), QStringLiteral("aleixpol@kde.org") );
51
52
53
54
55
56
57
58
59
    about.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
    KAboutData::setApplicationData(about);

    {
        QCommandLineParser parser;
        about.setupCommandLine(&parser);
        parser.process(app);
        about.processCommandLine(&parser);
    }
60
61
62
    
    KAlgebraMobile widget;
    
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
63
    const QString pluginsDir = PluginsModel::pluginsDirectoryPath();
64

65
    QQmlApplicationEngine engine;
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
66

67
    engine.rootContext()->setContextProperty(QStringLiteral("app"), &widget);
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
68
    engine.addImportPath(pluginsDir);
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
69
70
71
#ifdef __ANDROID__
    engine.addImportPath(QStringLiteral("assets:/qml"));
#endif
72
73
74

    engine.rootContext()->setContextObject(new KLocalizedContext(&engine));

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
75
    engine.load(QUrl::fromLocalFile(pluginsDir + QStringLiteral("/widgets/KAlgebraMobile.qml")));
76
    return app.exec();
77
}