reaction-trainer/sources/main.cpp

69 lines
2.4 KiB
C++
Raw Normal View History

2019-04-06 20:16:16 +02:00
/*
Speed climbing reaction timer
Copyright (C) 2019 Itsblue Development | Dorian Zedler
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2019-04-06 20:09:40 +02:00
#include <QGuiApplication>
#include <QQmlApplicationEngine>
2023-01-18 14:35:25 +01:00
#include <QQmlContext>
#include <QQuickStyle>
2019-04-06 20:09:40 +02:00
#include "headers/apptheme.h"
#include "headers/appsettings.h"
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras>
#endif
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
#ifdef Q_OS_ANDROID
//set the standard volume to media
QAndroidJniObject jactivity=QtAndroid::androidActivity();
if(jactivity.isValid())
jactivity.callMethod<void>("setVolumeControlStream","(I)V",3);
//set statusbar color
QtAndroid::runOnAndroidThread([=]()
{
QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
window.callMethod<void>("addFlags", "(I)V", 0x80000000);
window.callMethod<void>("clearFlags", "(I)V", 0x04000000);
//window.callMethod<void>("setStatusBarColor", "(I)V", 0x202227); // Desired statusbar color
//QAndroidJniObject decorView = window.callObjectMethod("getDecorView", "()Landroid/view/View;");
//decorView.callMethod<void>("setSystemUiVisibility", "(I)V", 0x00002000);
});
#endif
qmlRegisterType<AppTheme>("com.itsblue.SpeedClimbingStartTrainer", 2, 0, "AppTheme");
qmlRegisterType<AppSettings>("com.itsblue.SpeedClimbingStartTrainer", 2, 0, "AppSettings");
2023-01-18 14:35:25 +01:00
QQuickStyle::setStyle("Material");
2019-04-06 20:09:40 +02:00
QQmlApplicationEngine engine;
2023-01-18 14:35:25 +01:00
engine.rootContext()->setContextProperty("APP_VERSION", APP_VERSION);
2019-04-06 20:09:40 +02:00
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}