mirror of
https://github.com/akuker/RASCSI.git
synced 2024-05-28 09:41:33 +00:00
52e4a92aec
* Bump black from 22.8.0 to 24.3.0 in /python/web Bumps [black](https://github.com/psf/black) from 22.8.0 to 24.3.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/22.8.0...24.3.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * Github CI: Backend web test runner use python 3.9.19 * Reformat python sources with black * Docker: Bump to python 3.9-slim image for pytest * Bump pytest version to 8.1.1 * Bump more library versions, and freeze them --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Daniel Markstedt <daniel@mindani.net>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""Module providing the menu screensaver class"""
|
|
|
|
from abc import abstractmethod
|
|
from menu.timer import Timer
|
|
|
|
|
|
class ScreenSaver:
|
|
"""Class implementing the menu screensaver"""
|
|
|
|
def __init__(self, activation_delay, menu_renderer):
|
|
self.enabled = False
|
|
self.menu_renderer = menu_renderer
|
|
self.screensaver_activation_delay = activation_delay
|
|
self.timer_flag = Timer(self.screensaver_activation_delay)
|
|
|
|
def draw(self):
|
|
"""Draws the screen saver in a non-blocking way if enabled."""
|
|
if self.enabled is True:
|
|
self.draw_screensaver()
|
|
|
|
@abstractmethod
|
|
def draw_screensaver(self):
|
|
"""Draws the screen saver. Must be implemented in subclasses."""
|
|
|
|
def check_timer(self):
|
|
"""Checks if the screen saver should be enabled given the configured
|
|
activation delay."""
|
|
self.timer_flag.check_timer()
|
|
self.enabled = self.timer_flag.enabled
|
|
|
|
def reset_timer(self):
|
|
"""Resets the screen saver timer if an activitiy happend."""
|
|
self.timer_flag.reset_timer()
|
|
self.enabled = self.timer_flag.enabled
|