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)
|
2023-12-03 11:43:17 +01:00
|
|
|
Q_IMPORT_QML_PLUGIN(ScreenPlayUtilPlugin)
|
2022-02-20 17:55:26 +01:00
|
|
|
|
2018-02-18 16:46:47 +01:00
|
|
|
int main(int argc, char* argv[])
|
2023-01-28 11:02:10 +01:00
|
|
|
{
|
2023-12-03 11:43:17 +01:00
|
|
|
using namespace ScreenPlay;
|
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-12-20 15:11:16 +01:00
|
|
|
|
|
|
|
QCoreApplication::setApplicationName("ScreenPlayWallpaper");
|
|
|
|
QCoreApplication::setApplicationVersion("1.0");
|
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
|
2019-07-27 11:36:33 +02:00
|
|
|
|
2023-12-20 15:11:16 +01:00
|
|
|
QStringList argumentList;
|
|
|
|
if (app.arguments().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-12-20 15:11:16 +01:00
|
|
|
argumentList.append(
|
|
|
|
QStringList {
|
|
|
|
// Docs: Don't forget that arguments must start with the name of the executable (ignored, though).
|
|
|
|
QGuiApplication::applicationName(),
|
|
|
|
"--path", projectPath,
|
|
|
|
"--appID", "qmz9lq4wglox5DdYaXumVgRSDeZYAUjC",
|
|
|
|
"--screens", "{0}",
|
|
|
|
"--volume", "1",
|
|
|
|
"--fillmode", "Contain",
|
|
|
|
"--type", "VideoWallpaper",
|
|
|
|
"--check", "0" });
|
2023-01-20 14:42:48 +01:00
|
|
|
} else {
|
2023-12-20 15:11:16 +01:00
|
|
|
argumentList = app.arguments();
|
|
|
|
}
|
|
|
|
|
|
|
|
QCommandLineParser parser;
|
|
|
|
parser.setApplicationDescription("ScreenPlay Wallpaper");
|
|
|
|
parser.addHelpOption();
|
|
|
|
|
|
|
|
// Define the command line options
|
|
|
|
QCommandLineOption pathOption("path", "Set the project path.", "path");
|
|
|
|
QCommandLineOption appIDOption("appID", "Set the application ID.", "appID");
|
|
|
|
QCommandLineOption screensOption("screens", "Set screens parameter.", "screens");
|
|
|
|
QCommandLineOption volumeOption("volume", "Set volume level.", "volume");
|
|
|
|
QCommandLineOption fillmodeOption("fillmode", "Set fill mode.", "fillmode");
|
|
|
|
QCommandLineOption typeOption("type", "Set the type.", "type");
|
|
|
|
QCommandLineOption checkOption("check", "Set check value.", "check");
|
|
|
|
|
|
|
|
// Add the options to the parser
|
|
|
|
parser.addOption(pathOption);
|
|
|
|
parser.addOption(appIDOption);
|
|
|
|
parser.addOption(screensOption);
|
|
|
|
parser.addOption(volumeOption);
|
|
|
|
parser.addOption(fillmodeOption);
|
|
|
|
parser.addOption(typeOption);
|
|
|
|
parser.addOption(checkOption);
|
|
|
|
|
|
|
|
// Process the actual command line arguments given by the user
|
|
|
|
parser.process(argumentList);
|
|
|
|
|
|
|
|
// Check if all required options are provided
|
|
|
|
if (!parser.isSet(pathOption)
|
|
|
|
|| !parser.isSet(appIDOption)
|
|
|
|
|| !parser.isSet(screensOption)
|
|
|
|
|| !parser.isSet(volumeOption)
|
|
|
|
|| !parser.isSet(fillmodeOption)
|
|
|
|
|| !parser.isSet(typeOption)
|
|
|
|
|| !parser.isSet(checkOption)) {
|
|
|
|
qCritical() << "Missing required arguments. Please provide all arguments."
|
|
|
|
<< argumentList
|
|
|
|
<< "pathOption" << parser.value(pathOption)
|
|
|
|
<< "appIDOption" << parser.value(appIDOption)
|
|
|
|
<< "typeOption" << parser.value(typeOption)
|
|
|
|
<< "volumeOption" << parser.value(volumeOption)
|
|
|
|
<< "fillmodeOption" << parser.value(fillmodeOption)
|
|
|
|
<< "typeOption" << parser.value(typeOption)
|
|
|
|
<< "checkOption" << parser.value(checkOption);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString path = parser.value(pathOption);
|
|
|
|
QString appID = parser.value(appIDOption);
|
|
|
|
QString screens = parser.value(screensOption);
|
|
|
|
QString volume = parser.value(volumeOption);
|
|
|
|
QString fillmode = parser.value(fillmodeOption);
|
|
|
|
QString type = parser.value(typeOption);
|
|
|
|
QString check = parser.value(checkOption);
|
|
|
|
|
|
|
|
ScreenPlay::Util util;
|
|
|
|
|
|
|
|
auto activeScreensList = util.parseStringToIntegerList(screens);
|
|
|
|
if (!activeScreensList.has_value()) {
|
|
|
|
qCritical() << "Could not parse activeScreensList" << screens;
|
|
|
|
return static_cast<int>(WallpaperExit::Code::Invalid_ActiveScreensList);
|
2019-03-14 18:56:19 +01:00
|
|
|
}
|
|
|
|
|
2023-12-20 15:11:16 +01:00
|
|
|
auto installedType = util.getInstalledTypeFromString(type);
|
|
|
|
if (!installedType.has_value()) {
|
|
|
|
qCritical() << "Cannot parse Wallpaper type from value" << type;
|
|
|
|
return static_cast<int>(WallpaperExit::Code::Invalid_InstalledType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool okParseCheckWallpaperVisible = false;
|
|
|
|
const bool checkWallpaperVisible = check.toInt(&okParseCheckWallpaperVisible);
|
|
|
|
if (!okParseCheckWallpaperVisible) {
|
|
|
|
qCritical("Could not parse checkWallpaperVisible");
|
|
|
|
return static_cast<int>(WallpaperExit::Code::Invalid_CheckWallpaperVisible);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool okParseVolume = false;
|
|
|
|
const float volumeFloat = volume.toFloat(&okParseVolume);
|
|
|
|
if (!okParseVolume) {
|
|
|
|
qCritical("Could not parse Volume");
|
|
|
|
return static_cast<int>(WallpaperExit::Code::Invalid_Volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the properties of the window object
|
|
|
|
window->setActiveScreensList(activeScreensList.value());
|
|
|
|
window->setProjectPath(path);
|
|
|
|
window->setAppID(appID);
|
|
|
|
window->setVolume(volumeFloat);
|
|
|
|
window->setFillMode(fillmode);
|
|
|
|
window->setType(installedType.value());
|
|
|
|
window->setCheckWallpaperVisible(checkWallpaperVisible);
|
|
|
|
window->setDebugMode(false);
|
|
|
|
|
2023-10-29 11:26:42 +01:00
|
|
|
const auto setupStatus = window->setup();
|
2023-12-03 11:43:17 +01:00
|
|
|
if (setupStatus != 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-03 11:43:17 +01:00
|
|
|
if (startStatus != 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-12-20 15:11:16 +01:00
|
|
|
logging = std::make_unique<const ScreenPlayUtil::LoggingHandler>("ScreenPlayWallpaper_" + parser.value(appIDOption));
|
2023-10-29 18:10:13 +01:00
|
|
|
const int status = app.exec();
|
|
|
|
logging.reset();
|
|
|
|
return status;
|
2018-01-31 21:54:25 +01:00
|
|
|
}
|