Windows Disable ScreenSaver Train View

.. previously it was disabled via VLC, but if you're not running
   with video then the screensaver will kick in on Windows.

.. we now disable it via the Windows API too

Fixes #1859
This commit is contained in:
Mark Liversedge
2016-02-26 12:47:10 +00:00
parent 5af36e4e63
commit 9bdac884fa

View File

@@ -64,6 +64,10 @@
#include <QStyleFactory>
#endif
#ifdef WIN32
#include "Windows.h"
#endif
#include <cmath> // isnan and isinf
#include "TrainDB.h"
#include "Library.h"
@@ -1075,9 +1079,13 @@ void TrainSidebar::Start() // when start button is pressed
qDebug() << "start...";
#ifdef WIN32
// disable the screen saver on Windows
SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
#endif
// Stop users from selecting different devices
// media or workouts whilst a workout is in progress
#if !defined GC_VIDEO_NONE
mediaTree->setEnabled(false);
#ifdef GC_HAVE_VLC // RLV currently only support for VLC
@@ -1211,6 +1219,11 @@ void TrainSidebar::Stop(int deviceStatus) // when stop button is pressed
{
if ((status&RT_RUNNING) == 0) return;
// re-enable the screen saver on Windows
#ifdef WIN32
SetThreadExecutionState(ES_CONTINUOUS);
#endif
clearStatusFlags(RT_RUNNING|RT_PAUSED);
// Stop users from selecting different devices