monitor/ScStwMonitorSrc/main.cpp
2020-05-22 19:32:57 +02:00

64 lines
2.1 KiB
C++
Executable file

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QCursor>
#include <QRect>
#include <QScreen>
#include <scstwrace.h>
#include <scstwtimer.h>
#include <ScStw.hpp>
#include <scstwclient.h>
#include "headers/scstwmonitorbackend.h"
#if defined(Q_OS_IOS)
#include "sleepprevent.h"
#endif
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
app.setOrganizationName("itsblue");
app.setOrganizationDomain("itsblue.de");
qmlRegisterType<ScStwMonitorBackend>("de.itsblue.ScStwMonitor", 2, 0, "ScStwMonitorBackend");
// setup speed backend and App themes
qmlRegisterType<ScStwRace>("de.itsblue.ScStw", 2, 0, "ScStwRace");
qmlRegisterType<ScStwTimer>("de.itsblue.ScStw", 2, 0, "ScStwTimer");
qmlRegisterType<ScStw>("de.itsblue.ScStw", 2, 0, "ScStw");
qmlRegisterType<ScStwClient>("de.itsblue.ScStw", 2, 0, "ScStwClient");
//qmlRegisterUncreatableType<ScStwAppTheme>("de.itsblue.ScStw", 2, 0, "ScStwAppTheme", "The ScStwAppTheme has to be managed by a ScStwAppTheme manager and is therefore not creatable");
//qmlRegisterType<ScStwAppThemeManager>("de.itsblue.ScStw", 2, 0, "ScStwAppThemeManager");
QQmlApplicationEngine engine;
QSize size = app.screens().first()->size();
engine.rootContext()->setContextProperty("XscreenHeight", size.height());
engine.rootContext()->setContextProperty("XscreenWidth", size.width());
if(argc > 1 && QString(argv[1]) == "--noControls")
engine.rootContext()->setContextProperty("showControls", false);
else
engine.rootContext()->setContextProperty("showControls", true);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
#if defined(Q_OS_IOS)
SleepPrevent sp;
sp.setTimerDisabled();
#endif
// move the cursor into an invisible position
QScreen *screen = QGuiApplication::primaryScreen();
QRect rect = screen->geometry();
QCursor::setPos(rect.width(),rect.height());
return app.exec();
}