#include "common/NetworkTimer.hpp" #include "common/NetworkWorker.hpp" #include #include namespace chatterino { void NetworkTimer::start() { if (this->timeoutMS_ <= 0) { return; } this->timer_ = new QTimer; this->timer_->start(this->timeoutMS_); QObject::connect(this->timer_, &QTimer::timeout, [timer = this->timer_] { timer->deleteLater(); // }); this->started_ = true; } bool NetworkTimer::isStarted() const { return this->started_; } void NetworkTimer::onTimeout(NetworkWorker *worker, std::function cb) const { assert(this->timer_ != nullptr); assert(worker != nullptr); QObject::connect(this->timer_, &QTimer::timeout, worker, cb); } } // namespace chatterino