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 /**
33 * The controller that instantiated this face and is responsible for it. Contains information
34 * about the sensors that should be displayed and the configuration of the face
35 */
36 Q_PROPERTY(KSysGuard::SensorFaceController *controller READ controller CONSTANT)
37 /**
38 * The current active formFactor. Describes how the face should display itself
39 */
40 Q_PROPERTY(KSysGuard::SensorFace::FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
41 /**
42 * Main item of the face. Assign your custom visualization to it
43 */
44 Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged)
45#ifdef K_DOXYGEN // Document proprties from SensorFace.qml
46 /**
47 * Primary actions that this face provides
48 */
49 Q_PROPERTY(org::kde::kirigami::Action primaryActions)
50 /**
51 * Secondary actions this face provides
52 */
53 Q_PROPERTY(org::kde::kirigami::Action secondaryActions)
54 /**
55 * A color source that can be used when using charts from KQuickCharts
56 * @see SensorFaceController::sensorColors
57 */
58 Q_PROPERTY(MapProxySource colorSource)
59#endif
60public:
61 /**
62 * Describes how the face should display itself.
63 */
64 enum FormFactor {
65 Planar, ///< Default, the face can expand horizontally and vertically
66 Vertical, ///< The face is constrained horizontally, but can expand vertically
67 Horizontal, ///< The face is constrained vertically, but can expand horizontally
68 Constrained ///< The face is fully constrained, for example when in the edit mode of plasma-systemmonitor
69 };
70 Q_ENUM(FormFactor)
71
72 SensorFace(QQuickItem *parent = nullptr);
73 ~SensorFace() override;
74
75 SensorFaceController *controller() const;
76 // Not writable from QML
77 void setController(SensorFaceController *controller);
78
79 SensorFace::FormFactor formFactor() const;
80 void setFormFactor(SensorFace::FormFactor formFactor);
81
82 QQuickItem *contentItem() const;
83 void setContentItem(QQuickItem *item);
84
85Q_SIGNALS:
86 void formFactorChanged();
87 void contentItemChanged();
88
89protected:
90 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
91
92private:
93 class Private;
94 const std::unique_ptr<Private> d;
95};
96}
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 Tue Mar 26 2024 11:21:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.