From 9cf60b4d4ad77b51d48832eabaf6d327a79b737a Mon Sep 17 00:00:00 2001 From: APTX Date: Sun, 26 Mar 2017 16:06:13 +0200 Subject: [PATCH] Quick hack to disable screensaver during playback Works on windows only, is located in Player. Should be moved to instance manager to correctly account for multiple instances. --- core/player.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/player.cpp b/core/player.cpp index 6aa7085..8ff8a1c 100644 --- a/core/player.cpp +++ b/core/player.cpp @@ -3,6 +3,10 @@ #include #include +#ifdef Q_OS_WIN +#include +#endif + Q_LOGGING_CATEGORY(playerCategory, "Player") Player::Player(BackendPluginBase *backendPlugin, QObject *parent) @@ -36,7 +40,12 @@ Player::Player(BackendPluginBase *backendPlugin, QObject *parent) Q_CHECK_PTR(m_chapterModel); } -Player::~Player() { qCDebug(playerCategory) << "Destroying player" << this; } +Player::~Player() { + qCDebug(playerCategory) << "Destroying player" << this; +#ifdef Q_OS_WIN + SetThreadExecutionState(ES_CONTINUOUS); +#endif +} BackendInstance *Player::backend() const { return m_backend; } @@ -199,11 +208,18 @@ void Player::rendererReady() { void Player::playStateChanged(PlayerPluginInterface::PlayState state) { auto s = static_cast(state); - // if (currentSource().isEmpty()) s = PlayState::Stopped; if (m_state == s) return; m_state = s; qCDebug(playerCategory) << "Play state changed to" << s; + +#ifdef Q_OS_WIN + if (m_state == PlayState::Playing) + SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED); + else + SetThreadExecutionState(ES_CONTINUOUS); +#endif + emit stateChanged(s); } -- 2.52.0