This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
monitor/ScStwMonitorSrc/sources/main.cpp

57 lines
1.5 KiB
C++
Raw Normal View History

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QCursor>
#include <QRect>
#include <QScreen>
2020-05-24 15:03:35 +02:00
#include <scstwlibraries.h>
#include <scstwstyling.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");
QQmlApplicationEngine engine;
2020-05-24 15:03:35 +02:00
ScStwLibraries::init();
ScStwStyling::init(&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();
}