reaction-trainer/sources/main.cpp

46 lines
1.5 KiB
C++
Raw Normal View History

2019-04-06 20:09:40 +02:00
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#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");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}