2020-06-07 14:52:07 +02:00
|
|
|
/****************************************************************************
|
|
|
|
** ScStw Monitor
|
|
|
|
** Copyright (C) 2020 Itsblue development
|
|
|
|
**
|
|
|
|
** This program is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU 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 General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-05-22 19:32:57 +02:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QQmlApplicationEngine>
|
|
|
|
#include <QQmlContext>
|
|
|
|
#include <QCursor>
|
|
|
|
#include <QRect>
|
|
|
|
#include <QScreen>
|
|
|
|
|
2020-05-24 15:03:35 +02:00
|
|
|
#include <scstwlibraries.h>
|
2020-05-22 19:32:57 +02:00
|
|
|
|
|
|
|
#if defined(Q_OS_IOS)
|
|
|
|
#include "sleepprevent.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
|
|
|
|
QGuiApplication app(argc, argv);
|
|
|
|
|
2021-04-08 19:05:37 +02:00
|
|
|
app.setOrganizationName("ScStwMonitor");
|
2020-05-22 19:32:57 +02:00
|
|
|
app.setOrganizationDomain("itsblue.de");
|
|
|
|
|
|
|
|
QQmlApplicationEngine engine;
|
|
|
|
|
2020-05-24 15:03:35 +02:00
|
|
|
ScStwLibraries::init();
|
2020-07-03 15:42:27 +02:00
|
|
|
ScStwLibraries::initStyling(&engine);
|
2020-05-24 15:03:35 +02:00
|
|
|
|
2020-05-22 19:32:57 +02:00
|
|
|
QSize size = app.screens().first()->size();
|
|
|
|
engine.rootContext()->setContextProperty("XscreenHeight", size.height());
|
|
|
|
engine.rootContext()->setContextProperty("XscreenWidth", size.width());
|
|
|
|
|
2020-06-14 18:16:31 +02:00
|
|
|
QStringList args;
|
|
|
|
|
|
|
|
for(int i = 0; i <= argc; i++) {
|
|
|
|
args.append(argv[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(args.contains("--noControls"))
|
2020-05-22 19:32:57 +02:00
|
|
|
engine.rootContext()->setContextProperty("showControls", false);
|
|
|
|
else
|
|
|
|
engine.rootContext()->setContextProperty("showControls", true);
|
|
|
|
|
2020-06-14 18:16:31 +02:00
|
|
|
if(args.contains("--noBanners"))
|
|
|
|
engine.rootContext()->setContextProperty("showBanners", false);
|
|
|
|
else
|
|
|
|
engine.rootContext()->setContextProperty("showBanners", true);
|
|
|
|
|
|
|
|
if(args.contains("--darkMode"))
|
|
|
|
engine.rootContext()->setContextProperty("darkMode", true);
|
|
|
|
else
|
|
|
|
engine.rootContext()->setContextProperty("darkMode", false);
|
|
|
|
|
2021-04-08 19:05:37 +02:00
|
|
|
#ifdef RASPI
|
|
|
|
engine.rootContext()->setContextProperty("raspi", true);
|
|
|
|
#else
|
|
|
|
engine.rootContext()->setContextProperty("raspi", false);
|
|
|
|
#endif
|
|
|
|
|
2020-05-22 19:32:57 +02:00
|
|
|
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
|
|
|
if (engine.rootObjects().isEmpty())
|
|
|
|
return -1;
|
|
|
|
|
2021-04-08 19:05:37 +02:00
|
|
|
#if defined(Q_OS_IOS)
|
2020-05-22 19:32:57 +02:00
|
|
|
SleepPrevent sp;
|
|
|
|
sp.setTimerDisabled();
|
2021-04-08 19:05:37 +02:00
|
|
|
#endif
|
2020-05-22 19:32:57 +02:00
|
|
|
|
|
|
|
// move the cursor into an invisible position
|
|
|
|
QScreen *screen = QGuiApplication::primaryScreen();
|
|
|
|
QRect rect = screen->geometry();
|
|
|
|
QCursor::setPos(rect.width(),rect.height());
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|