2023-02-03 16:17:47 +01:00
|
|
|
|
2023-02-03 17:03:10 +01:00
|
|
|
#include <QGuiApplication>
|
2019-03-27 18:38:36 +01:00
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
2020-02-15 17:49:48 +01:00
|
|
|
#include <QVector>
|
2019-03-27 18:38:36 +01:00
|
|
|
#include <QtGlobal>
|
2023-07-29 11:21:05 +02:00
|
|
|
#include <QtWebEngineQuick>
|
|
|
|
|
|
|
|
#include "ScreenPlayWallpaper/CMakeVariables.h"
|
2019-03-10 21:20:55 +01:00
|
|
|
|
2023-01-22 16:28:15 +01:00
|
|
|
#include "ScreenPlayUtil/exitcodes.h"
|
2023-10-29 18:10:13 +01:00
|
|
|
#include "ScreenPlayUtil/logginghandler.h"
|
2023-11-01 12:28:35 +01:00
|
|
|
#include "ScreenPlayUtil/util.h"
|
2021-04-18 17:23:21 +02:00
|
|
|
|
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)
|
2023-10-29 11:26:42 +01:00
|
|
|
#include "src/linuxwaylandwindow.h"
|
2023-11-01 12:28:35 +01:00
|
|
|
#include "src/linuxx11window.h"
|
2023-11-09 18:06:52 +01:00
|
|
|
#elif defined(Q_OS_MACOS)
|
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[])
|
2023-01-28 11:02:10 +01:00
|
|
|
{
|
2023-01-27 11:12:45 +01:00
|
|
|
|
2023-07-29 11:21:05 +02:00
|
|
|
// Lets keep using it until: https://bugreports.qt.io/browse/QTBUG-109401
|
|
|
|
QtWebEngineQuick::initialize();
|
|
|
|
|
2023-03-02 13:22:26 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
2023-07-24 16:22:09 +02:00
|
|
|
// Workaround for Qt 6.5.1 crash https://bugreports.qt.io/browse/QTBUG-113832
|
|
|
|
qputenv("QT_DISABLE_HW_TEXTURES_CONVERSION", "1");
|
|
|
|
qputenv("QT_MEDIA_BACKEND", "ffmpeg");
|
2023-03-02 13:22:26 +01:00
|
|
|
#endif
|
|
|
|
|
2023-02-03 16:17:47 +01:00
|
|
|
QGuiApplication app(argc, argv);
|
2023-10-29 18:10:13 +01:00
|
|
|
std::unique_ptr<const ScreenPlayUtil::LoggingHandler> logging;
|
2023-10-29 11:26:42 +01:00
|
|
|
std::unique_ptr<BaseWindow> window;
|
|
|
|
const auto platformName = QGuiApplication::platformName();
|
2019-11-23 11:40:52 +01:00
|
|
|
|
2023-01-20 14:42:48 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
2023-10-29 11:26:42 +01:00
|
|
|
window = std::make_unique<WinWindow>();
|
2023-01-20 14:42:48 +01:00
|
|
|
#elif defined(Q_OS_LINUX)
|
2023-11-01 12:28:35 +01:00
|
|
|
if (platformName == "xcb") {
|
|
|
|
window = std::make_unique<LinuxX11Window>();
|
|
|
|
} else if (platformName == "wayland") {
|
2023-10-29 11:26:42 +01:00
|
|
|
window = std::make_unique<LinuxWaylandWindow>();
|
|
|
|
}
|
2023-11-09 18:06:52 +01:00
|
|
|
#elif defined(Q_OS_MACOS)
|
2023-10-29 11:26:42 +01:00
|
|
|
window = std::make_unique<MacWindow>();
|
2023-01-20 14:42:48 +01:00
|
|
|
#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();
|
2023-10-29 18:10:13 +01:00
|
|
|
QString appID;
|
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-02-18 14:30:06 +01:00
|
|
|
QString exampleContentPath = QString(SCREENPLAY_SOURCE_DIR) + "/Content";
|
|
|
|
QStringList contentFolder = {
|
2023-07-29 11:18:21 +02:00
|
|
|
"/wallpaper_html", // 0
|
|
|
|
"/wallpaper_qml", // 1
|
|
|
|
"/wallpaper_qml_landscape", // 2
|
|
|
|
"/wallpaper_qml_particles", // 3
|
|
|
|
"/wallpaper_video_astronaut_vp9", // 4
|
|
|
|
"/wallpaper_video_nebula_h264" // 5
|
2023-02-18 14:30:06 +01:00
|
|
|
};
|
2023-10-29 18:10:13 +01:00
|
|
|
const int index = 5;
|
2023-07-29 11:18:21 +02:00
|
|
|
QString projectPath = exampleContentPath + contentFolder.at(index);
|
2023-02-18 14:30:06 +01:00
|
|
|
|
2023-10-29 11:26:42 +01:00
|
|
|
window->setActiveScreensList({ 0 });
|
|
|
|
window->setProjectPath(projectPath);
|
|
|
|
window->setAppID("test");
|
|
|
|
window->setVolume(1);
|
|
|
|
window->setFillMode("cover");
|
2023-12-01 14:50:36 +01:00
|
|
|
window->setType(ScreenPlay::ContentTypes::InstalledType::VideoWallpaper);
|
2023-10-29 11:26:42 +01:00
|
|
|
window->setCheckWallpaperVisible(true);
|
|
|
|
window->setDebugMode(false);
|
2023-01-20 14:42:48 +01:00
|
|
|
} else {
|
|
|
|
// 8 parameter + 1 OS working directory as the first default paramter
|
|
|
|
if (argumentList.length() != 9) {
|
2023-12-01 14:50:36 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExit::Code::Invalid_ArgumentSize);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
2023-12-01 16:15:53 +01:00
|
|
|
ScreenPlay::Util util;
|
|
|
|
const auto activeScreensList = util.parseStringToIntegerList(argumentList.at(1));
|
2023-01-20 14:42:48 +01:00
|
|
|
|
|
|
|
if (!activeScreensList.has_value()) {
|
|
|
|
qCritical("Could not activeScreensList");
|
2023-12-01 14:50:36 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExit::Code::Invalid_ActiveScreensList);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
|
2023-12-01 14:50:36 +01:00
|
|
|
auto installedType = ScreenPlay::ContentTypes::InstalledType::Unknown;
|
2023-12-01 16:15:53 +01:00
|
|
|
if (auto typeOpt = util.getInstalledTypeFromString(argumentList.at(6))) {
|
2023-01-20 14:42:48 +01:00
|
|
|
installedType = typeOpt.value();
|
|
|
|
} else {
|
|
|
|
qCritical() << "Cannot parse Wallpaper type from value" << argumentList.at(6);
|
2023-12-01 14:50:36 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExit::Code::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-12-01 14:50:36 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExit::Code::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-12-01 14:50:36 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExit::Code::Invalid_Volume);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
|
2023-10-29 18:10:13 +01:00
|
|
|
appID = argumentList.at(3);
|
2023-01-20 14:42:48 +01:00
|
|
|
if (!appID.startsWith("appID=")) {
|
|
|
|
qCritical("Invalid appID");
|
2023-12-01 14:50:36 +01:00
|
|
|
return static_cast<int>(ScreenPlay::WallpaperExit::Code::Invalid_AppID);
|
2023-01-20 14:42:48 +01:00
|
|
|
}
|
|
|
|
appID = appID.remove("appID=");
|
|
|
|
|
2023-10-29 11:26:42 +01:00
|
|
|
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-10-29 11:26:42 +01:00
|
|
|
const auto setupStatus = window->setup();
|
2023-12-01 14:50:36 +01:00
|
|
|
if (setupStatus != ScreenPlay::WallpaperExit::Code::Ok) {
|
2023-01-20 14:42:48 +01:00
|
|
|
return static_cast<int>(setupStatus);
|
2018-02-18 16:46:47 +01:00
|
|
|
}
|
2023-10-29 11:26:42 +01:00
|
|
|
const auto startStatus = window->start();
|
2023-12-01 14:50:36 +01:00
|
|
|
if (startStatus != ScreenPlay::WallpaperExit::Code::Ok) {
|
2023-01-20 14:42:48 +01:00
|
|
|
return static_cast<int>(startStatus);
|
2020-02-15 17:49:48 +01:00
|
|
|
}
|
2023-10-29 11:26:42 +01:00
|
|
|
emit window->qmlStart();
|
2023-10-29 18:10:13 +01:00
|
|
|
logging = std::make_unique<const ScreenPlayUtil::LoggingHandler>("ScreenPlayWallpaper_" + appID);
|
|
|
|
const int status = app.exec();
|
|
|
|
logging.reset();
|
|
|
|
return status;
|
2018-01-31 21:54:25 +01:00
|
|
|
}
|