1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Add working pause visual part of the video with settings

This commit is contained in:
Elias Steurer 2020-02-15 17:49:48 +01:00
parent 4ebd0af183
commit 9f06f75f66
14 changed files with 150 additions and 166 deletions

View File

@ -95,7 +95,7 @@ App::App()
} }
m_create = make_unique<Create>(m_globalVariables); m_create = make_unique<Create>(m_globalVariables);
m_screenPlayManager = make_unique<ScreenPlayManager>(m_globalVariables, m_monitorListModel, m_sdkConnector, m_telemetry); m_screenPlayManager = make_unique<ScreenPlayManager>(m_globalVariables, m_monitorListModel, m_sdkConnector, m_telemetry, m_settings);
QObject::connect(m_sdkConnector.get(), &SDKConnector::requestDecreaseWidgetCount, m_screenPlayManager.get(), &ScreenPlayManager::decreaseActiveWidgetsCounter); QObject::connect(m_sdkConnector.get(), &SDKConnector::requestDecreaseWidgetCount, m_screenPlayManager.get(), &ScreenPlayManager::decreaseActiveWidgetsCounter);
// When the installed storage path changed // When the installed storage path changed

View File

@ -267,15 +267,14 @@ Item {
spacing: 10 spacing: 10
SettingBool { SettingBool {
headline: qsTr("Pause wallpaper while ingame") headline: qsTr("Pause wallpaper while another app is in the foreground")
available: false description: qsTr("We disable the video rendering (not the audio!) for the best performance. If you have problem you can disable this behaviour here. Wallpaper restart required!")
description: qsTr("To maximise your framerates ingame, you can enable this setting to pause all active wallpapers!") isChecked: ScreenPlay.settings.checkWallpaperVisible
isChecked: ScreenPlay.settings.pauseWallpaperWhenIngame
onCheckboxChanged: { onCheckboxChanged: {
ScreenPlay.settings.setPauseWallpaperWhenIngame( ScreenPlay.settings.setCheckWallpaperVisible(
checked) checked)
ScreenPlay.settings.writeSingleSettingConfig( ScreenPlay.settings.writeSingleSettingConfig(
"setPauseWallpaperWhenIngame", "checkWallpaperVisible",
checked) checked)
} }
} }

View File

@ -19,12 +19,14 @@ ScreenPlayManager::ScreenPlayManager(
const shared_ptr<MonitorListModel>& mlm, const shared_ptr<MonitorListModel>& mlm,
const shared_ptr<SDKConnector>& sdkc, const shared_ptr<SDKConnector>& sdkc,
const shared_ptr<GAnalytics>& telemetry, const shared_ptr<GAnalytics>& telemetry,
const shared_ptr<Settings>& settings,
QObject* parent) QObject* parent)
: QObject { parent } : QObject { parent }
, m_globalVariables { globalVariables } , m_globalVariables { globalVariables }
, m_monitorListModel { mlm } , m_monitorListModel { mlm }
, m_sdkconnector { sdkc } , m_sdkconnector { sdkc }
, m_telemetry { telemetry } , m_telemetry { telemetry }
, m_settings { settings }
{ {
loadWallpaperProfiles(); loadWallpaperProfiles();
} }
@ -59,44 +61,17 @@ void ScreenPlayManager::createWallpaper(
monitors.append(index); monitors.append(index);
} }
QJsonObject settings;
std::shared_ptr<ScreenPlayWallpaper> wallpaper; std::shared_ptr<ScreenPlayWallpaper> wallpaper;
wallpaper = make_shared<ScreenPlayWallpaper>(
if (type == "videoWallpaper") { monitorIndex,
wallpaper = make_shared<ScreenPlayWallpaper>( m_globalVariables,
monitorIndex, Util::generateRandomString(),
m_globalVariables, path,
Util::generateRandomString(), previewImage,
path, volume,
previewImage, fillMode,
volume, type,
fillMode, m_settings->checkWallpaperVisible());
type);
settings.insert("monitors", monitors);
settings.insert("type", type);
settings.insert("volume", static_cast<double>(volume));
settings.insert("isLooping", true);
settings.insert("fillMode", fillMode);
settings.insert("previewImage", previewImage);
settings.insert("absolutePath", path);
} else if (type == "qmlWallpaper" || type == "htmlWallpaper") {
wallpaper = make_shared<ScreenPlayWallpaper>(
monitorIndex,
m_globalVariables,
Util::generateRandomString(),
path,
previewImage,
type,
settings);
settings.insert("monitors", monitors);
settings.insert("type", type);
settings.insert("previewImage", previewImage);
settings.insert("absolutePath", path);
}
// Only support remove wallpaper that spans over 1 monitor // Only support remove wallpaper that spans over 1 monitor
if (monitorIndex.length() == 1) { if (monitorIndex.length() == 1) {
@ -113,11 +88,20 @@ void ScreenPlayManager::createWallpaper(
m_screenPlayWallpapers.append(wallpaper); m_screenPlayWallpapers.append(wallpaper);
m_monitorListModel->setWallpaperActiveMonitor(wallpaper, monitorIndex); m_monitorListModel->setWallpaperActiveMonitor(wallpaper, monitorIndex);
increaseActiveWallpaperCounter();
if (saveToProfilesConfigFile && type == "videoWallpaper") {
QJsonObject settings;
settings.insert("monitors", monitors);
settings.insert("type", type);
settings.insert("volume", static_cast<double>(volume));
settings.insert("isLooping", true);
settings.insert("fillMode", fillMode);
settings.insert("previewImage", previewImage);
settings.insert("absolutePath", path);
if (saveToProfilesConfigFile) {
saveWallpaperProfile("default", settings); saveWallpaperProfile("default", settings);
} }
increaseActiveWallpaperCounter();
} }
/*! /*!
@ -379,12 +363,6 @@ void ScreenPlayManager::loadWallpaperProfiles()
monitors.append(value); monitors.append(value);
} }
bool parsing = true;
bool isLooping = wallpaperObj.value("isLooping").toBool(parsing);
if (!parsing)
continue;
float volume = static_cast<float>(wallpaperObj.value("volume").toDouble(-1.0)); float volume = static_cast<float>(wallpaperObj.value("volume").toDouble(-1.0));
if (volume == -1.0F) if (volume == -1.0F)

View File

@ -15,6 +15,7 @@
#include "screenplaywallpaper.h" #include "screenplaywallpaper.h"
#include "screenplaywidget.h" #include "screenplaywidget.h"
#include "sdkconnector.h" #include "sdkconnector.h"
#include "settings.h"
#include "util.h" #include "util.h"
#include <memory> #include <memory>
@ -42,6 +43,7 @@ public:
const shared_ptr<MonitorListModel>& mlm, const shared_ptr<MonitorListModel>& mlm,
const shared_ptr<SDKConnector>& sdkc, const shared_ptr<SDKConnector>& sdkc,
const shared_ptr<GAnalytics>& telemetry, const shared_ptr<GAnalytics>& telemetry,
const shared_ptr<Settings>& settings,
QObject* parent = nullptr); QObject* parent = nullptr);
int activeWallpaperCounter() const int activeWallpaperCounter() const
@ -136,6 +138,7 @@ private:
const shared_ptr<MonitorListModel>& m_monitorListModel; const shared_ptr<MonitorListModel>& m_monitorListModel;
const shared_ptr<SDKConnector>& m_sdkconnector; const shared_ptr<SDKConnector>& m_sdkconnector;
const shared_ptr<GAnalytics>& m_telemetry; const shared_ptr<GAnalytics>& m_telemetry;
const shared_ptr<Settings>& m_settings;
QVector<shared_ptr<ScreenPlayWallpaper>> m_screenPlayWallpapers; QVector<shared_ptr<ScreenPlayWallpaper>> m_screenPlayWallpapers;
QVector<shared_ptr<ScreenPlayWidget>> m_screenPlayWidgets; QVector<shared_ptr<ScreenPlayWidget>> m_screenPlayWidgets;

View File

@ -1,6 +1,5 @@
#include "screenplaywallpaper.h" #include "screenplaywallpaper.h"
namespace ScreenPlay { namespace ScreenPlay {
/*! /*!
@ -23,6 +22,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
const float volume, const float volume,
const QString& fillMode, const QString& fillMode,
const QString& type, const QString& type,
const bool checkWallpaperVisible,
QObject* parent) QObject* parent)
: QObject(parent) : QObject(parent)
, m_projectSettingsListModel { make_shared<ProjectSettingsListModel>(absolutePath + "/project.json") } , m_projectSettingsListModel { make_shared<ProjectSettingsListModel>(absolutePath + "/project.json") }
@ -57,62 +57,8 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
QString { "appID=" + m_appID }, QString { "appID=" + m_appID },
QString::number(static_cast<double>(volume)), QString::number(static_cast<double>(volume)),
fillMode, fillMode,
type type,
}; QString::number(checkWallpaperVisible)
qDebug() << "Creating ScreenPlayWallpaper " << proArgs;
m_process.setArguments(proArgs);
m_process.setProgram(m_globalVariables->wallpaperExecutablePath().toString());
m_process.startDetached();
}
/*!
Constructor for scene Wallpaper with multile json settings.
*/
ScreenPlayWallpaper::ScreenPlayWallpaper(
const QVector<int>& screenNumber,
const shared_ptr<GlobalVariables>& globalVariables,
const QString& appID,
const QString& absolutePath,
const QString& previewImage,
const QString& type,
const QJsonObject& profileJsonObject,
QObject* parent)
: QObject(parent)
, m_projectSettingsListModel { make_shared<ProjectSettingsListModel>(absolutePath + "/project.json") }
, m_globalVariables { globalVariables }
, m_screenNumber { screenNumber }
, m_previewImage { QString { absolutePath + "/" + previewImage } }
, m_type { type }
, m_appID { appID }
, m_absolutePath { absolutePath }
, m_profileJsonObject { profileJsonObject }
{
QObject::connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &ScreenPlayWallpaper::processExit);
QObject::connect(&m_process, &QProcess::errorOccurred, this, &ScreenPlayWallpaper::processError);
QString tmpScreenNumber;
if (m_screenNumber.length() > 1) {
for (const int number : m_screenNumber) {
// IMPORTANT: NO TRAILING COMMA!
if (number == m_screenNumber.back()) {
tmpScreenNumber += QString::number(number);
} else {
tmpScreenNumber += QString::number(number) + ",";
}
}
} else {
tmpScreenNumber = QString::number(m_screenNumber.first());
}
const QStringList proArgs {
tmpScreenNumber,
m_absolutePath,
QString { "appID=" + m_appID },
QString::number(static_cast<double>(1)),
"fill",
type
}; };
qDebug() << "Creating ScreenPlayWallpaper " << proArgs; qDebug() << "Creating ScreenPlayWallpaper " << proArgs;

View File

@ -28,8 +28,7 @@ class ScreenPlayWallpaper : public QObject {
Q_PROPERTY(QJsonObject profileJsonObject READ profileJsonObject WRITE setProfileJsonObject NOTIFY profileJsonObjectChanged) Q_PROPERTY(QJsonObject profileJsonObject READ profileJsonObject WRITE setProfileJsonObject NOTIFY profileJsonObjectChanged)
public: public:
explicit ScreenPlayWallpaper( explicit ScreenPlayWallpaper(const QVector<int>& screenNumber,
const QVector<int>& screenNumber,
const shared_ptr<GlobalVariables>& globalVariables, const shared_ptr<GlobalVariables>& globalVariables,
const QString& appID, const QString& appID,
const QString& absolutePath, const QString& absolutePath,
@ -37,6 +36,7 @@ public:
const float volume, const float volume,
const QString& fillMode, const QString& fillMode,
const QString& type, const QString& type,
const bool checkWallpaperVisible,
QObject* parent = nullptr); QObject* parent = nullptr);
explicit ScreenPlayWallpaper( explicit ScreenPlayWallpaper(

View File

@ -147,13 +147,13 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
} }
} else { } else {
if(!steamWorkshopContentPath.cd("workshop")){ if (!steamWorkshopContentPath.cd("workshop")) {
qDebug() << "Error! No workshop folder found in path: " << steamWorkshopContentPath.absolutePath(); qDebug() << "Error! No workshop folder found in path: " << steamWorkshopContentPath.absolutePath();
} }
if(!steamWorkshopContentPath.cd("content")){ if (!steamWorkshopContentPath.cd("content")) {
qDebug() << "Error! No content folder found in path: " << steamWorkshopContentPath.absolutePath(); qDebug() << "Error! No content folder found in path: " << steamWorkshopContentPath.absolutePath();
} }
if(!steamWorkshopContentPath.cd("672870")){ if (!steamWorkshopContentPath.cd("672870")) {
qDebug() << "Error! No 672870 folder found in path: " << steamWorkshopContentPath.absolutePath(); qDebug() << "Error! No 672870 folder found in path: " << steamWorkshopContentPath.absolutePath();
} }
qDebug() << "Setup installed content path at" << steamWorkshopContentPath.absolutePath(); qDebug() << "Setup installed content path at" << steamWorkshopContentPath.absolutePath();
@ -177,6 +177,7 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
m_qSettings.sync(); m_qSettings.sync();
} }
m_checkWallpaperVisible = configObj.value().value("checkWallpaperVisible").toBool();
m_autostart = configObj.value().value("autostart").toBool(); m_autostart = configObj.value().value("autostart").toBool();
m_highPriorityStart = configObj.value().value("highPriorityStart").toBool(); m_highPriorityStart = configObj.value().value("highPriorityStart").toBool();
m_anonymousTelemetry = configObj.value().value("anonymousTelemetry").toBool(); m_anonymousTelemetry = configObj.value().value("anonymousTelemetry").toBool();

View File

@ -25,13 +25,12 @@
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <QtGlobal> #include <QtGlobal>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include "globalvariables.h" #include "globalvariables.h"
#include "util.h"
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#include "util.h"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <qt_windows.h> #include <qt_windows.h>
@ -47,13 +46,14 @@ class Settings : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QVersionNumber version READ version) Q_PROPERTY(QVersionNumber version READ version)
Q_PROPERTY(bool anonymousTelemetry READ anonymousTelemetry WRITE setAnonymousTelemetry NOTIFY anonymousTelemetryChanged) Q_PROPERTY(bool anonymousTelemetry READ anonymousTelemetry WRITE setAnonymousTelemetry NOTIFY anonymousTelemetryChanged)
Q_PROPERTY(bool silentStart READ silentStart WRITE setSilentStart NOTIFY silentStartChanged) Q_PROPERTY(bool silentStart READ silentStart WRITE setSilentStart NOTIFY silentStartChanged)
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged)
Q_PROPERTY(bool checkWallpaperVisible READ checkWallpaperVisible WRITE setCheckWallpaperVisible NOTIFY checkWallpaperVisibleChanged)
Q_PROPERTY(bool pauseWallpaperWhenIngame READ pauseWallpaperWhenIngame WRITE setPauseWallpaperWhenIngame NOTIFY pauseWallpaperWhenIngameChanged)
Q_PROPERTY(bool offlineMode READ offlineMode WRITE setOfflineMode NOTIFY offlineModeChanged) Q_PROPERTY(bool offlineMode READ offlineMode WRITE setOfflineMode NOTIFY offlineModeChanged)
Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged) Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged)
Q_PROPERTY(QString gitBuildHash READ gitBuildHash WRITE setGitBuildHash NOTIFY gitBuildHashChanged) Q_PROPERTY(QString gitBuildHash READ gitBuildHash WRITE setGitBuildHash NOTIFY gitBuildHashChanged)
Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged) Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged)
@ -68,11 +68,6 @@ public:
return m_version; return m_version;
} }
bool pauseWallpaperWhenIngame() const
{
return m_pauseWallpaperWhenIngame;
}
bool offlineMode() const bool offlineMode() const
{ {
return m_offlineMode; return m_offlineMode;
@ -118,21 +113,24 @@ public:
return m_language; return m_language;
} }
bool checkWallpaperVisible() const
{
return m_checkWallpaperVisible;
}
signals: signals:
void autostartChanged(bool autostart); void autostartChanged(bool autostart);
void highPriorityStartChanged(bool highPriorityStart); void highPriorityStartChanged(bool highPriorityStart);
void hasWorkshopBannerSeenChanged(bool hasWorkshopBannerSeen); void hasWorkshopBannerSeenChanged(bool hasWorkshopBannerSeen);
void decoderChanged(QString decoder); void decoderChanged(QString decoder);
void setMainWindowVisible(bool visible); void setMainWindowVisible(bool visible);
void pauseWallpaperWhenIngameChanged(bool pauseWallpaperWhenIngame);
void offlineModeChanged(bool offlineMode); void offlineModeChanged(bool offlineMode);
void gitBuildHashChanged(QString gitBuildHash); void gitBuildHashChanged(QString gitBuildHash);
void resetInstalledListmodel(); void resetInstalledListmodel();
void silentStartChanged(bool silentStart); void silentStartChanged(bool silentStart);
void anonymousTelemetryChanged(bool anonymousTelemetry); void anonymousTelemetryChanged(bool anonymousTelemetry);
void languageChanged(QString language); void languageChanged(QString language);
void checkWallpaperVisibleChanged(bool checkWallpaperVisible);
public slots: public slots:
bool writeSingleSettingConfig(QString name, QVariant value); bool writeSingleSettingConfig(QString name, QVariant value);
@ -200,15 +198,6 @@ public slots:
emit decoderChanged(m_decoder); emit decoderChanged(m_decoder);
} }
void setPauseWallpaperWhenIngame(bool pauseWallpaperWhenIngame)
{
if (m_pauseWallpaperWhenIngame == pauseWallpaperWhenIngame)
return;
m_pauseWallpaperWhenIngame = pauseWallpaperWhenIngame;
emit pauseWallpaperWhenIngameChanged(m_pauseWallpaperWhenIngame);
}
void setOfflineMode(bool offlineMode) void setOfflineMode(bool offlineMode)
{ {
if (m_offlineMode == offlineMode) if (m_offlineMode == offlineMode)
@ -254,6 +243,16 @@ public slots:
emit languageChanged(m_language); emit languageChanged(m_language);
} }
void setCheckWallpaperVisible(bool checkWallpaperVisible)
{
if (m_checkWallpaperVisible == checkWallpaperVisible)
return;
writeSingleSettingConfig("checkWallpaperVisible", checkWallpaperVisible);
m_checkWallpaperVisible = checkWallpaperVisible;
emit checkWallpaperVisibleChanged(m_checkWallpaperVisible);
}
private: private:
void restoreDefault(const QString& appConfigLocation, const QString& settingsFileType); void restoreDefault(const QString& appConfigLocation, const QString& settingsFileType);
@ -264,15 +263,15 @@ private:
const shared_ptr<GlobalVariables>& m_globalVariables; const shared_ptr<GlobalVariables>& m_globalVariables;
bool m_pauseWallpaperWhenIngame { false };
bool m_autostart { true }; bool m_autostart { true };
bool m_highPriorityStart { true }; bool m_highPriorityStart { true };
bool m_offlineMode { true }; bool m_offlineMode { true };
bool m_checkWallpaperVisible { true };
QString m_decoder { "" };
QString m_gitBuildHash;
bool m_silentStart { false }; bool m_silentStart { false };
bool m_anonymousTelemetry { true }; bool m_anonymousTelemetry { true };
QString m_gitBuildHash;
QString m_decoder { "" };
QString m_language; QString m_language;
}; };
} }

View File

@ -121,6 +121,12 @@ Item {
} }
} }
onVisualsPausedChanged:{
if(window.checkWallpaperVisible){
webView.visible = visualsPaused
}
}
onIsPlayingChanged: { onIsPlayingChanged: {
if (webView.loadProgress === 100) { if (webView.loadProgress === 100) {
if (isPlaying) { if (isPlaying) {

View File

@ -1,9 +1,9 @@
#include <QApplication> #include <QApplication>
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <QVector>
#include <QtGlobal> #include <QtGlobal>
#include <QtWebEngine> #include <QtWebEngine>
#include <QVector>
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#include "src/winwindow.h" #include "src/winwindow.h"
@ -42,7 +42,7 @@ int main(int argc, char* argv[])
WinWindow window2({ 1 }, "test", "appid", "1", "fill"); WinWindow window2({ 1 }, "test", "appid", "1", "fill");
WinWindow window3({ 2 }, "test", "appid", "1", "fill"); WinWindow window3({ 2 }, "test", "appid", "1", "fill");
//WinWindow window(list, "D:/672870/827874818", "appid", "1", "fill"); WinWindow window({ 0 }, "C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/1954178242", "appid", "1", "fill", true);
#endif #endif
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
LinuxWindow window(QVector<int>{ 0 }, "test", "appid", "1", "fill"); LinuxWindow window(QVector<int>{ 0 }, "test", "appid", "1", "fill");
@ -55,12 +55,12 @@ int main(int argc, char* argv[])
} }
// 6 parameter + 1 OS working directory default paramter // 6 parameter + 1 OS working directory default paramter
if (argumentList.length() != 7) { if (argumentList.length() != 8) {
return -3; return -3;
} }
// AppID, Type // AppID, Type
ScreenPlaySDK sdk(argumentList.at(3),argumentList.at(6)); ScreenPlaySDK sdk(argumentList.at(3), argumentList.at(6));
QString monitorNumbers = argumentList.at(1); QString monitorNumbers = argumentList.at(1);
QStringList activeScreensList = monitorNumbers.split(","); QStringList activeScreensList = monitorNumbers.split(",");
@ -90,15 +90,23 @@ int main(int argc, char* argv[])
} }
} }
if(list.empty()){ if (list.empty()) {
return -4; return -4;
} }
// Args: which monitor, (2) path to project, (3)wallpaper secret to identify the connected socket, (4) volume, (5) fillmode, (6) type
// Args: which monitor, (2) path to project, (3)wallpaper secret to identify the connected socket, (4) volume, (5) fillmode, (6) type, (7)
// See screenplay.h @ScreenPlayWallpaper constructor how the args get created // See screenplay.h @ScreenPlayWallpaper constructor how the args get created
qDebug() << argumentList; qDebug() << argumentList;
bool okParseCheckWallpaperVisible = false;
bool checkWallpaperVisible = argumentList.at(7).toInt(&okParseCheckWallpaperVisible);
if (!okParseCheckWallpaperVisible) {
qFatal("Could not parse checkWallpaperVisible");
return -5;
}
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
WinWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5)); WinWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5), checkWallpaperVisible);
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &WinWindow::destroyThis); QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &WinWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &WinWindow::messageReceived); QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &WinWindow::messageReceived);
#endif #endif

View File

@ -5,9 +5,10 @@ BaseWindow::BaseWindow(QObject* parent)
{ {
} }
BaseWindow::BaseWindow(QString projectFilePath, QVector<int> activeScreensList) BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreensList, const bool checkWallpaperVisible)
: QObject(nullptr) : QObject(nullptr)
, m_activeScreensList(activeScreensList) , m_activeScreensList(activeScreensList)
, m_checkWallpaperVisible(checkWallpaperVisible)
{ {
QApplication::instance()->installEventFilter(this); QApplication::instance()->installEventFilter(this);
qRegisterMetaType<BaseWindow::WallpaperType>(); qRegisterMetaType<BaseWindow::WallpaperType>();

View File

@ -16,7 +16,7 @@ class BaseWindow : public QObject {
public: public:
BaseWindow(QObject* parent = nullptr); BaseWindow(QObject* parent = nullptr);
BaseWindow(QString projectFilePath, QVector<int> activeScreensList); BaseWindow(QString projectFilePath, const QVector<int> activeScreensList, const bool checkWallpaperVisible);
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
@ -24,12 +24,16 @@ public:
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged) Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged) Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged) Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged)
Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged) Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged)
Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged) Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
Q_PROPERTY(bool canFade READ canFade WRITE setCanFade NOTIFY canFadeChanged) Q_PROPERTY(bool canFade READ canFade WRITE setCanFade NOTIFY canFadeChanged)
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
// Save performance by checking if the wallpaper is visible (video wallpaper only for now)
Q_PROPERTY(bool checkWallpaperVisible READ checkWallpaperVisible WRITE setCheckWallpaperVisible NOTIFY checkWallpaperVisibleChanged)
Q_PROPERTY(bool visualsPaused READ visualsPaused WRITE setVisualsPaused NOTIFY visualsPausedChanged)
Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged) Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(float playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) Q_PROPERTY(float playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
@ -123,6 +127,16 @@ public:
return m_activeScreensList; return m_activeScreensList;
} }
bool checkWallpaperVisible() const
{
return m_checkWallpaperVisible;
}
bool visualsPaused() const
{
return m_visualsPaused;
}
signals: signals:
void qmlExit(); void qmlExit();
@ -143,8 +157,12 @@ signals:
void heightChanged(int height); void heightChanged(int height);
void activeScreensListChanged(QVector<int> activeScreensList); void activeScreensListChanged(QVector<int> activeScreensList);
void checkWallpaperVisibleChanged(bool checkWallpaperVisible);
void visualsPausedChanged(bool visualsPaused);
public slots: public slots:
virtual void destroyThis() {} virtual void destroyThis() { }
virtual void setVisible(bool show) { Q_UNUSED(show) } virtual void setVisible(bool show) { Q_UNUSED(show) }
virtual void messageReceived(QString key, QString value) final; virtual void messageReceived(QString key, QString value) final;
@ -307,7 +325,30 @@ public slots:
emit activeScreensListChanged(m_activeScreensList); emit activeScreensListChanged(m_activeScreensList);
} }
void setCheckWallpaperVisible(bool checkWallpaperVisible)
{
if (m_checkWallpaperVisible == checkWallpaperVisible)
return;
m_checkWallpaperVisible = checkWallpaperVisible;
emit checkWallpaperVisibleChanged(m_checkWallpaperVisible);
}
void setVisualsPaused(bool visualsPaused)
{
if (m_visualsPaused == visualsPaused)
return;
qDebug() << "visualsPaused: " << visualsPaused;
m_visualsPaused = visualsPaused;
emit visualsPausedChanged(m_visualsPaused);
}
private: private:
bool m_checkWallpaperVisible { false };
bool m_visualsPaused { false };
bool m_loops { true }; bool m_loops { true };
bool m_isPlaying { true }; bool m_isPlaying { true };
bool m_muted { false }; bool m_muted { false };

View File

@ -62,11 +62,12 @@ LRESULT __stdcall MouseHookCallback(int nCode, WPARAM wParam, LPARAM lParam)
WinWindow::WinWindow( WinWindow::WinWindow(
const QVector<int>& activeScreensList, const QVector<int>& activeScreensList,
QString projectPath, const QString projectPath,
QString id, const QString id,
QString volume, const QString volume,
const QString fillmode) const QString fillmode,
: BaseWindow(projectPath, activeScreensList) const bool checkWallpaperVisible)
: BaseWindow(projectPath, activeScreensList, checkWallpaperVisible)
{ {
m_window.hide(); m_window.hide();
m_windowHandle = reinterpret_cast<HWND>(m_window.winId()); m_windowHandle = reinterpret_cast<HWND>(m_window.winId());
@ -123,7 +124,10 @@ WinWindow::WinWindow(
m_window.hide(); m_window.hide();
QObject::connect(&m_checkForFullScreenWindowTimer, &QTimer::timeout, this, &WinWindow::checkForFullScreenWindow); QObject::connect(&m_checkForFullScreenWindowTimer, &QTimer::timeout, this, &WinWindow::checkForFullScreenWindow);
m_checkForFullScreenWindowTimer.start(30);
if (checkWallpaperVisible) {
m_checkForFullScreenWindowTimer.start(10);
}
} }
void WinWindow::setVisible(bool show) void WinWindow::setVisible(bool show)
@ -292,10 +296,10 @@ void WinWindow::checkForFullScreenWindow()
if ((dwStyle & WS_MAXIMIZE) != 0) { if ((dwStyle & WS_MAXIMIZE) != 0) {
// do stuff // do stuff
setIsPlaying(false); setVisualsPaused(false);
qDebug() << "WS_MAXIMIZE: " << printWindowNameByhWnd(hWnd); qDebug() << "WS_MAXIMIZE: " << printWindowNameByhWnd(hWnd);
} else { } else {
setIsPlaying(true); setVisualsPaused(true);
} }
return; return;
} }
@ -316,16 +320,16 @@ void WinWindow::checkForFullScreenWindow()
if (activeScreensList().length() == 1) { if (activeScreensList().length() == 1) {
// If the window that has WS_MAXIMIZE is at the same monitor as this wallpaper // If the window that has WS_MAXIMIZE is at the same monitor as this wallpaper
if (monitorIndex == activeScreensList().at(0)) { if (monitorIndex == activeScreensList().at(0)) {
qDebug() << "monitorIndex" << monitorIndex; // qDebug() << "monitorIndex" << monitorIndex;
setIsPlaying(false); setVisualsPaused(false);
} else { } else {
setIsPlaying(true); setVisualsPaused(true);
} }
} }
} else { } else {
// qDebug() << "No window found, playing!"; // qDebug() << "No window found, playing!";
setIsPlaying(true); setVisualsPaused(true);
} }
} }
} }

View File

@ -9,9 +9,8 @@
#include <QScreen> #include <QScreen>
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#include <QVector>
#include <QApplication>
#include <QTimer> #include <QTimer>
#include <QVector>
#include <memory> #include <memory>
#include <qt_windows.h> #include <qt_windows.h>
@ -22,9 +21,8 @@
class WinWindow : public BaseWindow { class WinWindow : public BaseWindow {
Q_OBJECT Q_OBJECT
public: public:
explicit WinWindow(const QVector<int>& activeScreensList, QString projectPath, QString id, QString volume, const QString fillmode); explicit WinWindow(const QVector<int>& activeScreensList, const QString projectPath, const QString id, const QString volume, const QString fillmode, const bool checkWallpaperVisible);
public slots: public slots:
void setVisible(bool show) override; void setVisible(bool show) override;