10using namespace KSysGuard;
19 void setupController();
28 bool complete =
false;
34 int updateRateLimit = 0;
36 bool showTitle =
false;
39FaceLoader::FaceLoader(
QObject *parent)
41 , d(new Private{this})
45FaceLoader::~FaceLoader() =
default;
49 return d->parentController;
54 if (newParentController == d->parentController) {
58 if (d->parentController) {
59 d->parentController->disconnect(
this);
63 d->controller->deleteLater();
66 d->parentController = newParentController;
70 Q_EMIT parentControllerChanged();
78void FaceLoader::setFaceId(
const QString &newFaceId)
80 if (newFaceId == d->faceId) {
84 d->faceId = newFaceId;
86 d->controller->setFaceId(d->faceId);
97void FaceLoader::setGroupName(
const QString &newGroupName)
99 if (newGroupName == d->groupName) {
103 d->groupName = newGroupName;
105 d->setupController();
107 Q_EMIT groupNameChanged();
115void FaceLoader::setSensors(
const QJsonArray &newSensors)
117 if (newSensors == d->sensors) {
121 d->sensors = newSensors;
124 d->controller->setHighPrioritySensorIds(d->sensors);
135void FaceLoader::setColors(
const QVariantMap &newColors)
137 if (newColors == d->colors) {
141 d->colors = newColors;
143 d->controller->setSensorColors(d->colors);
146 Q_EMIT d->controller->sensorColorsChanged();
156void FaceLoader::setLabels(
const QVariantMap &newLabels)
158 if (newLabels == d->labels) {
162 d->labels = newLabels;
164 d->controller->setSensorLabels(d->labels);
167 Q_EMIT d->controller->sensorLabelsChanged();
174 return d->updateRateLimit;
177void FaceLoader::setUpdateRateLimit(
int newLimit)
179 if (newLimit == d->updateRateLimit) {
183 d->updateRateLimit = newLimit;
185 d->controller->setUpdateRateLimit(d->updateRateLimit);
188 Q_EMIT d->controller->updateRateLimitChanged();
190 Q_EMIT updateRateLimitChanged();
198void FaceLoader::setReadOnly(
bool newReadOnly)
200 if (newReadOnly == d->readOnly) {
204 d->readOnly = newReadOnly;
206 d->controller->setShouldSync(!d->readOnly);
213 return d->controller;
216void FaceLoader::reload()
218 d->controller->reloadFaceConfiguration();
221void FaceLoader::classBegin()
225void FaceLoader::componentComplete()
228 d->setupController();
231void FaceLoader::Private::setupController()
233 if (!parentController || groupName.
isEmpty() || !complete) {
240 controller->setHighPrioritySensorIds(sensors);
241 controller->setSensorColors(colors);
242 controller->setSensorLabels(labels);
243 controller->setShowTitle(showTitle);
244 controller->setFaceId(faceId);
245 controller->setUpdateRateLimit(updateRateLimit);
247 Q_EMIT q->controllerChanged();
KConfigGroup group(const QString &group)
A helper class to make it easier to load faces when used inside a face.
bool readOnly
Whether to allow modifying the face configuration.
KSysGuard::SensorFaceController * controller
The face controller that provides the loaded face.
QJsonArray sensors
The sensors to use for this face.
QVariantMap labels
A map of sensor labels to be used by the face.
QVariantMap colors
A map of sensor colors to be used by the face.
QString groupName
The name of the config group to read configuration from.
QString faceId
The face to use.
QML_ELEMENTKSysGuard::SensorFaceController * parentController
The parent SensorFaceController that will be used for configuration storage.
int updateRateLimit
The minimum time that needs to elapse, in milliseconds, between updates of the face.
The SensorFaceController links sensor faces and applications in which these faces are shown.
void setShouldSync(bool sync)
Specifies if the controller should automatically sync configuration changes.
KConfigGroup configGroup() const
Retrieve the KConfigGroup this controller is using to store configuration.
bool isEmpty() const const