1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00
ScreenPlay/main.cpp

74 lines
2.3 KiB
C++

#include <QDebug>
#include <QDir>
#include <QGuiApplication>
#include <QIcon>
#include <QLibrary>
#include <QModelIndex>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickStyle>
#include <QQuickView>
#include <QScreen>
#include <QUrl>
#include <QVariant>
#include <QWindow>
#include <QObject>
#include <QtQuick/QQuickItem>
#include <qt_windows.h>
#include "backend.h"
#include "installedlistmodel.h"
#include "monitorlistmodel.h"
#include "packagefilehandler.h"
#include "screenplay.h"
#include "settings.h"
#include "profilelistmodel.h"
int main(int argc, char* argv[])
{
Q_INIT_RESOURCE(qml);
QGuiApplication app(argc, argv);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setOrganizationName("Aimber");
QCoreApplication::setOrganizationDomain("aimber.net");
QCoreApplication::setApplicationName("ScreenPlay");
app.setWindowIcon(QIcon(":/assets/icons/favicon.ico"));
QQuickStyle::setStyle("Material");
InstalledListModel installedListModel;
MonitorListModel monitorListModel;
PackageFileHandler packageFileHandler;
ProfileListModel profileListModel;
// Create settings at the end because for now it depends on
// such things as the profile list model to complete
Settings settings(&profileListModel, &monitorListModel, &installedListModel);
QQmlApplicationEngine mainWindowEngine;
installedListModel.loadScreens();
mainWindowEngine.rootContext()->setContextProperty("monitorListModel", &monitorListModel);
mainWindowEngine.rootContext()->setContextProperty("installedListModel", &installedListModel);
mainWindowEngine.rootContext()->setContextProperty("settings", &settings);
mainWindowEngine.rootContext()->setContextProperty("packageFileHandler", &packageFileHandler);
mainWindowEngine.rootContext()->setContextProperty("profileListModel", &profileListModel);
mainWindowEngine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
// FIXME: Needed workaround to close the app because
// apparently some thread still runs in the background
QObject::connect(&app, &QGuiApplication::lastWindowClosed,
[&](){exit(app.exec()); });
profileListModel.loadProfiles();
int status = app.exec();
//Shutdown
return app.exec();
}