diff --git a/doc/Changelog.md b/doc/Changelog.md index 0a969f64..d2a03fcd 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -5,6 +5,8 @@ Changelog {#changelog} * [202](https://github.com/BlueBrain/Tide/pull/202): Fixed incorrect count of open windows reported at tide/stats HTTP endpoint. +* [201](https://github.com/BlueBrain/Tide/pull/201): + The interface unlocks when the screens are turned off. * [200](https://github.com/BlueBrain/Tide/pull/200): Xml configuration simplification: - replaced screenWidth/Height with displayWidht/Height, which refers diff --git a/tide/core/CMakeLists.txt b/tide/core/CMakeLists.txt index 96d9df4c..657401b3 100644 --- a/tide/core/CMakeLists.txt +++ b/tide/core/CMakeLists.txt @@ -116,6 +116,7 @@ list(APPEND TIDECORE_PUBLIC_HEADERS CommandLineParameters.h CommandLineParser.h Configuration.h + CountdownStatus.h data/Image.h data/QtImage.h data/SVG.h @@ -123,7 +124,6 @@ list(APPEND TIDECORE_PUBLIC_HEADERS data/SVGQtGpuBackend.h data/YUVImage.h geometry.h - InactivityTimer.h log.h network/LocalBarrier.h network/MPIChannel.h @@ -177,12 +177,12 @@ list(APPEND TIDECORE_SOURCES CommandLineParameters.cpp CommandLineParser.cpp Configuration.cpp + CountdownStatus.cpp data/QtImage.cpp data/SVG.cpp data/SVGQtGpuBackend.cpp data/YUVImage.cpp geometry.cpp - InactivityTimer.cpp log.cpp MetaTypeRegistration.cpp network/LocalBarrier.cpp diff --git a/tide/core/CountdownStatus.cpp b/tide/core/CountdownStatus.cpp new file mode 100644 index 00000000..72e5ecd8 --- /dev/null +++ b/tide/core/CountdownStatus.cpp @@ -0,0 +1,56 @@ +/*********************************************************************/ +/* Copyright (c) 2017, EPFL/Blue Brain Project */ +/* Raphael Dumusc */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* 1. Redistributions of source code must retain the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer. */ +/* */ +/* 2. Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials */ +/* provided with the distribution. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ +/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */ +/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ +/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ +/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ +/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */ +/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ +/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ +/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ +/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/* The views and conclusions contained in the software and */ +/* documentation are those of the authors and should not be */ +/* interpreted as representing official policies, either expressed */ +/* or implied, of Ecole polytechnique federale de Lausanne. */ +/*********************************************************************/ + +#include "CountdownStatus.h" + +CountdownStatus::CountdownStatus(const bool active, const uint duration) + : _active{active} + , _duration{duration} +{ +} + +bool CountdownStatus::isActive() const +{ + return _active; +} + +uint CountdownStatus::getDuration() const +{ + return _duration; +} diff --git a/tide/core/CountdownStatus.h b/tide/core/CountdownStatus.h new file mode 100644 index 00000000..4cacd9fc --- /dev/null +++ b/tide/core/CountdownStatus.h @@ -0,0 +1,87 @@ +/*********************************************************************/ +/* Copyright (c) 2017, EPFL/Blue Brain Project */ +/* Raphael Dumusc */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* 1. Redistributions of source code must retain the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer. */ +/* */ +/* 2. Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials */ +/* provided with the distribution. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ +/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */ +/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ +/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ +/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ +/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */ +/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ +/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ +/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ +/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/* The views and conclusions contained in the software and */ +/* documentation are those of the authors and should not be */ +/* interpreted as representing official policies, either expressed */ +/* or implied, of Ecole polytechnique federale de Lausanne. */ +/*********************************************************************/ + +#ifndef COUNTDOWN_STATUS_H +#define COUNTDOWN_STATUS_H + +#include "serialization/includes.h" + +#include + +/** + * The status of the inactivity countdown, to be displayed on the wall. + */ +class CountdownStatus : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(CountdownStatus) + + Q_PROPERTY(bool active READ isActive) + Q_PROPERTY(uint duration READ getDuration) + +public: + /** Default constructor for use on wall processes. */ + CountdownStatus() = default; + + /** Constructor. */ + CountdownStatus(bool active, uint duration); + + /** Check if countdown timer is active. */ + bool isActive() const; + + /** Get the duration of the countdown for transition in qml. */ + uint getDuration() const; + +private: + friend class boost::serialization::access; + + template + void serialize(Archive& ar, const unsigned int) + { + // clang-format off + ar & _active; + ar & _duration; + // clang-format on + } + + bool _active = false; + uint _duration = 0u; +}; + +#endif diff --git a/tide/core/MetaTypeRegistration.cpp b/tide/core/MetaTypeRegistration.cpp index 8d732985..09cc8634 100644 --- a/tide/core/MetaTypeRegistration.cpp +++ b/tide/core/MetaTypeRegistration.cpp @@ -60,6 +60,7 @@ struct MetaTypeRegistration "ContentWindow::WindowState"); qRegisterMetaType( "ContentSynchronizerSharedPtr"); + qRegisterMetaType("CountdownStatusPtr"); qRegisterMetaType("DisplayGroupPtr"); qRegisterMetaType("DisplayGroupConstPtr"); qRegisterMetaType("ImagePtr"); @@ -72,7 +73,6 @@ struct MetaTypeRegistration qRegisterMetaType("TilePtr"); qRegisterMetaType("TileWeakPtr"); qRegisterMetaTypeStreamOperators("QUuid"); - qRegisterMetaType("InactivityTimerPtr"); } }; diff --git a/tide/core/network/MPIHeader.h b/tide/core/network/MPIHeader.h index c9f06274..fc6629c0 100644 --- a/tide/core/network/MPIHeader.h +++ b/tide/core/network/MPIHeader.h @@ -56,7 +56,7 @@ enum class MPIMessageType TIMESTAMP, START_PROCESS, IMAGE, - TIMER, + COUNTDOWN_STATUS, PIXELSTREAM_CLOSE, LOCK }; diff --git a/tide/core/types.h b/tide/core/types.h index e8aef802..44d7afd0 100644 --- a/tide/core/types.h +++ b/tide/core/types.h @@ -108,6 +108,7 @@ class Configuration; class Content; class ContentSynchronizer; class ContentWindow; +class CountdownStatus; class DataProvider; class DataSource; class DisplayGroup; @@ -145,10 +146,10 @@ class WebbrowserContent; typedef boost::shared_ptr ContentPtr; typedef std::shared_ptr ContentSynchronizerSharedPtr; typedef boost::shared_ptr ContentWindowPtr; +typedef boost::shared_ptr CountdownStatusPtr; typedef boost::shared_ptr DisplayGroupPtr; typedef boost::shared_ptr DisplayGroupConstPtr; typedef std::shared_ptr ImagePtr; -typedef boost::shared_ptr InactivityTimerPtr; typedef std::shared_ptr PicturePtr; typedef boost::shared_ptr MarkersPtr; typedef boost::shared_ptr MPIChannelPtr; diff --git a/tide/master/CMakeLists.txt b/tide/master/CMakeLists.txt index d5b886fe..b6e260db 100644 --- a/tide/master/CMakeLists.txt +++ b/tide/master/CMakeLists.txt @@ -25,6 +25,7 @@ list(APPEND TIDEMASTER_PUBLIC_HEADERS control/PixelStreamController.h control/ZoomController.h FileInfoHelper.h + InactivityTimer.h localstreamer/HtmlSelectReplacer.h localstreamer/CommandLineOptions.h localstreamer/PixelStreamerLauncher.h @@ -71,6 +72,7 @@ list(APPEND TIDEMASTER_SOURCES control/LayoutPolicy.cpp control/PixelStreamController.cpp control/ZoomController.cpp + InactivityTimer.cpp localstreamer/HtmlSelectReplacer.cpp localstreamer/CommandLineOptions.cpp localstreamer/PixelStreamerLauncher.cpp diff --git a/tide/core/InactivityTimer.cpp b/tide/master/InactivityTimer.cpp similarity index 70% rename from tide/core/InactivityTimer.cpp rename to tide/master/InactivityTimer.cpp index 912f53bd..28c6c2e3 100644 --- a/tide/core/InactivityTimer.cpp +++ b/tide/master/InactivityTimer.cpp @@ -1,6 +1,7 @@ /*********************************************************************/ /* Copyright (c) 2017, EPFL/Blue Brain Project */ /* Pawel Podhajski */ +/* Raphael Dumusc */ /* All rights reserved. */ /* */ /* Redistribution and use in source and binary forms, with or */ @@ -39,73 +40,62 @@ #include "InactivityTimer.h" +#include "CountdownStatus.h" #include "log.h" namespace { -const int COUNTDOWNTIMER = 15000; // ms +const auto COUNTDOWNTIMER_MS = 15000; +const auto MS_PER_MIN = 60000; } -InactivityTimer::InactivityTimer() +InactivityTimer::InactivityTimer(const uint timeoutInMinutes) { -} + _inactivityTimer.setInterval(timeoutInMinutes * MS_PER_MIN); + _inactivityTimer.setSingleShot(true); + _inactivityTimer.start(); -InactivityTimer::InactivityTimer(const int timeout) - : _timeout(timeout * 60000) // from ms to minute - , _countDownTimer(new QTimer()) - , _inactivityTimer(new QTimer()) -{ - _inactivityTimer->setInterval(_timeout); - _inactivityTimer->setSingleShot(true); - _inactivityTimer->start(); - _countDownTimer->setSingleShot(true); - _countDownTimer->setInterval(COUNTDOWNTIMER); + _countdownTimer.setInterval(COUNTDOWNTIMER_MS); + _countdownTimer.setSingleShot(true); - connect(_inactivityTimer.get(), &QTimer::timeout, [this]() { - if (!_countDownTimer->isActive()) + connect(&_inactivityTimer, &QTimer::timeout, [this]() { + if (!_countdownTimer.isActive()) { - _countdownActive = true; - _countDownTimer->start(); - emit updated(shared_from_this()); + _countdownTimer.start(); + _sendCountdownStatus(); } }); - connect(_countDownTimer.get(), &QTimer::timeout, [this]() { + connect(&_countdownTimer, &QTimer::timeout, [this]() { emit poweroff(); - _countdownActive = false; - emit updated(shared_from_this()); + _sendCountdownStatus(); }); } -int InactivityTimer::getCountdownTimeout() -{ - return COUNTDOWNTIMER; -} - -bool InactivityTimer::isCountdownActive() -{ - return _countdownActive; -} - void InactivityTimer::stop() { - _inactivityTimer->stop(); - if (_countdownActive) + _inactivityTimer.stop(); + if (_countdownTimer.isActive()) { - _countdownActive = false; - _countDownTimer->stop(); - emit updated(shared_from_this()); + _countdownTimer.stop(); + _sendCountdownStatus(); } } void InactivityTimer::restart() { - _inactivityTimer->start(); - if (_countdownActive) + _inactivityTimer.start(); + if (_countdownTimer.isActive()) { print_log(LOG_INFO, LOG_POWER, "Prevented powering off the screens during countdown"); - _countDownTimer->stop(); - _countdownActive = false; - emit updated(shared_from_this()); + _countdownTimer.stop(); + _sendCountdownStatus(); } } + +void InactivityTimer::_sendCountdownStatus() +{ + emit countdownUpdated( + boost::make_shared(_countdownTimer.isActive(), + (uint)_countdownTimer.interval())); +} diff --git a/tide/core/InactivityTimer.h b/tide/master/InactivityTimer.h similarity index 70% rename from tide/core/InactivityTimer.h rename to tide/master/InactivityTimer.h index 7a4be553..32695744 100644 --- a/tide/core/InactivityTimer.h +++ b/tide/master/InactivityTimer.h @@ -1,6 +1,7 @@ /*********************************************************************/ /* Copyright (c) 2017, EPFL/Blue Brain Project */ /* Pawel Podhajski */ +/* Raphael Dumusc */ /* All rights reserved. */ /* */ /* Redistribution and use in source and binary forms, with or */ @@ -40,67 +41,43 @@ #ifndef INACTIVITYTIMER_H #define INACTIVITYTIMER_H -#include "serialization/includes.h" #include "types.h" -#include - #include #include /** - * Inform user about inactivity timeout. + * Detect user inactivity to power off screens after a configurable timeout. */ -class InactivityTimer : public QObject, - public boost::enable_shared_from_this +class InactivityTimer : public QObject { Q_OBJECT Q_DISABLE_COPY(InactivityTimer) public: /** - * Construct a timer which can be used to turn off the displays. - * @param timeout value of the timer in minutes. + * Create a timer which can be used to turn off the displays. + * @param timeoutInMinutes duration of the timeout in minutes. */ - InactivityTimer(int timeout); - - /** Default constructor, creates a read-only timer used on Wall processes */ - InactivityTimer(); - - /** Get the duration of countdown needed for transition in qml */ - Q_INVOKABLE int getCountdownTimeout(); - - /** Check if countdown timer is active */ - Q_INVOKABLE bool isCountdownActive(); + explicit InactivityTimer(uint timeoutInMinutes); - /** Stop the timer */ + /** Stop the timer. */ void stop(); - /** Restart the inactivity timer and interrupt the countdown if active */ + /** Restart the inactivity timer and interrupt the countdown if active. */ void restart(); signals: - /** Emitted when the countdown timer times-out */ - void poweroff(); + /** Emitted when the state of the countdown is modified. */ + void countdownUpdated(CountdownStatusPtr); - /** Emitted when the state of timer is modified */ - void updated(InactivityTimerPtr); + /** Emitted when the countdown timer times-out. */ + void poweroff(); private: - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int) - { - // clang-format off - ar & _countdownActive; - // clang-format on - } - - bool _countdownActive = false; - int _timeout; + QTimer _countdownTimer; + QTimer _inactivityTimer; - std::unique_ptr _countDownTimer; - std::unique_ptr _inactivityTimer; + void _sendCountdownStatus(); }; #endif diff --git a/tide/master/MasterApplication.cpp b/tide/master/MasterApplication.cpp index 2a034133..587bb4a2 100644 --- a/tide/master/MasterApplication.cpp +++ b/tide/master/MasterApplication.cpp @@ -386,10 +386,10 @@ void MasterApplication::_setupMPIConnections() }, Qt::DirectConnection); - connect(_inactivityTimer.get(), &InactivityTimer::updated, + connect(_inactivityTimer.get(), &InactivityTimer::countdownUpdated, _masterToWallChannel.get(), - [this](InactivityTimerPtr timer) { - _masterToWallChannel->sendAsync(timer); + [this](CountdownStatusPtr status) { + _masterToWallChannel->sendAsync(status); }, Qt::DirectConnection); @@ -567,13 +567,19 @@ void MasterApplication::_initRestInterface() _logger.get(), &LoggingUtility::logScreenStateChanged); connect(_planarController.get(), &PlanarController::powerStateChanged, - [this](ScreenState state) { + [this](const ScreenState state) { if (state == ScreenState::ON) _inactivityTimer->restart(); else _inactivityTimer->stop(); }); + connect(_planarController.get(), &PlanarController::powerStateChanged, + [this](const ScreenState state) { + if (state == ScreenState::OFF) + _lock->unlock(); + }); + connect(&appController, &AppController::powerOff, [this]() { if (_planarController->powerOff()) DisplayGroupController(*_displayGroup).hidePanels(); diff --git a/tide/master/MasterApplication.h b/tide/master/MasterApplication.h index d9fdb95a..eb4cfe8a 100644 --- a/tide/master/MasterApplication.h +++ b/tide/master/MasterApplication.h @@ -113,7 +113,7 @@ class MasterApplication : public QApplication ScreenLockPtr _lock; MarkersPtr _markers; OptionsPtr _options; - InactivityTimerPtr _inactivityTimer; + std::unique_ptr _inactivityTimer; std::unique_ptr _masterWindow; std::unique_ptr _offscreenQuickView; diff --git a/tide/master/MasterConfiguration.cpp b/tide/master/MasterConfiguration.cpp index 2be836b0..95eba45d 100644 --- a/tide/master/MasterConfiguration.cpp +++ b/tide/master/MasterConfiguration.cpp @@ -48,7 +48,7 @@ namespace { const int DEFAULT_WEBSERVICE_PORT = 8888; -const int DEFAULT_PLANAR_TIMEOUT = 60; +const int DEFAULT_PLANAR_TIMEOUT_MIN = 60; const QString DEFAULT_URL("http://www.google.com"); const QString DEFAULT_WHITEBOARD_SAVE_FOLDER("/tmp/"); } @@ -57,7 +57,7 @@ MasterConfiguration::MasterConfiguration(const QString& filename) : Configuration(filename) , _webServicePort(DEFAULT_WEBSERVICE_PORT) , _backgroundColor(Qt::black) - , _planarTimeout(DEFAULT_PLANAR_TIMEOUT) + , _planarTimeout(DEFAULT_PLANAR_TIMEOUT_MIN) { loadMasterSettings(); } diff --git a/tide/master/MasterConfiguration.h b/tide/master/MasterConfiguration.h index f1ea502a..1a06b9a6 100644 --- a/tide/master/MasterConfiguration.h +++ b/tide/master/MasterConfiguration.h @@ -119,7 +119,7 @@ class MasterConfiguration : public Configuration QString getPlanarSerialPort() const; /** - * Get the timeout after which the Planar screns should be turned off. + * Get the timeout in minutes after which the screns should be turned off. * @return default value if unspecified. */ int getPlanarTimeout() const; diff --git a/tide/master/network/MasterToWallChannel.cpp b/tide/master/network/MasterToWallChannel.cpp index 23386e05..dccad59e 100644 --- a/tide/master/network/MasterToWallChannel.cpp +++ b/tide/master/network/MasterToWallChannel.cpp @@ -39,7 +39,7 @@ #include "MasterToWallChannel.h" -#include "InactivityTimer.h" +#include "CountdownStatus.h" #include "ScreenLock.h" #include "network/MPIChannel.h" #include "scene/ContentWindow.h" @@ -82,9 +82,9 @@ void MasterToWallChannel::sendAsync(OptionsPtr options) broadcastAsync(options, MPIMessageType::OPTIONS); } -void MasterToWallChannel::sendAsync(InactivityTimerPtr timer) +void MasterToWallChannel::sendAsync(CountdownStatusPtr status) { - broadcastAsync(timer, MPIMessageType::TIMER); + broadcastAsync(status, MPIMessageType::COUNTDOWN_STATUS); } void MasterToWallChannel::sendAsync(ScreenLockPtr lock) diff --git a/tide/master/network/MasterToWallChannel.h b/tide/master/network/MasterToWallChannel.h index cc351035..72b3ca92 100644 --- a/tide/master/network/MasterToWallChannel.h +++ b/tide/master/network/MasterToWallChannel.h @@ -85,10 +85,10 @@ public slots: void sendAsync(OptionsPtr options); /** - * Send the given InactivityTimer to the wall processes. - * @param timer The InactivityTimer to send + * Send the given CountdownStatus to the wall processes. + * @param status The countdownStatus to send */ - void sendAsync(InactivityTimerPtr timer); + void sendAsync(CountdownStatusPtr status); /** * Send the Lock to the wall processes. diff --git a/tide/wall/DisplayGroupRenderer.cpp b/tide/wall/DisplayGroupRenderer.cpp index 5254825a..883a6734 100644 --- a/tide/wall/DisplayGroupRenderer.cpp +++ b/tide/wall/DisplayGroupRenderer.cpp @@ -39,8 +39,8 @@ #include "DisplayGroupRenderer.h" +#include "CountdownStatus.h" #include "DataProvider.h" -#include "InactivityTimer.h" #include "ScreenLock.h" #include "VisibilityHelper.h" #include "WallWindow.h" @@ -72,14 +72,15 @@ DisplayGroupRenderer::DisplayGroupRenderer(WallWindow& parentWindow, , _markers(Markers::create()) , _options{Options::create()} , _lock(ScreenLock::create()) - , _timer{new InactivityTimer} + , _countdownStatus{new CountdownStatus} , _screenRect{screenRect} , _view{view} { - _engine.rootContext()->setContextProperty("markers", _markers.get()); - _engine.rootContext()->setContextProperty("options", _options.get()); - _engine.rootContext()->setContextProperty("timer", _timer.get()); - _engine.rootContext()->setContextProperty("lock", _lock.get()); + auto context = _engine.rootContext(); + context->setContextProperty("markers", _markers.get()); + context->setContextProperty("options", _options.get()); + context->setContextProperty("countdownStatus", _countdownStatus.get()); + context->setContextProperty("lock", _lock.get()); _createDisplayGroupQmlItem(*parentWindow.rootObject()); _displayGroupItem->setPosition(-screenRect.topLeft()); _setBackground(_options->getBackgroundContent()); @@ -166,10 +167,10 @@ void DisplayGroupRenderer::setScreenLock(ScreenLockPtr lock) _lock = lock; } -void DisplayGroupRenderer::setTimer(InactivityTimerPtr timer) +void DisplayGroupRenderer::setCountdownStatus(CountdownStatusPtr status) { - _engine.rootContext()->setContextProperty("timer", timer.get()); - _timer = timer; // Retain the new InactivityTimer + _engine.rootContext()->setContextProperty("countdownStatus", status.get()); + _countdownStatus = std::move(status); } void DisplayGroupRenderer::updateRenderedFrames() diff --git a/tide/wall/DisplayGroupRenderer.h b/tide/wall/DisplayGroupRenderer.h index 70cce51a..372b9d82 100644 --- a/tide/wall/DisplayGroupRenderer.h +++ b/tide/wall/DisplayGroupRenderer.h @@ -82,8 +82,8 @@ class DisplayGroupRenderer : public QObject /** Set the ScreenLock replacing the previous one. */ void setScreenLock(ScreenLockPtr lock); - /** Set timer used to notify about inactivity timeout. */ - void setTimer(InactivityTimerPtr timer); + /** Set statis used to notify about inactivity timeout. */ + void setCountdownStatus(CountdownStatusPtr status); /** @return true if the renderer requires a redraw. */ bool needRedraw() const; @@ -99,7 +99,7 @@ public slots: MarkersPtr _markers; OptionsPtr _options; ScreenLockPtr _lock; - InactivityTimerPtr _timer; + CountdownStatusPtr _countdownStatus; const QRect _screenRect; const deflect::View _view; diff --git a/tide/wall/RenderController.cpp b/tide/wall/RenderController.cpp index 01f5962d..67443922 100644 --- a/tide/wall/RenderController.cpp +++ b/tide/wall/RenderController.cpp @@ -39,9 +39,9 @@ #include "RenderController.h" +#include "CountdownStatus.h" #include "DataProvider.h" #include "DisplayGroupRenderer.h" -#include "InactivityTimer.h" #include "ScreenLock.h" #include "WallWindow.h" #include "network/WallToWallChannel.h" @@ -55,8 +55,8 @@ RenderController::RenderController(std::vector windows, : _windows{std::move(windows)} , _provider{provider} , _wallChannel{wallChannel} + , _syncCountdownStatus{boost::make_shared()} , _syncDisplayGroup{boost::make_shared(QSize())} - , _syncInactivityTimer{boost::make_shared()} , _syncLock(ScreenLock::create()) , _syncOptions{Options::create()} { @@ -69,9 +69,9 @@ RenderController::RenderController(std::vector windows, for (auto window : _windows) window->setScreenLock(lock); }); - _syncInactivityTimer.setCallback([this](InactivityTimerPtr timer) { + _syncCountdownStatus.setCallback([this](CountdownStatusPtr status) { for (auto window : _windows) - window->setInactivityTimer(timer); + window->setCountdownStatus(status); }); _syncMarkers.setCallback([this](MarkersPtr markers) { for (auto window : _windows) @@ -181,15 +181,15 @@ bool RenderController::_syncAndRenderWindows(const bool grab) return _wallChannel.allReady(!_needRedraw); } -void RenderController::updateDisplayGroup(DisplayGroupPtr displayGroup) +void RenderController::updateCountdownStatus(CountdownStatusPtr status) { - _syncDisplayGroup.update(displayGroup); + _syncCountdownStatus.update(status); requestRender(); } -void RenderController::updateInactivityTimer(InactivityTimerPtr timer) +void RenderController::updateDisplayGroup(DisplayGroupPtr displayGroup) { - _syncInactivityTimer.update(timer); + _syncDisplayGroup.update(displayGroup); requestRender(); } @@ -225,10 +225,10 @@ void RenderController::updateQuit() void RenderController::_synchronizeObjects(const SyncFunction& versionCheckFunc) { - _syncScreenshot.sync(versionCheckFunc); + _syncCountdownStatus.sync(versionCheckFunc); _syncDisplayGroup.sync(versionCheckFunc); + _syncLock.sync(versionCheckFunc); _syncMarkers.sync(versionCheckFunc); _syncOptions.sync(versionCheckFunc); - _syncInactivityTimer.sync(versionCheckFunc); - _syncLock.sync(versionCheckFunc); + _syncScreenshot.sync(versionCheckFunc); } diff --git a/tide/wall/RenderController.h b/tide/wall/RenderController.h index 534608ad..ca4ed332 100644 --- a/tide/wall/RenderController.h +++ b/tide/wall/RenderController.h @@ -63,8 +63,8 @@ class RenderController : public QObject public slots: void requestRender(); + void updateCountdownStatus(CountdownStatusPtr status); void updateDisplayGroup(DisplayGroupPtr displayGroup); - void updateInactivityTimer(InactivityTimerPtr timer); void updateLock(ScreenLockPtr lock); void updateMarkers(MarkersPtr markers); void updateOptions(OptionsPtr options); @@ -80,8 +80,8 @@ public slots: WallToWallChannel& _wallChannel; std::unique_ptr _swapSynchronizer; + SwapSyncObject _syncCountdownStatus; SwapSyncObject _syncDisplayGroup; - SwapSyncObject _syncInactivityTimer; SwapSyncObject _syncLock; SwapSyncObject _syncMarkers; SwapSyncObject _syncOptions; diff --git a/tide/wall/WallApplication.cpp b/tide/wall/WallApplication.cpp index e8ed3e4a..08d0196e 100644 --- a/tide/wall/WallApplication.cpp +++ b/tide/wall/WallApplication.cpp @@ -147,9 +147,9 @@ void WallApplication::_initMPIConnection(MPIChannelPtr worldChannel) connect(_fromMasterChannel.get(), SIGNAL(received(OptionsPtr)), _renderController.get(), SLOT(updateOptions(OptionsPtr))); - connect(_fromMasterChannel.get(), SIGNAL(received(InactivityTimerPtr)), + connect(_fromMasterChannel.get(), SIGNAL(received(CountdownStatusPtr)), _renderController.get(), - SLOT(updateInactivityTimer(InactivityTimerPtr))); + SLOT(updateCountdownStatus(CountdownStatusPtr))); connect(_fromMasterChannel.get(), SIGNAL(received(ScreenLockPtr)), _renderController.get(), SLOT(updateLock(ScreenLockPtr))); diff --git a/tide/wall/WallWindow.cpp b/tide/wall/WallWindow.cpp index c43e58b3..870ff5c2 100644 --- a/tide/wall/WallWindow.cpp +++ b/tide/wall/WallWindow.cpp @@ -39,9 +39,9 @@ #include "WallWindow.h" +#include "CountdownStatus.h" #include "DataProvider.h" #include "DisplayGroupRenderer.h" -#include "InactivityTimer.h" #include "SwapSynchronizer.h" #include "TestPattern.h" #include "WallConfiguration.h" @@ -212,9 +212,9 @@ void WallWindow::setScreenLock(ScreenLockPtr lock) _displayGroupRenderer->setScreenLock(lock); } -void WallWindow::setInactivityTimer(InactivityTimerPtr timer) +void WallWindow::setCountdownStatus(CountdownStatusPtr status) { - _displayGroupRenderer->setTimer(timer); + _displayGroupRenderer->setCountdownStatus(status); } void WallWindow::setMarkers(MarkersPtr markers) diff --git a/tide/wall/WallWindow.h b/tide/wall/WallWindow.h index 429b0b80..cf5a99f7 100644 --- a/tide/wall/WallWindow.h +++ b/tide/wall/WallWindow.h @@ -91,8 +91,8 @@ class WallWindow : public QQuickWindow /** Set new screen lock. */ void setScreenLock(ScreenLockPtr lock); - /** Set new inactivity timer. */ - void setInactivityTimer(InactivityTimerPtr timer); + /** Set new countdown status. */ + void setCountdownStatus(CountdownStatusPtr status); /** Set new touchpoint's markers. */ void setMarkers(MarkersPtr markers); diff --git a/tide/wall/network/WallFromMasterChannel.cpp b/tide/wall/network/WallFromMasterChannel.cpp index 3b1e3d2e..88524360 100644 --- a/tide/wall/network/WallFromMasterChannel.cpp +++ b/tide/wall/network/WallFromMasterChannel.cpp @@ -39,7 +39,7 @@ #include "WallFromMasterChannel.h" -#include "InactivityTimer.h" +#include "CountdownStatus.h" #include "ScreenLock.h" #include "network/MPIChannel.h" #include "scene/ContentWindow.h" @@ -86,8 +86,8 @@ void WallFromMasterChannel::receiveMessage() case MPIMessageType::MARKERS: emit received(receiveQObjectBroadcast(mh.size)); break; - case MPIMessageType::TIMER: - emit received(receiveQObjectBroadcast(mh.size)); + case MPIMessageType::COUNTDOWN_STATUS: + emit received(receiveQObjectBroadcast(mh.size)); break; case MPIMessageType::PIXELSTREAM: #if BOOST_VERSION >= 106000 diff --git a/tide/wall/network/WallFromMasterChannel.h b/tide/wall/network/WallFromMasterChannel.h index e89a8ec0..fc02d4dd 100644 --- a/tide/wall/network/WallFromMasterChannel.h +++ b/tide/wall/network/WallFromMasterChannel.h @@ -88,11 +88,11 @@ public slots: */ void received(OptionsPtr options); - /** Emitted when a new InactivityTimer was received + /** Emitted when a new CountdownStatus was received * @see receiveMessage() - * @param timer The timer that was received + * @param status The status that was received */ - void received(InactivityTimerPtr timer); + void received(CountdownStatusPtr status); /** * Emitted when new ScreenLock was recieved diff --git a/tide/wall/resources/PowerOffCountdown.qml b/tide/wall/resources/PowerOffCountdown.qml index b6770cbd..b7590b53 100644 --- a/tide/wall/resources/PowerOffCountdown.qml +++ b/tide/wall/resources/PowerOffCountdown.qml @@ -12,7 +12,7 @@ Item { states: [ State { name: "hidden" - when: !timer.isCountdownActive() + when: !countdownStatus.active PropertyChanges { target: countdown opacity: 0.0 @@ -20,7 +20,7 @@ Item { }, State { name: "visible" - when: timer.isCountdownActive() + when: countdownStatus.active PropertyChanges { target: countdown opacity: 0.9 @@ -35,7 +35,7 @@ Item { NumberAnimation { properties: "opacity" easing.type: Easing.OutBack - duration: timer.getCountdownTimeout() + duration: countdownStatus.duration } }, Transition { @@ -51,7 +51,7 @@ Item { Text { text: "Touch to prevent sleep!" - visible: timer.isCountdownActive() ? 1 : 0 + visible: countdownStatus.active font.pointSize: displaygroup.height * Style.countdownTextScale anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter