blob: 519d6fcf7801053f8911d6e04c3bf694f9523d4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "createtexture.h"
#include <QFrame>
#include <QPointer>
QT_BEGIN_NAMESPACE
class QDir;
class QShortcut;
class QToolButton;
QT_END_NAMESPACE
class StudioQuickWidget;
namespace QmlDesigner {
class ContentLibraryTexture;
class ContentLibraryMaterial;
class ContentLibraryTexturesModel;
class ContentLibraryMaterialsModel;
class ContentLibraryWidget : public QFrame
{
Q_OBJECT
Q_PROPERTY(bool hasQuick3DImport READ hasQuick3DImport NOTIFY hasQuick3DImportChanged)
Q_PROPERTY(bool hasMaterialLibrary READ hasMaterialLibrary NOTIFY hasMaterialLibraryChanged)
// Needed for a workaround for a bug where after drag-n-dropping an item, the ScrollView scrolls to a random position
Q_PROPERTY(bool isDragging MEMBER m_isDragging NOTIFY isDraggingChanged)
public:
ContentLibraryWidget();
QList<QToolButton *> createToolBarWidgets();
static QString qmlSourcesPath();
void clearSearchFilter();
bool hasQuick3DImport() const;
void setHasQuick3DImport(bool b);
bool hasMaterialLibrary() const;
void setHasMaterialLibrary(bool b);
Q_INVOKABLE void handleSearchFilterChanged(const QString &filterText);
void setMaterialsModel(QPointer<ContentLibraryMaterialsModel> newMaterialsModel);
QPointer<ContentLibraryMaterialsModel> materialsModel() const;
QPointer<ContentLibraryTexturesModel> texturesModel() const;
QPointer<ContentLibraryTexturesModel> environmentsModel() const;
Q_INVOKABLE void startDragMaterial(QmlDesigner::ContentLibraryMaterial *mat, const QPointF &mousePos);
Q_INVOKABLE void startDragTexture(QmlDesigner::ContentLibraryTexture *tex, const QPointF &mousePos);
Q_INVOKABLE void addImage(QmlDesigner::ContentLibraryTexture *tex);
Q_INVOKABLE void addTexture(QmlDesigner::ContentLibraryTexture *tex);
Q_INVOKABLE void addLightProbe(QmlDesigner::ContentLibraryTexture *tex);
Q_INVOKABLE void updateSceneEnvState();
Q_INVOKABLE bool markTextureDownloading();
Q_INVOKABLE void markNoTextureDownloading();
signals:
void bundleMaterialDragStarted(QmlDesigner::ContentLibraryMaterial *bundleMat);
void bundleTextureDragStarted(QmlDesigner::ContentLibraryTexture *bundleTex);
void addTextureRequested(const QString texPath, QmlDesigner::AddTextureMode mode);
void updateSceneEnvStateRequested();
void hasQuick3DImportChanged();
void hasMaterialLibraryChanged();
void isDraggingChanged();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
private:
void reloadQmlSource();
void updateSearch();
void setIsDragging(bool val);
QString findTextureBundlePath();
void loadTextureBundle();
QVariantMap readBundleMetadata();
bool fetchTextureBundleMetadata(const QDir &bundleDir);
bool fetchTextureBundleIcons(const QDir &bundleDir);
QScopedPointer<StudioQuickWidget> m_quickWidget;
QPointer<ContentLibraryMaterialsModel> m_materialsModel;
QPointer<ContentLibraryTexturesModel> m_texturesModel;
QPointer<ContentLibraryTexturesModel> m_environmentsModel;
QShortcut *m_qmlSourceUpdateShortcut = nullptr;
QString m_filterText;
ContentLibraryMaterial *m_materialToDrag = nullptr;
ContentLibraryTexture *m_textureToDrag = nullptr;
QPoint m_dragStartPoint;
bool m_hasMaterialLibrary = false;
bool m_hasQuick3DImport = false;
bool m_isDragging = false;
bool m_anyTextureBeingDownloaded = false;
QString m_baseUrl;
QString m_texturesUrl;
QString m_environmentsUrl;
QString m_downloadPath;
};
} // namespace QmlDesigner
|