1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00
ScreenPlay/main.cpp

74 lines
2.3 KiB
C++
Raw Normal View History

#include <QDebug>
#include <QDir>
#include <QGuiApplication>
2017-05-13 10:50:15 +02:00
#include <QIcon>
#include <QLibrary>
2017-04-05 13:04:13 +02:00
#include <QModelIndex>
2017-03-25 18:44:26 +01:00
#include <QQmlApplicationEngine>
2017-04-05 13:04:13 +02:00
#include <QQmlContext>
2017-04-23 12:53:00 +02:00
#include <QQmlEngine>
2017-05-13 10:50:15 +02:00
#include <QQuickStyle>
2017-03-25 18:44:26 +01:00
#include <QQuickView>
#include <QScreen>
#include <QUrl>
2017-04-05 13:04:13 +02:00
#include <QVariant>
#include <QWindow>
2017-06-26 22:00:51 +02:00
#include <QObject>
2017-05-13 10:50:15 +02:00
#include <QtQuick/QQuickItem>
#include <qt_windows.h>
2017-03-25 18:44:26 +01:00
2017-04-23 12:53:00 +02:00
#include "backend.h"
#include "installedlistmodel.h"
#include "monitorlistmodel.h"
2017-06-06 12:51:53 +02:00
#include "packagefilehandler.h"
2017-04-05 13:04:13 +02:00
#include "screenplay.h"
2017-05-02 21:26:43 +02:00
#include "settings.h"
2017-06-06 12:51:53 +02:00
#include "profilelistmodel.h"
2017-03-25 18:44:26 +01:00
int main(int argc, char* argv[])
2017-03-25 18:44:26 +01:00
{
2017-06-06 12:51:53 +02:00
Q_INIT_RESOURCE(qml);
2017-03-25 18:44:26 +01:00
QGuiApplication app(argc, argv);
2017-06-26 22:00:51 +02:00
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setOrganizationName("Aimber");
QCoreApplication::setOrganizationDomain("aimber.net");
QCoreApplication::setApplicationName("ScreenPlay");
2017-04-17 12:54:53 +02:00
app.setWindowIcon(QIcon(":/assets/icons/favicon.ico"));
2017-05-13 10:50:15 +02:00
QQuickStyle::setStyle("Material");
InstalledListModel installedListModel;
MonitorListModel monitorListModel;
2017-06-06 12:51:53 +02:00
PackageFileHandler packageFileHandler;
ProfileListModel profileListModel;
// Create settings at the end because for now it depends on
// such things as the profile list model to complete
2017-06-27 18:42:38 +02:00
Settings settings(&profileListModel, &monitorListModel, &installedListModel);
2017-06-26 22:00:51 +02:00
2017-06-26 22:00:51 +02:00
QQmlApplicationEngine mainWindowEngine;
installedListModel.loadScreens();
2017-06-26 22:00:51 +02:00
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")));
2017-04-23 12:53:00 +02:00
// FIXME: Needed workaround to close the app because
// apparently some thread still runs in the background
QObject::connect(&app, &QGuiApplication::lastWindowClosed,
[&](){exit(app.exec()); });
2017-04-06 23:12:58 +02:00
profileListModel.loadProfiles();
int status = app.exec();
//Shutdown
2017-04-23 12:53:00 +02:00
return app.exec();
2017-03-25 18:44:26 +01:00
}