Libksysguard

SensorFace_p.h
1/*
2 SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QQuickItem>
10
11#include "sensorfaces_export.h"
12
13namespace KSysGuard
14{
15class SensorFaceController;
16
17/**
18 * Base for sensor faces. Use this as root item when creating custom faces.
19 * @code
20 * import org.kde.ksysguard.faces 1.0
21 * SensorFace {
22 * contentItem: Label {
23 * text: "Custom visualization"
24 * }
25 * }
26 * @endcode
27 * @since 5.19
28 */
29class SENSORFACES_EXPORT SensorFace : public QQuickItem
30{
31 Q_OBJECT
32 QML_NAMED_ELEMENT(AbstractSensorFace)
33 /**
34 * The controller that instantiated this face and is responsible for it. Contains information
35 * about the sensors that should be displayed and the configuration of the face
36 */
37 Q_PROPERTY(KSysGuard::SensorFaceController *controller READ controller CONSTANT)
38 /**
39 * The current active formFactor. Describes how the face should display itself
40 */
41 Q_PROPERTY(KSysGuard::SensorFace::FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
42 /**
43 * Main item of the face. Assign your custom visualization to it
44 */
45 Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged)
46#ifdef K_DOXYGEN // Document proprties from SensorFace.qml
47 /**
48 * Primary actions that this face provides
49 */
50 Q_PROPERTY(org::kde::kirigami::Action primaryActions)
51 /**
52 * Secondary actions this face provides
53 */
54 Q_PROPERTY(org::kde::kirigami::Action secondaryActions)
55 /**
56 * A color source that can be used when using charts from KQuickCharts
57 * @see SensorFaceController::sensorColors
58 */
59 Q_PROPERTY(MapProxySource colorSource)
60#endif
61public:
62 /**
63 * Describes how the face should display itself.
64 */
65 enum FormFactor {
66 Planar, ///< Default, the face can expand horizontally and vertically
67 Vertical, ///< The face is constrained horizontally, but can expand vertically
68 Horizontal, ///< The face is constrained vertically, but can expand horizontally
69 Constrained ///< The face is fully constrained, for example when in the edit mode of plasma-systemmonitor
70 };
71 Q_ENUM(FormFactor)
72
73 SensorFace(QQuickItem *parent = nullptr);
74 ~SensorFace() override;
75
76 SensorFaceController *controller() const;
77 // Not writable from QML
78 void setController(SensorFaceController *controller);
79
80 SensorFace::FormFactor formFactor() const;
81 void setFormFactor(SensorFace::FormFactor formFactor);
82
83 QQuickItem *contentItem() const;
84 void setContentItem(QQuickItem *item);
85
86Q_SIGNALS:
87 void formFactorChanged();
88 void contentItemChanged();
89
90protected:
91 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
92
93private:
94 class Private;
95 const std::unique_ptr<Private> d;
96};
97}
The SensorFaceController links sensor faces and applications in which these faces are shown.
Base for sensor faces.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:17:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.