mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2026-01-29 12:39:46 +00:00
fix: check if subscription optimisation is enabled explicitly
Previous implementation has used implicit logic with empty keys arrays, which might lead to some errors in processing
This commit is contained in:
@@ -65,7 +65,7 @@ QStringList AWDataEngineMapper::keysFromSource(const QString &_source) const
|
|||||||
// HACK units required to define should the value be calculated as temperature
|
// HACK units required to define should the value be calculated as temperature
|
||||||
// or fan data
|
// or fan data
|
||||||
QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSysGuard::Unit _units,
|
QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSysGuard::Unit _units,
|
||||||
const QStringList &_keys)
|
const QStringList &_keys, const bool _disconnectUnused)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
|||||||
|
|
||||||
// check if keys were actually requested
|
// check if keys were actually requested
|
||||||
qCInfo(LOG_AW) << "Looking for keys" << keys << "in" << _keys;
|
qCInfo(LOG_AW) << "Looking for keys" << keys << "in" << _keys;
|
||||||
auto required = _keys.isEmpty()
|
auto required = !_disconnectUnused
|
||||||
|| std::any_of(keys.cbegin(), keys.cend(), [&_keys](auto &key) { return _keys.contains(key); });
|
|| std::any_of(keys.cbegin(), keys.cend(), [&_keys](auto &key) { return _keys.contains(key); });
|
||||||
if (!required)
|
if (!required)
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ public:
|
|||||||
[[nodiscard]] AWPluginFormaterInterface *formatter(const QString &_key) const;
|
[[nodiscard]] AWPluginFormaterInterface *formatter(const QString &_key) const;
|
||||||
[[nodiscard]] QStringList keysFromSource(const QString &_source) const;
|
[[nodiscard]] QStringList keysFromSource(const QString &_source) const;
|
||||||
// set methods
|
// set methods
|
||||||
QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys);
|
QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys,
|
||||||
|
const bool _disconnectUnused);
|
||||||
void setDevices(const AWPluginMatcherSettings &_settings);
|
void setDevices(const AWPluginMatcherSettings &_settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -206,9 +206,8 @@ void AWKeys::reinitKeys(const QStringList &_currentKeys)
|
|||||||
barKeys.append(item->usedKeys());
|
barKeys.append(item->usedKeys());
|
||||||
}
|
}
|
||||||
// get required keys
|
// get required keys
|
||||||
m_requiredKeys = m_optimize ? AWKeyCache::getRequiredKeys(m_foundKeys, barKeys, m_tooltipParams,
|
m_requiredKeys = AWKeyCache::getRequiredKeys(m_foundKeys, barKeys, m_tooltipParams,
|
||||||
m_keyOperator->requiredUserKeys(), _currentKeys)
|
m_keyOperator->requiredUserKeys(), _currentKeys);
|
||||||
: QStringList();
|
|
||||||
|
|
||||||
// set key data to m_aggregator
|
// set key data to m_aggregator
|
||||||
m_aggregator->setDevices(m_keyOperator->devices());
|
m_aggregator->setDevices(m_keyOperator->devices());
|
||||||
@@ -317,7 +316,7 @@ void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo
|
|||||||
// first list init
|
// first list init
|
||||||
auto tags = m_aggregator->keysFromSource(_source);
|
auto tags = m_aggregator->keysFromSource(_source);
|
||||||
if (tags.isEmpty())
|
if (tags.isEmpty())
|
||||||
tags = m_aggregator->registerSource(_source, _sensor.unit, m_requiredKeys);
|
tags = m_aggregator->registerSource(_source, _sensor.unit, m_requiredKeys, m_optimize);
|
||||||
|
|
||||||
// update data or drop source if there are no matches and exit
|
// update data or drop source if there are no matches and exit
|
||||||
if (tags.isEmpty()) {
|
if (tags.isEmpty()) {
|
||||||
|
|||||||
@@ -151,9 +151,9 @@ void AWKeysAggregator::setTranslate(const bool _translate)
|
|||||||
|
|
||||||
|
|
||||||
QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit _units,
|
QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit _units,
|
||||||
const QStringList &_keys)
|
const QStringList &_keys, const bool _disconnectUnused)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
||||||
|
|
||||||
return m_mapper->registerSource(_source, _units, _keys);
|
return m_mapper->registerSource(_source, _units, _keys, _disconnectUnused);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ public:
|
|||||||
void setTranslate(bool _translate);
|
void setTranslate(bool _translate);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys);
|
QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys,
|
||||||
|
const bool _disconnectUnused);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AWPluginFormatSettings m_settings;
|
AWPluginFormatSettings m_settings;
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ QVariant SystemInfoSource::sendDBusRequest(const QString &_destination, const QS
|
|||||||
|
|
||||||
auto response = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT);
|
auto response = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT);
|
||||||
|
|
||||||
if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) {
|
if (response.type() != QDBusMessage::ReplyMessage || response.arguments().isEmpty()) {
|
||||||
qCWarning(LOG_ESS) << "Error message" << response.errorMessage();
|
qCWarning(LOG_ESS) << "Error" << response.errorName() << "with message" << response.errorMessage();
|
||||||
return {};
|
return {};
|
||||||
} else {
|
} else {
|
||||||
return response.arguments().first();
|
return response.arguments().first();
|
||||||
|
|||||||
Reference in New Issue
Block a user