1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00
ScreenPlay/ScreenPlayWallpaper/main.cpp
Elias Steurer e7f1e61d33 Refactor wallpaper connection
Change sdk connection from shared to unqiue ptr
to make sure to only have one connection alive at
every time. This fixes to removal of wallpaper because
of a bug a shared connection as set in the monitorlistmodel.

The SDK connection is now part of the ScreenPlayWallpaper/Widget.
2021-04-18 17:23:21 +02:00

116 lines
3.3 KiB
C++

#include <QApplication>
#include <QObject>
#include <QStringList>
#include <QVector>
#include <QtGlobal>
#include <QtWebEngine>
#include "ScreenPlayUtil/util.h"
#if defined(Q_OS_WIN)
#include "src/winwindow.h"
#endif
#if defined(Q_OS_LINUX)
#include "src/linuxwindow.h"
#endif
#if defined(Q_OS_OSX)
#include "src/macwindow.h"
#endif
int main(int argc, char* argv[])
{
//QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication app(argc, argv);
// This gives us nice clickable output in QtCreator
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
// If we start with only one argument (app path)
// It means we want to test a single wallpaper
QStringList argumentList = app.arguments();
if (argumentList.length() == 1) {
#if defined(Q_OS_WIN)
WinWindow window1({ 0 }, "test", "appID=test", "1", "fill", "videoWallpaper", true, true);
//WinWindow window2({ 1 }, "test", "appID=xyz", "1", "fill", true, true);
//WinWindow window3({ 2 }, "test", "appID=123", "1", "fill", true,true);
#endif
#if defined(Q_OS_LINUX)
LinuxWindow window({ 0 }, "/home/graphicscore/Desktop/wallpapers/MechaGirl", "appid", "1", "fill", false);
#endif
#if defined(Q_OS_OSX)
MacWindow window({ 0 }, "test", "appid", "1", "fill");
#endif
return app.exec();
}
// 8 parameter + 1 OS working directory as the first default paramter
if (argumentList.length() != 9) {
return -3;
}
const bool debugMode = true;
const auto activeScreensList = ScreenPlayUtil::parseStringToIntegerList(argumentList.at(1));
if (!activeScreensList.has_value())
return -4;
// See ScreenPlayWallpaper m_appArgumentsList constructor how the args get created
const QString projectFilePath = argumentList.at(2);
const QString appID = argumentList.at(3);
const QString volume = argumentList.at(4);
const QString fillmode = argumentList.at(5);
const QString type = argumentList.at(6);
bool okParseCheckWallpaperVisible = false;
bool checkWallpaperVisible = argumentList.at(7).toInt(&okParseCheckWallpaperVisible);
if (!okParseCheckWallpaperVisible) {
qFatal("Could not parse checkWallpaperVisible");
return -5;
}
#if defined(Q_OS_WIN)
WinWindow window(
activeScreensList.value(),
projectFilePath,
appID,
volume,
fillmode,
type,
checkWallpaperVisible,
debugMode);
#endif
#if defined(Q_OS_LINUX)
LinuxWindow window(
activeScreensList.value(),
projectPath,
appID,
fillmode,
volume,
checkWallpaperVisible);
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &LinuxWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &LinuxWindow::messageReceived);
#endif
#if defined(Q_OS_OSX)
MacWindow window(
activeScreensList.value(),
projectPath,
appID,
fillmode,
volume,
checkWallpaperVisible);
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &MacWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &MacWindow::messageReceived);
#endif
return app.exec();
}