File indexing completed on 2022-09-20 16:26:44

0001 /*
0002  *   Copyright 2016 Marco Martin <mart@kde.org>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (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 Library General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 
0020 #include <QtGlobal>
0021 
0022 #ifdef Q_OS_ANDROID
0023 #include <QGuiApplication>
0024 #else
0025 #include <QApplication>
0026 #endif
0027 #include <QQmlApplicationEngine>
0028 #include <QtQml>
0029 #include <QUrl>
0030 
0031 #include "data.h"
0032 #include "availablegradesmodel.h"
0033 
0034 Q_DECL_EXPORT int main(int argc, char *argv[])
0035 {
0036     QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
0037     //qputenv("QT_QUICK_CONTROLS_STYLE", "Material");
0038     //TODO: make it selectively a QAplpication or a QGuiApplication with ifdefs
0039 #ifdef Q_OS_ANDROID
0040     QGuiApplication app(argc, argv);
0041 #else
0042     QApplication app(argc, argv);
0043 #endif
0044     QCoreApplication::setOrganizationName("KDE");
0045     QCoreApplication::setOrganizationDomain("kde.org");
0046     QCoreApplication::setApplicationName("Climbing Grades");
0047 
0048     //qputenv("QML_IMPORT_TRACE", "1");
0049     qRegisterMetaType<AvailableGradesModel*>();
0050     QQmlApplicationEngine engine;
0051 
0052     Data *data = new Data;
0053 
0054     engine.rootContext()->setContextProperty(QLatin1String("dataStore"), data);
0055     //we want different main files on desktop or mobile
0056     //very small difference as they as they are subclasses of the same thing
0057     if (QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_STYLE")) == QStringLiteral("org.kde.desktop")) {
0058         engine.load(QUrl(QStringLiteral("qrc:///desktopmain.qml")));
0059     } else {
0060         engine.load(QUrl(QStringLiteral("qrc:///mobilemain.qml")));
0061     }
0062 
0063     if (engine.rootObjects().isEmpty()) {
0064         return -1;
0065     }
0066 
0067     int ret = app.exec();
0068     delete data;
0069     return ret;
0070 }