Commit 00dda874 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Add an updateRateLimit property to SensorFaceController

Mostly as a convenience to store the value so each face does not need to
reimplement all this. It should be used to set the updateRateLimit value
of Sensor/SensorDataModel.
parent 2e0c9de4
......@@ -558,6 +558,23 @@ void SensorFaceController::setLowPrioritySensorIds(const QJsonArray &lowPriority
});
}
int SensorFaceController::updateRateLimit() const
{
return d->appearanceGroup.readEntry<int>(QStringLiteral("updateRateLimit"), 0);
}
void SensorFaceController::setUpdateRateLimit(int limit)
{
if (limit == updateRateLimit()) {
return;
}
d->appearanceGroup.writeEntry("updateRateLimit", limit);
d->syncTimer->start();
Q_EMIT updateRateLimitChanged();
}
// from face config, immutable by the user
QString SensorFaceController::name() const
{
......@@ -782,6 +799,7 @@ void SensorFaceController::reloadConfig()
Q_EMIT titleChanged();
Q_EMIT sensorColorsChanged();
Q_EMIT showTitleChanged();
Q_EMIT updateRateLimitChanged();
}
void SensorFaceController::loadPreset(const QString &preset)
......
......@@ -162,6 +162,10 @@ class SENSORFACES_EXPORT SensorFaceController : public QObject
* The properties of the preset can be accessed via the `config` role.
*/
Q_PROPERTY(QAbstractItemModel *availablePresetsModel READ availablePresetsModel CONSTANT)
/**
* The minimum time that needs to elapse, in milliseconds, between updates of the face.
*/
Q_PROPERTY(int updateRateLimit READ updateRateLimit WRITE setUpdateRateLimit NOTIFY updateRateLimitChanged)
public:
/**
......@@ -207,6 +211,9 @@ public:
QVariantMap sensorColors() const;
void setSensorColors(const QVariantMap &colors);
int updateRateLimit() const;
void setUpdateRateLimit(int limit);
// from face config, immutable by the user
QString name() const;
const QString icon() const;
......@@ -261,6 +268,7 @@ Q_SIGNALS:
void lowPrioritySensorIdsChanged();
void sensorsChanged();
void sensorColorsChanged();
void updateRateLimitChanged();
private:
const std::unique_ptr<SensorFaceControllerPrivate> d;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment