Add Suspend/Resume support (#1535)

* Add Suspend/Resume support

* Support Suspend/Resume/Restart via API, UI and Systray

* Support screen lock/unlock scenario

* Handle idle scenario

* Align with fix for #1368

* Update Windows build

* Refactor SuspendHandler to maintain state

* Do not start BG-Effect, if system goes into suspend mode

* Correct Idle and Resume interaction
This commit is contained in:
LordGrey
2022-12-22 12:40:39 +01:00
committed by GitHub
parent 2217135336
commit 1189f86c1a
32 changed files with 994 additions and 67 deletions

View File

@@ -75,6 +75,8 @@ Hyperion::Hyperion(quint8 instance, bool readonlyMode)
#endif
, _readOnlyMode(readonlyMode)
{
qRegisterMetaType<ComponentList>("ComponentList");
QString subComponent = "I"+QString::number(instance);
this->setProperty("instance", (QString) subComponent);
@@ -117,8 +119,9 @@ void Hyperion::start()
connect(_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::handleSourceAvailability);
connect(_muxer, &PriorityMuxer::visibleComponentChanged, this, &Hyperion::handleVisibleComponentChanged);
// listens for ComponentRegister changes of COMP_ALL to perform core enable/disable actions
// connect(&_componentRegister, &ComponentRegister::updatedComponentState, this, &Hyperion::updatedComponentState);
// listen for suspend/resume, idle requests to perform core activation/deactivation actions
connect(this, &Hyperion::suspendRequest, this, &Hyperion::setSuspend);
connect(this, &Hyperion::idleRequest, this, &Hyperion::setIdle);
// listen for settings updates of this instance (LEDS & COLOR)
connect(_settingsManager, &SettingsManager::settingsChanged, this, &Hyperion::handleSettingsUpdate);
@@ -377,6 +380,20 @@ int Hyperion::isComponentEnabled(hyperion::Components comp) const
return _componentRegister->isComponentEnabled(comp);
}
void Hyperion::setSuspend(bool isSuspend)
{
bool enable = !isSuspend;
emit compStateChangeRequestAll(enable);
}
void Hyperion::setIdle(bool isIdle)
{
clear(-1);
bool enable = !isIdle;
emit compStateChangeRequestAll(enable, {hyperion::COMP_LEDDEVICE, hyperion::COMP_SMOOTHING} );
}
void Hyperion::registerInput(int priority, hyperion::Components component, const QString& origin, const QString& owner, unsigned smooth_cfg)
{
_muxer->registerInput(priority, component, origin, owner, smooth_cfg);