2019-03-27 18:38:36 +01:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
2020-02-15 17:49:48 +01:00
|
|
|
#include <QVector>
|
2019-03-27 18:38:36 +01:00
|
|
|
#include <QtGlobal>
|
2021-07-15 12:07:39 +02:00
|
|
|
#include <QtWebEngineQuick>
|
2019-03-10 21:20:55 +01:00
|
|
|
|
2021-04-18 17:23:21 +02:00
|
|
|
#include "ScreenPlayUtil/util.h"
|
|
|
|
|
2019-03-10 21:20:55 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
#include "src/winwindow.h"
|
2022-04-23 20:15:32 +02:00
|
|
|
Q_IMPORT_QML_PLUGIN(ScreenPlaySysInfoPlugin)
|
2021-05-12 17:42:38 +02:00
|
|
|
#elif defined(Q_OS_LINUX)
|
2019-04-01 13:42:35 +02:00
|
|
|
#include "src/linuxwindow.h"
|
2021-05-12 17:42:38 +02:00
|
|
|
#elif defined(Q_OS_OSX)
|
2019-04-04 17:20:13 +02:00
|
|
|
#include "src/macwindow.h"
|
2019-03-27 18:38:36 +01:00
|
|
|
#endif
|
|
|
|
|
2022-02-20 17:55:26 +01:00
|
|
|
Q_IMPORT_QML_PLUGIN(ScreenPlayWeatherPlugin)
|
|
|
|
|
2018-02-18 16:46:47 +01:00
|
|
|
int main(int argc, char* argv[])
|
2018-01-31 21:54:25 +01:00
|
|
|
{
|
2020-03-27 14:29:44 +01:00
|
|
|
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
2021-07-15 12:07:39 +02:00
|
|
|
QtWebEngineQuick::initialize();
|
|
|
|
|
2019-03-10 21:20:55 +01:00
|
|
|
QApplication app(argc, argv);
|
2019-11-23 11:40:52 +01:00
|
|
|
|
2023-01-20 14:42:48 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
WinWindow window;
|
|
|
|
#elif defined(Q_OS_LINUX)
|
|
|
|
LinuxWindow window;
|
|
|
|
#elif defined(Q_OS_OSX)
|
|
|
|
MacWindow window;
|
|
|
|
#endif
|
2019-03-27 18:38:36 +01:00
|
|
|
|
2019-03-24 16:52:07 +01:00
|
|
|
// If we start with only one argument (app path)
|
|
|
|
// It means we want to test a single wallpaper
|
2021-05-12 17:42:38 +02:00
|
|
|
const QStringList argumentList = app.arguments();
|
2019-07-27 11:36:33 +02:00
|
|
|
|
2021-05-12 17:42:38 +02:00
|
|
|
// For testing purposes when starting the ScreenPlayWallpaper directly.
|
2021-04-18 17:23:21 +02:00
|
|
|
if (argumentList.length() == 1) {
|
2023-01-20 14:42:48 +01:00
|
|
|
window.setActiveScreensList({ 0 });
|
|
|
|
// window.setProjectPath("test");
|
|
|
|
window.setProjectPath("C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/1958068741");
|
|
|
|
window.setAppID("test");
|
|
|
|
window.setVolume(1);
|
|
|
|
window.setFillMode("fill");
|
|
|
|
window.setType(ScreenPlay::InstalledType::InstalledType::VideoWallpaper);
|
|
|
|
window.setCheckWallpaperVisible(true);
|
|
|
|
window.setDebugMode(true);
|
|
|
|
} else {
|
|
|
|
// 8 parameter + 1 OS working directory as the first default paramter
|
|
|
|
if (argumentList.length() != 9) {
|
2023-01-22 16:27:18 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExitCode::Invalid_ArgumentSize);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const auto activeScreensList = ScreenPlayUtil::parseStringToIntegerList(argumentList.at(1));
|
|
|
|
|
|
|
|
if (!activeScreensList.has_value()) {
|
|
|
|
qCritical("Could not activeScreensList");
|
2023-01-22 16:27:18 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExitCode::Invalid_ActiveScreensList);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
auto installedType = ScreenPlay::InstalledType::InstalledType::Unknown;
|
|
|
|
if (auto typeOpt = ScreenPlayUtil::getInstalledTypeFromString(argumentList.at(6))) {
|
|
|
|
installedType = typeOpt.value();
|
|
|
|
} else {
|
|
|
|
qCritical() << "Cannot parse Wallpaper type from value" << argumentList.at(6);
|
2023-01-22 16:27:18 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExitCode::Invalid_InstalledType);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool okParseCheckWallpaperVisible = false;
|
|
|
|
const bool checkWallpaperVisible = argumentList.at(7).toInt(&okParseCheckWallpaperVisible);
|
|
|
|
if (!okParseCheckWallpaperVisible) {
|
|
|
|
qCritical("Could not parse checkWallpaperVisible");
|
2023-01-22 16:27:18 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExitCode::Invalid_CheckWallpaperVisible);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
bool okParseVolume = 0.0f;
|
|
|
|
const float volume = argumentList.at(4).toFloat(&okParseVolume);
|
|
|
|
if (!okParseVolume) {
|
|
|
|
qCritical("Could not parse Volume");
|
2023-01-22 16:27:18 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExitCode::Invalid_Volume);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString appID = argumentList.at(3);
|
|
|
|
if (!appID.startsWith("appID=")) {
|
|
|
|
qCritical("Invalid appID");
|
2023-01-22 16:27:18 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExitCode::Invalid_AppID);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
appID = appID.remove("appID=");
|
|
|
|
|
|
|
|
window.setActiveScreensList(activeScreensList.value());
|
|
|
|
window.setProjectPath(argumentList.at(2));
|
|
|
|
window.setAppID(appID);
|
|
|
|
window.setVolume(volume);
|
|
|
|
window.setFillMode(argumentList.at(5));
|
|
|
|
window.setType(installedType);
|
|
|
|
window.setCheckWallpaperVisible(checkWallpaperVisible);
|
|
|
|
window.setDebugMode(false);
|
2019-03-14 18:56:19 +01:00
|
|
|
}
|
|
|
|
|
2023-01-20 14:42:48 +01:00
|
|
|
const auto setupStatus = window.setup();
|
2023-01-22 16:27:18 +01:00
|
|
|
if (setupStatus != ScreenPlay::WallpaperExitCode::Ok) {
|
2023-01-20 14:42:48 +01:00
|
|
|
return static_cast<int>(setupStatus);
|
2018-02-18 16:46:47 +01:00
|
|
|
}
|
2023-01-20 14:42:48 +01:00
|
|
|
const auto startStatus = window.start();
|
2023-01-22 16:27:18 +01:00
|
|
|
if (startStatus != ScreenPlay::WallpaperExitCode::Ok) {
|
2023-01-20 14:42:48 +01:00
|
|
|
return static_cast<int>(startStatus);
|
2020-02-15 17:49:48 +01:00
|
|
|
}
|
2019-03-10 21:20:55 +01:00
|
|
|
return app.exec();
|
2018-01-31 21:54:25 +01:00
|
|
|
}
|