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>
|
|
|
|
#include <QtWebEngine>
|
2019-03-10 21:20:55 +01:00
|
|
|
|
|
|
|
#if defined(Q_OS_WIN)
|
2020-03-07 21:37:01 +01:00
|
|
|
|
2019-03-10 21:20:55 +01:00
|
|
|
#include "src/winwindow.h"
|
|
|
|
#endif
|
|
|
|
|
2019-04-01 13:42:35 +02:00
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
#include "src/linuxwindow.h"
|
|
|
|
#endif
|
|
|
|
|
2019-03-27 18:38:36 +01:00
|
|
|
#if 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
|
|
|
|
|
|
|
|
#include "../ScreenPlaySDK/screenplaysdk.h"
|
2018-01-31 21:54:25 +01:00
|
|
|
|
2018-02-18 16:46:47 +01:00
|
|
|
int main(int argc, char* argv[])
|
2018-01-31 21:54:25 +01:00
|
|
|
{
|
2018-09-06 13:57:36 +02:00
|
|
|
|
2018-02-18 16:46:47 +01:00
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
2020-03-27 14:29:44 +01:00
|
|
|
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
2018-12-01 18:01:17 +01:00
|
|
|
|
2019-03-10 21:20:55 +01:00
|
|
|
QApplication app(argc, argv);
|
2019-11-23 11:40:52 +01:00
|
|
|
|
2019-03-27 18:38:36 +01:00
|
|
|
// This gives us nice clickable output in QtCreator
|
|
|
|
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
|
|
|
|
|
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-03-27 18:38:36 +01:00
|
|
|
QStringList argumentList = app.arguments();
|
2019-03-24 16:52:07 +01:00
|
|
|
if (argumentList.length() == 1) {
|
2019-09-14 19:33:58 +02:00
|
|
|
|
|
|
|
//Set the monitor number to test
|
2019-07-27 11:36:33 +02:00
|
|
|
|
2019-03-27 18:38:36 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
2020-03-07 21:37:01 +01:00
|
|
|
|
2020-02-15 18:03:36 +01:00
|
|
|
//WinWindow window1({ 0 }, "test", "appid", "1", "fill");
|
|
|
|
//WinWindow window2({ 1 }, "test", "appid", "1", "fill");
|
|
|
|
//WinWindow window3({ 2 }, "test", "appid", "1", "fill");
|
2019-09-14 19:33:58 +02:00
|
|
|
|
2020-03-28 17:22:56 +01:00
|
|
|
WinWindow window({ 0 }, "C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/1958068745", "appid", "1", "fill", true);
|
2019-03-27 18:38:36 +01:00
|
|
|
#endif
|
2019-04-01 13:42:35 +02:00
|
|
|
#if defined(Q_OS_LINUX)
|
2020-03-27 16:18:15 +01:00
|
|
|
LinuxWindow window({ 0 }, "/home/graphicscore/Desktop/wallpapers/MechaGirl", "appid", "1", "fill", false);
|
2019-04-01 13:42:35 +02:00
|
|
|
#endif
|
2019-04-04 17:20:13 +02:00
|
|
|
#if defined(Q_OS_OSX)
|
2020-01-30 16:32:24 +01:00
|
|
|
MacWindow window({ 0 }, "test", "appid", "1", "fill");
|
2019-04-04 17:20:13 +02:00
|
|
|
#endif
|
2019-04-01 13:42:35 +02:00
|
|
|
|
2019-03-14 18:56:19 +01:00
|
|
|
return app.exec();
|
|
|
|
}
|
|
|
|
|
2019-09-14 19:33:58 +02:00
|
|
|
// 6 parameter + 1 OS working directory default paramter
|
2020-05-23 14:37:00 +02:00
|
|
|
if (argumentList.length() != 9) {
|
2018-02-18 16:46:47 +01:00
|
|
|
return -3;
|
|
|
|
}
|
|
|
|
|
2019-09-14 19:33:58 +02:00
|
|
|
// AppID, Type
|
2020-02-15 17:49:48 +01:00
|
|
|
ScreenPlaySDK sdk(argumentList.at(3), argumentList.at(6));
|
2018-02-18 16:46:47 +01:00
|
|
|
|
2019-03-10 21:20:55 +01:00
|
|
|
QString monitorNumbers = argumentList.at(1);
|
2019-08-10 16:38:44 +02:00
|
|
|
QStringList activeScreensList = monitorNumbers.split(",");
|
2019-09-06 14:16:08 +02:00
|
|
|
|
2019-08-10 16:38:44 +02:00
|
|
|
activeScreensList.removeAll(",");
|
2019-03-10 21:20:55 +01:00
|
|
|
QVector<int> list;
|
|
|
|
|
|
|
|
if (monitorNumbers.length() == 1) {
|
|
|
|
bool canParseMonitorNumber = false;
|
|
|
|
int monitor = monitorNumbers.toInt(&canParseMonitorNumber);
|
2019-03-14 18:56:19 +01:00
|
|
|
if (!canParseMonitorNumber) {
|
|
|
|
qFatal("Could not parse monitor id to diplay wallpaper");
|
2019-11-23 17:19:26 +01:00
|
|
|
} else {
|
|
|
|
list.append(monitor);
|
2019-03-14 18:56:19 +01:00
|
|
|
}
|
2019-11-23 17:19:26 +01:00
|
|
|
|
2019-03-10 21:20:55 +01:00
|
|
|
} else {
|
2019-08-10 16:38:44 +02:00
|
|
|
|
|
|
|
for (const QString& s : activeScreensList) {
|
2019-03-10 21:20:55 +01:00
|
|
|
bool ok = false;
|
|
|
|
int val = s.toInt(&ok);
|
|
|
|
if (!ok) {
|
|
|
|
qFatal("Could not parse monitor id to diplay wallpaper");
|
2019-11-23 17:19:26 +01:00
|
|
|
} else {
|
|
|
|
list.append(val);
|
2019-03-10 21:20:55 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-18 16:46:47 +01:00
|
|
|
}
|
2018-02-14 10:21:15 +01:00
|
|
|
|
2020-02-15 17:49:48 +01:00
|
|
|
if (list.empty()) {
|
2019-11-23 17:19:26 +01:00
|
|
|
return -4;
|
|
|
|
}
|
2020-02-15 17:49:48 +01:00
|
|
|
|
|
|
|
// Args: which monitor, (2) path to project, (3)wallpaper secret to identify the connected socket, (4) volume, (5) fillmode, (6) type, (7)
|
2018-09-06 13:57:36 +02:00
|
|
|
// See screenplay.h @ScreenPlayWallpaper constructor how the args get created
|
2019-09-12 21:03:58 +02:00
|
|
|
qDebug() << argumentList;
|
2018-02-22 15:22:10 +01:00
|
|
|
|
2020-02-15 17:49:48 +01:00
|
|
|
bool okParseCheckWallpaperVisible = false;
|
|
|
|
bool checkWallpaperVisible = argumentList.at(7).toInt(&okParseCheckWallpaperVisible);
|
|
|
|
if (!okParseCheckWallpaperVisible) {
|
|
|
|
qFatal("Could not parse checkWallpaperVisible");
|
|
|
|
return -5;
|
|
|
|
}
|
|
|
|
|
2019-03-10 21:20:55 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
2020-02-15 17:49:48 +01:00
|
|
|
WinWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5), checkWallpaperVisible);
|
2019-03-10 21:20:55 +01:00
|
|
|
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &WinWindow::destroyThis);
|
|
|
|
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &WinWindow::messageReceived);
|
|
|
|
#endif
|
2018-09-06 13:57:36 +02:00
|
|
|
|
2019-04-01 13:42:35 +02:00
|
|
|
#if defined(Q_OS_LINUX)
|
2020-03-27 16:18:15 +01:00
|
|
|
LinuxWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5), checkWallpaperVisible);
|
2019-04-01 13:42:35 +02:00
|
|
|
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &LinuxWindow::destroyThis);
|
|
|
|
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &LinuxWindow::messageReceived);
|
|
|
|
#endif
|
|
|
|
|
2019-03-27 18:38:36 +01:00
|
|
|
#if defined(Q_OS_OSX)
|
2020-04-20 16:36:49 +02:00
|
|
|
MacWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5));
|
|
|
|
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &MacWindow::destroyThis);
|
|
|
|
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &MacWindow::messageReceived);
|
2019-03-27 18:38:36 +01:00
|
|
|
#endif
|
|
|
|
|
2019-03-10 21:20:55 +01:00
|
|
|
return app.exec();
|
2018-01-31 21:54:25 +01:00
|
|
|
}
|