File indexing completed on 2023-09-24 03:51:58
0001 /************************************************************************************* 0002 * Copyright (C) 2010 by Aleix Pol <aleixpol@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License * 0006 * as published by the Free Software Foundation; either version 2 * 0007 * of the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the Free Software * 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0017 *************************************************************************************/ 0018 0019 #include <QGuiApplication> 0020 #ifdef Q_OS_ANDROID 0021 #include <QQuickStyle> 0022 #else 0023 #include <QApplication> 0024 #endif 0025 0026 #include <KLocalizedContext> 0027 #include <KLocalizedString> 0028 #include <KAboutData> 0029 0030 #include <QIcon> 0031 #include <QCommandLineParser> 0032 #include <QQmlApplicationEngine> 0033 #include <QQmlContext> 0034 #include <QStandardPaths> 0035 0036 #include "kalgebramobile.h" 0037 #include "kalgebra_version.h" 0038 0039 Q_DECL_EXPORT int main(int argc, char *argv[]) 0040 { 0041 #ifdef Q_OS_ANDROID 0042 QQuickStyle::setStyle("Material"); 0043 #endif 0044 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0045 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 0046 #endif 0047 #ifdef Q_OS_ANDROID 0048 QGuiApplication app(argc, argv); 0049 #else 0050 QApplication app(argc, argv); 0051 #endif 0052 KLocalizedString::setApplicationDomain("kalgebramobile"); 0053 KAboutData about(QStringLiteral("kalgebramobile"), QStringLiteral("KAlgebra"), QStringLiteral(KALGEBRA_VERSION_STRING), i18n("A portable calculator"), 0054 KAboutLicense::GPL, i18n("(C) 2006-2023 Aleix Pol i Gonzalez")); 0055 about.addAuthor(i18n("Aleix Pol i Gonzalez"), i18nc("@info:credit", "Maintainer"), QStringLiteral("aleixpol@kde.org")); 0056 about.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails")); 0057 KAboutData::setApplicationData(about); 0058 QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kalgebra"))); 0059 0060 { 0061 QCommandLineParser parser; 0062 about.setupCommandLine(&parser); 0063 parser.process(app); 0064 about.processCommandLine(&parser); 0065 } 0066 0067 KAlgebraMobile widget; 0068 0069 QQmlApplicationEngine engine; 0070 0071 qmlRegisterSingletonInstance("org.kde.kalgebra.mobile", 1, 0, "App", &widget); 0072 qmlRegisterSingletonType("org.kde.kalgebra.mobile", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { 0073 return engine->toScriptValue(KAboutData::applicationData()); 0074 }); 0075 engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); 0076 engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 0077 return app.exec(); 0078 }