From 1f1b939af49cdc8b2d85ef3792adf58c58a19427 Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Wed, 4 Feb 2026 13:09:04 +0200 Subject: [PATCH] fetch snapshot data on subsrciption --- .../plugin/awdataengineaggregator.cpp | 24 +++++++++++++++---- .../plugin/awdataengineaggregator.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.cpp b/sources/awesome-widget/plugin/awdataengineaggregator.cpp index 5665f07..7176dee 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataengineaggregator.cpp @@ -63,7 +63,7 @@ void AWDataEngineAggregator::connectSources() auto keys = m_sensors.keys(); auto newKeys = QSet(keys.cbegin(), keys.cend()) - m_subscribed; - m_interface->subscribe(newKeys.values()).waitForFinished(); + subscribeSources(newKeys.values()); m_subscribed.unite(newKeys); } @@ -106,6 +106,19 @@ void AWDataEngineAggregator::registerClient(QObject *_client) } +void AWDataEngineAggregator::subscribeSources(const QStringList &_sources) +{ + qCDebug(LOG_AW) << "Subscribe on sources" << _sources; + + // subscribe + m_interface->subscribe(_sources).waitForFinished(); + // get data snapshot + auto data = m_interface->sensorData(_sources); + data.waitForFinished(); + updateData(data); +} + + void AWDataEngineAggregator::unregisterClient(QObject *_client) { qCDebug(LOG_AW) << "Unregister client" << _client; @@ -159,15 +172,16 @@ void AWDataEngineAggregator::sensorAdded(const QString &_sensor) if (!isValidSensor(info)) return; + // notify about new device + emit(deviceAdded(_sensor)); + + // process connection m_sensors[_sensor] = info; dropSource(_sensor); // force reconnect if (!m_subscribed.contains(_sensor)) { - m_interface->subscribe({_sensor}).waitForFinished(); + subscribeSources({_sensor}); m_subscribed.insert(_sensor); } - - // notify about new device - emit(deviceAdded(_sensor)); } diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.h b/sources/awesome-widget/plugin/awdataengineaggregator.h index 0a0eeb9..deedffd 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.h +++ b/sources/awesome-widget/plugin/awdataengineaggregator.h @@ -54,6 +54,7 @@ public: [[nodiscard]] static bool isValidSensor(const KSysGuard::SensorInfo &_sensor); void loadSources(); void registerClient(QObject *_client); + void subscribeSources(const QStringList &_sources); void unregisterClient(QObject *_client); signals: