Libksysguard

SensorFace.cpp
1/*
2 SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "SensorFaceController.h"
8#include "SensorFace_p.h"
9
10#include <QDebug>
11
12using namespace KSysGuard;
13
14class SensorFace::Private
15{
16public:
17 QPointer<QQuickItem> contentItem;
18 SensorFaceController *controller = nullptr;
19 FormFactor formFactor = Planar;
20};
21
22SensorFace::SensorFace(QQuickItem *parent)
23 : QQuickItem(parent)
24 , d(std::make_unique<Private>())
25{
26}
27
28SensorFace::~SensorFace()
29{
30}
31
33{
34 return d->controller;
35}
36
37// Not writable from QML
38void SensorFace::setController(SensorFaceController *controller)
39{
40 d->controller = controller;
41}
42
43SensorFace::FormFactor SensorFace::formFactor() const
44{
45 return d->formFactor;
46}
47
48void SensorFace::setFormFactor(SensorFace::FormFactor formFactor)
49{
50 if (d->formFactor == formFactor) {
51 return;
52 }
53
54 d->formFactor = formFactor;
55 Q_EMIT formFactorChanged();
56}
57
59{
60 return d->contentItem;
61}
62
63void SensorFace::setContentItem(QQuickItem *item)
64{
65 if (d->contentItem == item) {
66 return;
67 }
68 d->contentItem = item;
69
70 if (d->contentItem) {
71 d->contentItem->setParentItem(this);
72 d->contentItem->setX(0);
73 d->contentItem->setY(0);
74 d->contentItem->setSize(size());
75 }
76
77 Q_EMIT contentItemChanged();
78}
79void SensorFace::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
80{
81 if (d->contentItem) {
82 d->contentItem->setX(0);
83 d->contentItem->setY(0);
84 d->contentItem->setSize(newGeometry.size());
85 }
86 QQuickItem::geometryChange(newGeometry, oldGeometry);
87}
88
89#include "moc_SensorFace_p.cpp"
The SensorFaceController links sensor faces and applications in which these faces are shown.
KSysGuard::SensorFace::FormFactor formFactor
The current active formFactor.
KSysGuard::SensorFaceController * controller
The controller that instantiated this face and is responsible for it.
QQuickItem * contentItem
Main item of the face.
Q_EMITQ_EMIT
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
QSizeF size() const const
QSizeF size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.