File indexing completed on 2024-10-13 03:27:26

0001 // SPDX-FileCopyrightText: 2010 by Aleix Pol <aleixpol@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 #include <QGuiApplication>
0005 #ifdef Q_OS_ANDROID
0006 #include <QQuickStyle>
0007 #else
0008 #include <QApplication>
0009 #endif
0010 
0011 #include <KAboutData>
0012 #include <KLocalizedContext>
0013 #include <KLocalizedString>
0014 
0015 #include <QCommandLineParser>
0016 #include <QIcon>
0017 #include <QQmlApplicationEngine>
0018 #include <QQmlContext>
0019 #include <QStandardPaths>
0020 
0021 #include "kalgebra_version.h"
0022 #include "kalgebramobile.h"
0023 
0024 Q_DECL_EXPORT int main(int argc, char *argv[])
0025 {
0026 #ifdef Q_OS_ANDROID
0027     QQuickStyle::setStyle("Material");
0028 #endif
0029 #ifdef Q_OS_ANDROID
0030     QGuiApplication app(argc, argv);
0031 #else
0032     QApplication app(argc, argv);
0033 #endif
0034     KLocalizedString::setApplicationDomain("kalgebramobile");
0035     KAboutData about(QStringLiteral("kalgebramobile"),
0036                      QStringLiteral("KAlgebra"),
0037                      QStringLiteral(KALGEBRA_VERSION_STRING),
0038                      i18n("A portable calculator"),
0039                      KAboutLicense::GPL,
0040                      i18n("(C) 2006-2023 Aleix Pol i Gonzalez"));
0041     about.addAuthor(i18n("Aleix Pol i Gonzalez"), i18nc("@info:credit", "Maintainer"), QStringLiteral("aleixpol@kde.org"));
0042     about.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
0043     KAboutData::setApplicationData(about);
0044     QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kalgebra")));
0045 
0046     {
0047         QCommandLineParser parser;
0048         about.setupCommandLine(&parser);
0049         parser.process(app);
0050         about.processCommandLine(&parser);
0051     }
0052 
0053     KAlgebraMobile widget;
0054 
0055     QQmlApplicationEngine engine;
0056 
0057     qmlRegisterSingletonInstance("org.kde.kalgebra.mobile", 1, 0, "App", &widget);
0058     qmlRegisterSingletonType("org.kde.kalgebra.mobile", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue {
0059         return engine->toScriptValue(KAboutData::applicationData());
0060     });
0061     engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
0062     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
0063     return app.exec();
0064 }