Files
z-bar-qt/Plugins/ZShell/Services/tickingservice.cpp
T
zach 5618ba9e6b
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 9s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Successful in 32s
Rust / build (pull_request) Successful in 52s
Python / verify (pull_request) Successful in 1m45s
Rust / fmt (pull_request) Successful in 33s
Rust / clippy (pull_request) Successful in 58s
fix: fix nvidia update interval on config change + more robust read path for generic
2026-09-28 12:32:36 +02:00

55 lines
1.1 KiB
C++

#include "tickingservice.hpp"
#include "config/dashboard.hpp"
#include "config/rootnodes.hpp"
namespace ZShell::services {
TickingService::TickingService(QObject* parent)
: Service(parent), m_timer(new QTimer(this)) {
m_timer->setSingleShot(false);
QObject::connect(m_timer, &QTimer::timeout, this, [this] {
tick();
updateTriggered();
});
auto* dash = ZShell::config::ConfigSingleton::instance()->dashboard();
applyInterval(dash->resourceUpdateInterval());
QObject::connect(
dash,
&ZShell::config::Dashboard::resourceUpdateIntervalChanged,
this,
[this, dash] { applyInterval(dash->resourceUpdateInterval()); });
}
int TickingService::updateInterval() const {
return m_interval;
}
void TickingService::start() {
m_running = true;
if (m_interval > 0) {
m_timer->start(m_interval);
}
tick();
}
void TickingService::stop() {
m_running = false;
m_timer->stop();
onStopped();
}
void TickingService::applyInterval(int ms) {
if (ms <= 0 || ms == m_interval) {
return;
}
m_interval = ms;
if (m_running) {
m_timer->start(m_interval);
}
Q_EMIT updateIntervalChanged();
}
} // namespace ZShell::services