2017-03-27 16:38:42 +02:00
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QGuiApplication>
|
2017-05-13 10:50:15 +02:00
|
|
|
|
#include <QIcon>
|
2017-03-27 16:38:42 +02:00
|
|
|
|
#include <QLibrary>
|
2017-04-05 13:04:13 +02:00
|
|
|
|
#include <QModelIndex>
|
2017-07-06 17:53:41 +02:00
|
|
|
|
#include <QObject>
|
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>
|
2017-03-27 15:38:25 +02:00
|
|
|
|
#include <QScreen>
|
2017-07-12 21:50:54 +02:00
|
|
|
|
#include <QTimer>
|
2017-03-27 15:38:25 +02:00
|
|
|
|
#include <QUrl>
|
2017-04-05 13:04:13 +02:00
|
|
|
|
#include <QVariant>
|
2017-03-27 16:38:42 +02:00
|
|
|
|
#include <QWindow>
|
2017-05-13 10:50:15 +02:00
|
|
|
|
#include <QtQuick/QQuickItem>
|
2017-03-27 16:38:42 +02:00
|
|
|
|
#include <qt_windows.h>
|
2017-03-25 18:44:26 +01:00
|
|
|
|
|
2017-04-03 18:48:34 +02:00
|
|
|
|
#include "installedlistmodel.h"
|
2017-04-28 14:43:43 +02:00
|
|
|
|
#include "monitorlistmodel.h"
|
2017-06-06 12:51:53 +02:00
|
|
|
|
#include "packagefilehandler.h"
|
2017-07-06 17:53:41 +02:00
|
|
|
|
#include "profilelistmodel.h"
|
2017-09-30 17:36:11 +02:00
|
|
|
|
#include "quazip5/quazip.h"
|
2017-05-02 21:26:43 +02:00
|
|
|
|
#include "settings.h"
|
2017-07-12 21:50:54 +02:00
|
|
|
|
#include "steam/steam_api.h"
|
|
|
|
|
#include "steamworkshop.h"
|
2017-09-30 17:36:11 +02:00
|
|
|
|
#include "steamworkshoplistmodel.h"
|
|
|
|
|
#include "widget.h"
|
2017-07-17 14:29:17 +02:00
|
|
|
|
|
2017-03-27 16:38:42 +02:00
|
|
|
|
int main(int argc, char* argv[])
|
2017-03-25 18:44:26 +01:00
|
|
|
|
{
|
2017-10-26 14:16:40 +02:00
|
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
|
QApplication::setAttribute(Qt::AA_UseOpenGLES);
|
2017-11-02 18:58:35 +01:00
|
|
|
|
|
2017-12-14 14:05:00 +01:00
|
|
|
|
QGuiApplication app(argc, argv);
|
2017-07-12 21:50:54 +02:00
|
|
|
|
|
2017-11-02 18:58:35 +01:00
|
|
|
|
AppId_t steamID = 672870;
|
2017-10-26 20:26:42 +02:00
|
|
|
|
QCoreApplication::setOrganizationName("Aimber");
|
|
|
|
|
QCoreApplication::setOrganizationDomain("aimber.net");
|
|
|
|
|
QCoreApplication::setApplicationName("ScreenPlay");
|
|
|
|
|
app.setWindowIcon(QIcon(":/assets/icons/favicon.ico"));
|
|
|
|
|
bool steamErrorRestart = false;
|
|
|
|
|
bool steamErrorAPIInit = false;
|
2017-11-02 18:54:24 +01:00
|
|
|
|
|
2017-07-12 21:50:54 +02:00
|
|
|
|
if (SteamAPI_RestartAppIfNecessary(steamID)) {
|
|
|
|
|
qWarning() << "SteamAPI_RestartAppIfNecessary";
|
2017-10-26 20:26:42 +02:00
|
|
|
|
steamErrorRestart = true;
|
2017-07-12 21:50:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SteamAPI_Init()) {
|
|
|
|
|
qWarning() << "Could not init steam sdk!";
|
2017-10-26 20:26:42 +02:00
|
|
|
|
steamErrorAPIInit = true;
|
2017-07-12 21:50:54 +02:00
|
|
|
|
}
|
2017-03-27 15:38:25 +02:00
|
|
|
|
|
2017-04-28 14:43:43 +02:00
|
|
|
|
InstalledListModel installedListModel;
|
|
|
|
|
MonitorListModel monitorListModel;
|
2017-06-06 12:51:53 +02:00
|
|
|
|
PackageFileHandler packageFileHandler;
|
|
|
|
|
ProfileListModel profileListModel;
|
2017-11-02 18:58:35 +01:00
|
|
|
|
SteamWorkshopListModel steamWorkshopListModel;
|
2017-07-06 17:53:41 +02:00
|
|
|
|
|
2017-09-30 17:36:11 +02:00
|
|
|
|
// Create settings in the end because for now it depends on
|
2017-06-06 12:51:53 +02:00
|
|
|
|
// such things as the profile list model to complete
|
2017-07-06 17:53:41 +02:00
|
|
|
|
// It will also set the m_absoluteStoragePath in profileListModel and installedListModel
|
2017-07-17 14:29:17 +02:00
|
|
|
|
Settings settings(&profileListModel, &monitorListModel, &installedListModel, steamID);
|
2017-12-14 14:05:00 +01:00
|
|
|
|
SteamWorkshop steamWorkshop(steamID, &steamWorkshopListModel, &settings);
|
2017-11-02 18:58:35 +01:00
|
|
|
|
|
2017-07-06 17:53:41 +02:00
|
|
|
|
// All the list need the default path from the settings
|
|
|
|
|
// to know where to look for the files
|
|
|
|
|
profileListModel.loadProfiles();
|
|
|
|
|
settings.loadActiveProfiles();
|
2017-04-03 18:48:34 +02:00
|
|
|
|
|
2017-06-26 22:00:51 +02:00
|
|
|
|
QQmlApplicationEngine mainWindowEngine;
|
2017-11-02 18:58:35 +01:00
|
|
|
|
mainWindowEngine.rootContext()->setContextProperty("workshopListModel", &steamWorkshopListModel);
|
2017-06-26 22:00:51 +02:00
|
|
|
|
mainWindowEngine.rootContext()->setContextProperty("monitorListModel", &monitorListModel);
|
|
|
|
|
mainWindowEngine.rootContext()->setContextProperty("installedListModel", &installedListModel);
|
2017-11-02 18:58:35 +01:00
|
|
|
|
mainWindowEngine.rootContext()->setContextProperty("profileListModel", &profileListModel);
|
|
|
|
|
|
2017-10-17 10:18:13 +02:00
|
|
|
|
mainWindowEngine.rootContext()->setContextProperty("screenPlaySettings", &settings);
|
2017-06-26 22:00:51 +02:00
|
|
|
|
mainWindowEngine.rootContext()->setContextProperty("packageFileHandler", &packageFileHandler);
|
2017-07-12 21:50:54 +02:00
|
|
|
|
mainWindowEngine.rootContext()->setContextProperty("steamWorkshop", &steamWorkshop);
|
2017-10-26 20:26:42 +02:00
|
|
|
|
|
|
|
|
|
QQmlApplicationEngine errorWindowEngine;
|
|
|
|
|
if (steamErrorRestart || steamErrorAPIInit) {
|
|
|
|
|
errorWindowEngine.load(QUrl(QStringLiteral("qrc:/qml/Components/StartupErrorWindow.qml")));
|
|
|
|
|
} else {
|
|
|
|
|
mainWindowEngine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
|
|
|
|
}
|
2017-04-23 12:53:00 +02:00
|
|
|
|
|
2017-11-06 10:52:05 +01:00
|
|
|
|
installedListModel.loadScreens();
|
2017-06-21 11:23:55 +02:00
|
|
|
|
// FIXME: Needed workaround to close the app because
|
|
|
|
|
// apparently some thread still runs in the background
|
2017-07-15 10:46:50 +02:00
|
|
|
|
QObject::connect(&app, &QGuiApplication::lastWindowClosed, [&]() { exit(app.exec()); });
|
2017-04-06 23:12:58 +02:00
|
|
|
|
|
2017-07-12 21:50:54 +02:00
|
|
|
|
// Timer for steam polls. WTF?
|
|
|
|
|
QTimer timer;
|
|
|
|
|
QObject::connect(&timer, &QTimer::timeout, [&]() { SteamAPI_RunCallbacks(); });
|
2017-11-02 18:54:24 +01:00
|
|
|
|
timer.setInterval(200);
|
2017-07-12 21:50:54 +02:00
|
|
|
|
timer.start();
|
|
|
|
|
|
2017-04-03 18:48:34 +02:00
|
|
|
|
int status = app.exec();
|
|
|
|
|
|
2017-09-30 17:36:11 +02:00
|
|
|
|
SteamAPI_Shutdown();
|
2017-04-03 18:48:34 +02:00
|
|
|
|
//Shutdown
|
2017-07-12 21:50:54 +02:00
|
|
|
|
return status;
|
2017-03-25 18:44:26 +01:00
|
|
|
|
}
|