9using namespace KSysGuard;
18 void setupController();
27 bool complete =
false;
34 bool showTitle =
false;
37FaceLoader::FaceLoader(
QObject *parent)
39 , d(new Private{this})
43FaceLoader::~FaceLoader() =
default;
47 return d->parentController;
52 if (newParentController == d->parentController) {
56 if (d->parentController) {
57 d->parentController->disconnect(
this);
61 d->controller->deleteLater();
64 d->parentController = newParentController;
68 Q_EMIT parentControllerChanged();
76void FaceLoader::setFaceId(
const QString &newFaceId)
78 if (newFaceId == d->faceId) {
82 d->faceId = newFaceId;
84 d->controller->setFaceId(d->faceId);
95void FaceLoader::setGroupName(
const QString &newGroupName)
97 if (newGroupName == d->groupName) {
101 d->groupName = newGroupName;
103 d->setupController();
105 Q_EMIT groupNameChanged();
113void FaceLoader::setSensors(
const QJsonArray &newSensors)
115 if (newSensors == d->sensors) {
119 d->sensors = newSensors;
122 d->controller->setHighPrioritySensorIds(d->sensors);
133void FaceLoader::setColors(
const QVariantMap &newColors)
135 if (newColors == d->colors) {
139 d->colors = newColors;
141 d->controller->setSensorColors(d->colors);
151void FaceLoader::setLabels(
const QVariantMap &newLabels)
153 if (newLabels == d->labels) {
157 d->labels = newLabels;
159 d->controller->setSensorLabels(d->labels);
169void FaceLoader::setReadOnly(
bool newReadOnly)
171 if (newReadOnly == d->readOnly) {
175 d->readOnly = newReadOnly;
177 d->controller->setShouldSync(!d->readOnly);
184 return d->controller;
187void FaceLoader::reload()
189 d->controller->reloadFaceConfiguration();
192void FaceLoader::classBegin()
196void FaceLoader::componentComplete()
199 d->setupController();
202void FaceLoader::Private::setupController()
204 if (!parentController || groupName.
isEmpty() || !complete) {
211 controller->setHighPrioritySensorIds(sensors);
212 controller->setSensorColors(colors);
213 controller->setSensorLabels(labels);
214 controller->setShowTitle(showTitle);
215 controller->setFaceId(faceId);
217 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.
KSysGuard::SensorFaceController * parentController
The parent SensorFaceController that will be used for configuration storage.
QString groupName
The name of the config group to read configuration from.
QString faceId
The face to use.
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