File indexing completed on 2024-04-28 05:31:32
0001 /* 0002 SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QQuickItem> 0010 0011 #include "sensorfaces_export.h" 0012 0013 namespace KSysGuard 0014 { 0015 class SensorFaceController; 0016 0017 /** 0018 * Base for sensor faces. Use this as root item when creating custom faces. 0019 * @code 0020 * import org.kde.ksysguard.faces 1.0 0021 * SensorFace { 0022 * contentItem: Label { 0023 * text: "Custom visualization" 0024 * } 0025 * } 0026 * @endcode 0027 * @since 5.19 0028 */ 0029 class SENSORFACES_EXPORT SensorFace : public QQuickItem 0030 { 0031 Q_OBJECT 0032 /** 0033 * The controller that instantiated this face and is responsible for it. Contains information 0034 * about the sensors that should be displayed and the configuration of the face 0035 */ 0036 Q_PROPERTY(KSysGuard::SensorFaceController *controller READ controller CONSTANT) 0037 /** 0038 * The current active formFactor. Describes how the face should display itself 0039 */ 0040 Q_PROPERTY(KSysGuard::SensorFace::FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged) 0041 /** 0042 * Main item of the face. Assign your custom visualization to it 0043 */ 0044 Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged) 0045 #ifdef K_DOXYGEN // Document proprties from SensorFace.qml 0046 /** 0047 * Primary actions that this face provides 0048 */ 0049 Q_PROPERTY(org::kde::kirigami::Action primaryActions) 0050 /** 0051 * Secondary actions this face provides 0052 */ 0053 Q_PROPERTY(org::kde::kirigami::Action secondaryActions) 0054 /** 0055 * A color source that can be used when using charts from KQuickCharts 0056 * @see SensorFaceController::sensorColors 0057 */ 0058 Q_PROPERTY(MapProxySource colorSource) 0059 #endif 0060 public: 0061 /** 0062 * Describes how the face should display itself. 0063 */ 0064 enum FormFactor { 0065 Planar, ///< Default, the face can expand horizontally and vertically 0066 Vertical, ///< The face is constrained horizontally, but can expand vertically 0067 Horizontal, ///< The face is constrained vertically, but can expand horizontally 0068 Constrained ///< The face is fully constrained, for example when in the edit mode of plasma-systemmonitor 0069 }; 0070 Q_ENUM(FormFactor) 0071 0072 SensorFace(QQuickItem *parent = nullptr); 0073 ~SensorFace() override; 0074 0075 SensorFaceController *controller() const; 0076 // Not writable from QML 0077 void setController(SensorFaceController *controller); 0078 0079 SensorFace::FormFactor formFactor() const; 0080 void setFormFactor(SensorFace::FormFactor formFactor); 0081 0082 QQuickItem *contentItem() const; 0083 void setContentItem(QQuickItem *item); 0084 0085 Q_SIGNALS: 0086 void formFactorChanged(); 0087 void contentItemChanged(); 0088 0089 protected: 0090 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; 0091 0092 private: 0093 class Private; 0094 const std::unique_ptr<Private> d; 0095 }; 0096 }