DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dquickitemviewport.h
1// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DQUICKITEMVIEWPORT_H
6#define DQUICKITEMVIEWPORT_H
7
8#include <dtkdeclarative_global.h>
9#include <DObject>
10
11#include <QQuickItem>
12
13DQUICK_BEGIN_NAMESPACE
14
15class DQuickItemViewportPrivate;
16class DQuickItemViewport : public QQuickItem, public DCORE_NAMESPACE::DObject
17{
18 Q_OBJECT
19 Q_PROPERTY(QQuickItem* sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged)
20 Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged)
21 Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged)
22 Q_PROPERTY(bool fixed READ fixed WRITE setFixed NOTIFY fixedChanged)
23 Q_PROPERTY(bool hideSource READ hideSource WRITE setHideSource NOTIFY hideSourceChanged)
24 D_DECLARE_PRIVATE(DQuickItemViewport)
25#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
26 QML_NAMED_ELEMENT(ItemViewport)
27#endif
28
29public:
30 explicit DQuickItemViewport(QQuickItem *parent = nullptr);
31 ~DQuickItemViewport() override;
32
33 QQuickItem* sourceItem() const;
34 void setSourceItem(QQuickItem* sourceItem);
35
36 QRectF sourceRect() const;
37 void setSourceRect(const QRectF &sourceRect);
38
39 float radius() const;
40 void setRadius(float radius);
41
42 bool fixed() const;
43 void setFixed(bool newFixed);
44
45 bool hideSource() const;
46 void setHideSource(bool newHideSource);
47
48 bool isTextureProvider() const override { return true; }
49 QSGTextureProvider *textureProvider() const override;
50
51Q_SIGNALS:
52 void sourceItemChanged();
53 void sourceRectChanged();
54 void radiusChanged();
55 void fixedChanged();
56 void hideSourceChanged();
57
58private Q_SLOTS:
59 void invalidateSceneGraph();
60
61protected:
62 void itemChange(ItemChange, const ItemChangeData &) override;
63#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
64 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
65#else
66 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
67#endif
68 QSGNode *updatePaintNode(QSGNode *old, UpdatePaintNodeData *) override;
69 void componentComplete() override;
70 void releaseResources() override;
71};
72
73DQUICK_END_NAMESPACE
74
75#endif // DQUICKITEMVIEWPORT_H
DQuickItemViewport 类是根据 sourceItem 属性设定的 QQuickItem 作为绘制时的材质来源,这个行为依赖于 QQuickItem::textureProvider 提供...
Definition dquickitemviewport.h:17