reaction-trainer/sources/main.cpp

69 lines
2.4 KiB
C++

/*
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/>.
*/
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickStyle>
#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");
QQuickStyle::setStyle("Material");
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("APP_VERSION", APP_VERSION);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}