mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-16 23:29:58 +00:00
add time source
This commit is contained in:
@ -358,7 +358,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter[key] = _units == KSysGuard::UnitCelsius ? AWKeysAggregator::FormatterType::Temperature
|
||||
: AWKeysAggregator::FormatterType::Integer;
|
||||
}
|
||||
} else if (_source == "Local") {
|
||||
} else if (_source == "extsysmon/time/now") {
|
||||
// time
|
||||
m_map.insert(_source, "time");
|
||||
m_formatter["time"] = AWKeysAggregator::FormatterType::Time;
|
||||
@ -410,7 +410,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
||||
}
|
||||
|
||||
QStringList foundKeys = keysFromSource(_source);
|
||||
auto foundKeys = keysFromSource(_source);
|
||||
|
||||
// rewrite formatters for custom ones
|
||||
QStringList customFormattersKeys;
|
||||
@ -425,7 +425,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
|
||||
// drop key from dictionary if no one user requested key required it
|
||||
qCInfo(LOG_AW) << "Looking for keys" << foundKeys << "in" << _keys;
|
||||
bool required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](const QString &key) {
|
||||
auto required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](const QString &key) {
|
||||
return _keys.contains(key);
|
||||
});
|
||||
if (!required) {
|
||||
|
@ -373,7 +373,6 @@ void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo
|
||||
}
|
||||
|
||||
m_mutex.lock();
|
||||
// HACK workaround for time values which are stored in the different path
|
||||
std::for_each(tags.cbegin(), tags.cend(), [this, &_data](const QString &tag) { m_values[tag] = _data.payload; });
|
||||
m_mutex.unlock();
|
||||
}
|
||||
|
@ -113,26 +113,26 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
|
||||
output = QString("%1").arg(temperature(_data.toDouble()), 5, 'f', 1);
|
||||
break;
|
||||
case FormatterType::Time:
|
||||
output = _data.toDateTime().toString();
|
||||
output = QDateTime::fromSecsSinceEpoch(_data.toLongLong()).toString();
|
||||
break;
|
||||
case FormatterType::TimeCustom:
|
||||
output = m_customTime;
|
||||
[&output, loc, this](const QDateTime &dt) {
|
||||
for (auto &key : m_timeKeys)
|
||||
output.replace(QString("$%1").arg(key), loc.toString(dt, key));
|
||||
}(_data.toDateTime());
|
||||
}(QDateTime::fromSecsSinceEpoch(_data.toLongLong()));
|
||||
break;
|
||||
case FormatterType::TimeISO:
|
||||
output = _data.toDateTime().toString(Qt::ISODate);
|
||||
output = QDateTime::fromSecsSinceEpoch(_data.toLongLong()).toString(Qt::ISODate);
|
||||
break;
|
||||
case FormatterType::TimeLong:
|
||||
output = loc.toString(_data.toDateTime(), QLocale::LongFormat);
|
||||
output = loc.toString(QDateTime::fromSecsSinceEpoch(_data.toLongLong()), QLocale::LongFormat);
|
||||
break;
|
||||
case FormatterType::TimeShort:
|
||||
output = loc.toString(_data.toDateTime(), QLocale::ShortFormat);
|
||||
output = loc.toString(QDateTime::fromSecsSinceEpoch(_data.toLongLong()), QLocale::ShortFormat);
|
||||
break;
|
||||
case FormatterType::Timestamp:
|
||||
output = QString("%1").arg(_data.toDateTime().toMSecsSinceEpoch() / 1000.0, 10, 'f', 0);
|
||||
output = _data.toString();
|
||||
break;
|
||||
case FormatterType::Uptime:
|
||||
case FormatterType::UptimeCustom:
|
||||
|
Reference in New Issue
Block a user