10using namespace KSysGuard;
19 void setupController();
28 bool complete =
false;
35 bool showTitle =
false;
38FaceLoader::FaceLoader(
QObject *parent)
40 , d(new Private{this})
44FaceLoader::~FaceLoader() =
default;
48 return d->parentController;
53 if (newParentController == d->parentController) {
57 if (d->parentController) {
58 d->parentController->disconnect(
this);
62 d->controller->deleteLater();
65 d->parentController = newParentController;
69 Q_EMIT parentControllerChanged();
77void FaceLoader::setFaceId(
const QString &newFaceId)
79 if (newFaceId == d->faceId) {
83 d->faceId = newFaceId;
85 d->controller->setFaceId(d->faceId);
96void FaceLoader::setGroupName(
const QString &newGroupName)
98 if (newGroupName == d->groupName) {
102 d->groupName = newGroupName;
104 d->setupController();
106 Q_EMIT groupNameChanged();
114void FaceLoader::setSensors(
const QJsonArray &newSensors)
116 if (newSensors == d->sensors) {
120 d->sensors = newSensors;
123 d->controller->setHighPrioritySensorIds(d->sensors);
134void FaceLoader::setColors(
const QVariantMap &newColors)
136 if (newColors == d->colors) {
140 d->colors = newColors;
142 d->controller->setSensorColors(d->colors);
152void FaceLoader::setLabels(
const QVariantMap &newLabels)
154 if (newLabels == d->labels) {
158 d->labels = newLabels;
160 d->controller->setSensorLabels(d->labels);
170void FaceLoader::setReadOnly(
bool newReadOnly)
172 if (newReadOnly == d->readOnly) {
176 d->readOnly = newReadOnly;
178 d->controller->setShouldSync(!d->readOnly);
185 return d->controller;
188void FaceLoader::reload()
190 d->controller->reloadFaceConfiguration();
193void FaceLoader::classBegin()
197void FaceLoader::componentComplete()
200 d->setupController();
203void FaceLoader::Private::setupController()
205 if (!parentController || groupName.
isEmpty() || !complete) {
212 controller->setHighPrioritySensorIds(sensors);
213 controller->setSensorColors(colors);
214 controller->setSensorLabels(labels);
215 controller->setShowTitle(showTitle);
216 controller->setFaceId(faceId);
218 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.
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