#ifndef ENERGYSAVER_H #define ENERGYSAVER_H #include #include /** * @brief Class handling energy saving options. * * Shut down device if no mouse input is detected and music player * has not been active or a certain time interval. * * @todo For now this does only work for Lena's RasPi, where the * shutdown script is positioned in a ceratin hardcoded path. * Enable/disable energy saving option, timeout and path of * shutdown script via config */ class EnergySaver : public QObject { Q_OBJECT protected: explicit EnergySaver(QObject *parent = nullptr) : QObject(parent) {}; public: /** * @brief Create instance if necessary and set timeout interval. * @param interval Timer interval in seconds * @see EnergySaver::instance */ static void init(int interval); /** * @brief Implements the singleton pattern. * @return Instance * * If no instance has been created yet, create new instance. */ static EnergySaver *instance(); public slots: /** * @brief Restart shutdown timer, e.g. because of music player activiti */ void restartTimer(); private: /** * @brief Initialize and connect timer. * @param interval Timeout interval in millisecond. */ void initTimer(int interval); QTimer mTimer; private slots: /** * @brief Behavior on timeout: shut down RaspberryPi. */ void onTimeout(); }; #endif // ENERGYSAVER_H