Libksysguard

SensorFace_p.h
1 /*
2  Copyright (C) 2020 Marco Martin <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #pragma once
21 
22 #include <QQuickItem>
23 
24 #include "sensorfaces_export.h"
25 
26 namespace KSysGuard {
27 
28 class SensorFaceController;
29 
30 
31 /**
32  * Base for sensor faces. Use this as root item when creating custom faces.
33  * @code
34  * import org.kde.ksysguard.faces 1.0
35  * SensorFace {
36  * contentItem: Label {
37  * text: "Custom visualization"
38  * }
39  * }
40  * @endcode
41  * @since 5.19
42  */
43 class SENSORFACES_EXPORT SensorFace : public QQuickItem
44 {
45  Q_OBJECT
46  /**
47  * The controller that instantiated this face and is responsible for it. Contains information
48  * about the sensors that should be displayed and the configuration of the face
49  */
50  Q_PROPERTY(KSysGuard::SensorFaceController *controller READ controller CONSTANT)
51  /**
52  * The current active formFactor. Describes how the face should display itself
53  */
54  Q_PROPERTY(KSysGuard::SensorFace::FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
55  /**
56  * Main item of the face. Assign your custom visualization to it
57  */
58  Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged)
59 #ifdef K_DOXYGEN // Document proprties from SensorFace.qml
60  /**
61  * Primary actions that this face provides
62  */
63  Q_PROPERTY(org::kde::kirigami::Action primaryActions)
64  /**
65  * Secondary actions this face provides
66  */
67  Q_PROPERTY(org::kde::kirigami::Action secondaryActions)
68  /**
69  * A color source that can be used when using charts from KQuickCharts
70  * @see SensorFaceController::sensorColors
71  */
72  Q_PROPERTY(MapProxySource colorSource)
73 #endif
74 public:
75  /**
76  * Describes how the face should display itself.
77  */
78  enum FormFactor {
79  Planar, ///< Default, the face can expand horizontally and vertically
80  Vertical, ///< The face is constrained horizontally, but can expand vertically
81  Horizontal, ///< The face is constrained vertically, but can expand horizontally
82  Constrained ///< The face is fully constrained, for example when in the edit mode of plasma-systemmonitor
83  };
84  Q_ENUM(FormFactor)
85 
86  SensorFace(QQuickItem *parent = nullptr);
87  ~SensorFace();
88 
89  SensorFaceController *controller() const;
90  // Not writable from QML
91  void setController(SensorFaceController *controller);
92 
93  SensorFace::FormFactor formFactor() const;
94  void setFormFactor(SensorFace::FormFactor formFactor);
95 
96  QQuickItem * contentItem() const;
97  void setContentItem(QQuickItem *item);
98 
99 Q_SIGNALS:
100  void formFactorChanged();
101  void contentItemChanged();
102 
103 protected:
104  void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
105 
106 private:
107  class Private;
108  const std::unique_ptr<Private> d;
109 };
110 }
The SensorFaceController links sensor faces and applications in which these faces are shown...
The face is constrained vertically, but can expand horizontally.
Definition: SensorFace_p.h:81
Default, the face can expand horizontally and vertically.
Definition: SensorFace_p.h:79
FormFactor
Describes how the face should display itself.
Definition: SensorFace_p.h:78
The face is constrained horizontally, but can expand vertically.
Definition: SensorFace_p.h:80
Base for sensor faces.
Definition: SensorFace_p.h:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 02:46:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.