diff --git a/Userland/Libraries/LibCore/Timer.cpp b/Userland/Libraries/LibCore/Timer.cpp index cf5a35ac17e..c58f6d2bc5e 100644 --- a/Userland/Libraries/LibCore/Timer.cpp +++ b/Userland/Libraries/LibCore/Timer.cpp @@ -58,6 +58,14 @@ void Timer::stop() m_active = false; } +void Timer::set_active(bool active) +{ + if (active) + start(); + else + stop(); +} + void Timer::timer_event(TimerEvent&) { if (m_single_shot) diff --git a/Userland/Libraries/LibCore/Timer.h b/Userland/Libraries/LibCore/Timer.h index 94c1ac4c1cf..2edadc6af17 100644 --- a/Userland/Libraries/LibCore/Timer.h +++ b/Userland/Libraries/LibCore/Timer.h @@ -37,6 +37,8 @@ public: void restart(int interval_ms); void stop(); + void set_active(bool); + bool is_active() const { return m_active; } int interval() const { return m_interval_ms; } void set_interval(int interval_ms)