forked from qt-creator/qt-creator
QmlDesigner: Implement basic composition node delegate
Task-number: QDS-10404 Change-Id: Ia456fb96c157d5e8d6206732c90d761c59b27fab Reviewed-by: Amr Elsayed <amr.elsayed@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (C) 2023 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuickDesignerTheme
|
||||||
|
import HelperWidgets as HelperWidgets
|
||||||
|
import StudioControls as StudioControls
|
||||||
|
import StudioTheme 1.0 as StudioTheme
|
||||||
|
import EffectMakerBackend
|
||||||
|
|
||||||
|
HelperWidgets.Section {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
caption: model.nodeName
|
||||||
|
category: "EffectMaker"
|
||||||
|
|
||||||
|
// TODO: implement effect properties
|
||||||
|
// property var propList: model.props
|
||||||
|
|
||||||
|
Column {
|
||||||
|
anchors.fill: parent
|
||||||
|
spacing: 2
|
||||||
|
|
||||||
|
// Repeater {
|
||||||
|
// id: effects
|
||||||
|
// model: effectList
|
||||||
|
// width: parent.width
|
||||||
|
// height: parent.height
|
||||||
|
// delegate: Text {
|
||||||
|
// width: parent.width
|
||||||
|
// //height: StudioTheme.Values.checkIndicatorHeight * 2 // TODO: update or remove
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -64,40 +64,18 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
Item {
|
|
||||||
width: scrollView.width
|
width: scrollView.width
|
||||||
height: categories.height
|
height: compositionRepeater.height
|
||||||
|
spacing: 1
|
||||||
|
|
||||||
Column {
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: categories
|
id: compositionRepeater
|
||||||
|
|
||||||
width: root.width
|
width: root.width
|
||||||
model: EffectMakerBackend.effectMakerModel
|
model: EffectMakerBackend.effectMakerModel
|
||||||
|
|
||||||
delegate: HelperWidgets.Section {
|
delegate: EffectCompositionNode {
|
||||||
id: effectsSection
|
|
||||||
width: root.width
|
width: root.width
|
||||||
caption: model.categoryName
|
|
||||||
category: "EffectMaker"
|
|
||||||
|
|
||||||
property var effectList: model.effectNames
|
|
||||||
|
|
||||||
onExpandedChanged: {
|
|
||||||
effects.visible = expanded // TODO: update
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
id: effects
|
|
||||||
model: effectList
|
|
||||||
width: parent.width
|
|
||||||
height: parent.height
|
|
||||||
delegate: EffectNode {
|
|
||||||
width: parent.width
|
|
||||||
//height: StudioTheme.Values.checkIndicatorHeight * 2 // TODO: update or remove
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
#include "compositionnode.h"
|
#include "compositionnode.h"
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -33,14 +33,14 @@ QString CompositionNode::description() const
|
|||||||
void CompositionNode::parse(const QString &qenPath)
|
void CompositionNode::parse(const QString &qenPath)
|
||||||
{
|
{
|
||||||
|
|
||||||
QFile loadFile(qenPath);
|
QFile qenFile(qenPath);
|
||||||
|
|
||||||
if (!loadFile.open(QIODevice::ReadOnly)) {
|
if (!qenFile.open(QIODevice::ReadOnly)) {
|
||||||
qWarning("Couldn't open effect file.");
|
qWarning("Couldn't open effect file.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray loadData = loadFile.readAll();
|
QByteArray loadData = qenFile.readAll();
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(loadData, &parseError));
|
QJsonDocument jsonDoc(QJsonDocument::fromJson(loadData, &parseError));
|
||||||
if (parseError.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
@@ -51,13 +51,31 @@ void CompositionNode::parse(const QString &qenPath)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject json = jsonDoc.object();
|
QJsonObject json = jsonDoc.object().value("QEN").toObject();
|
||||||
QFileInfo fi(loadFile);
|
|
||||||
|
|
||||||
// TODO: QDS-10467
|
m_name = json.value("name").toString();
|
||||||
// Parse the effect from QEN file
|
|
||||||
// The process from the older implementation has the concept of `project`
|
// parse properties
|
||||||
// and it contains source & dest nodes that we don't need
|
QJsonArray properties = json.value("properties").toArray();
|
||||||
|
for (const auto /*QJsonValueRef*/ &prop : properties) {
|
||||||
|
QJsonObject propObj = prop.toObject();
|
||||||
|
propObj.value("name");
|
||||||
|
propObj.value("type");
|
||||||
|
propObj.value("defaultValue");
|
||||||
|
propObj.value("description");
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse shaders
|
||||||
|
QJsonArray vertexCode = json.value("vertexCode").toArray();
|
||||||
|
if (!vertexCode.isEmpty()) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonArray fragmentCode = json.value("fragmentCode").toArray();
|
||||||
|
if (!fragmentCode.isEmpty()) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace QmlDesigner
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ class CompositionNode : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QString nodeName MEMBER m_name CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CompositionNode(const QString &qenPath);
|
CompositionNode(const QString &qenPath);
|
||||||
|
|
||||||
@@ -28,4 +30,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "compositionnode.h"
|
#include "compositionnode.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
EffectMakerModel::EffectMakerModel(QObject *parent)
|
EffectMakerModel::EffectMakerModel(QObject *parent)
|
||||||
@@ -26,14 +28,12 @@ int EffectMakerModel::rowCount(const QModelIndex &parent) const
|
|||||||
return m_nodes.count();
|
return m_nodes.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant EffectMakerModel::data(const QModelIndex &index, int /*role*/) const
|
QVariant EffectMakerModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (index.row() < 0 || index.row() >= m_nodes.count())
|
QTC_ASSERT(index.isValid() && index.row() < m_nodes.size(), return {});
|
||||||
return {};
|
QTC_ASSERT(roleNames().contains(role), return {});
|
||||||
|
|
||||||
// TODO
|
return m_nodes.values().at(index.row())->property(roleNames().value(role));
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectMakerModel::resetModel()
|
void EffectMakerModel::resetModel()
|
||||||
@@ -46,9 +46,10 @@ void EffectMakerModel::addNode(const QString &nodeQenPath)
|
|||||||
{
|
{
|
||||||
static int id = 0;
|
static int id = 0;
|
||||||
|
|
||||||
|
beginInsertRows({}, m_nodes.size(), m_nodes.size());
|
||||||
auto *node = new CompositionNode(nodeQenPath);
|
auto *node = new CompositionNode(nodeQenPath);
|
||||||
m_nodes.insert(id++, node);
|
m_nodes.insert(id++, node);
|
||||||
// TODO: update model
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectMakerModel::selectEffect(int idx, bool force)
|
void EffectMakerModel::selectEffect(int idx, bool force)
|
||||||
|
|||||||
Reference in New Issue
Block a user