forked from qt-creator/qt-creator
QmlDesigner: Implement disabling effect maker composition nodes
Disabling happens using a new button added to the section. Also a small tweak to disable drag button when there is only one section in a category. Fixes: QDS-10575 Change-Id: I33884a5b333c54b2bae650943940d4858f489f7a Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Amr Elsayed <amr.elsayed@qt.io> Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
committed by
Amr Elsayed
parent
1b0f25eee8
commit
c5c1612c6b
@@ -12,7 +12,14 @@ import EffectMakerBackend
|
||||
HelperWidgets.Section {
|
||||
id: root
|
||||
|
||||
caption: nodeName
|
||||
// model properties
|
||||
required property string nodeName
|
||||
required property bool nodeEnabled
|
||||
required property var nodeUniformsModel
|
||||
|
||||
required property int index
|
||||
|
||||
caption: root.nodeName
|
||||
category: "EffectMaker"
|
||||
|
||||
draggable: true
|
||||
@@ -21,14 +28,22 @@ HelperWidgets.Section {
|
||||
closeButtonToolTip: qsTr("Remove")
|
||||
|
||||
onCloseButtonClicked: {
|
||||
EffectMakerBackend.effectMakerModel.removeNode(index)
|
||||
EffectMakerBackend.effectMakerModel.removeNode(root.index)
|
||||
}
|
||||
|
||||
showEyeButton: true
|
||||
eyeEnabled: root.nodeEnabled
|
||||
eyeButtonToolTip: qsTr("Enable/Disable Node")
|
||||
|
||||
onEyeButtonClicked: {
|
||||
root.nodeEnabled = root.eyeEnabled
|
||||
}
|
||||
|
||||
Column {
|
||||
spacing: 10
|
||||
|
||||
Repeater {
|
||||
model: nodeUniformsModel
|
||||
model: root.nodeUniformsModel
|
||||
|
||||
EffectCompositionNodeUniform {
|
||||
width: root.width
|
||||
|
||||
@@ -69,6 +69,10 @@ Item {
|
||||
width: root.width
|
||||
model: EffectMakerBackend.effectMakerModel
|
||||
|
||||
onCountChanged: {
|
||||
HelperWidgets.Controller.setCount("EffectMaker", repeater.count)
|
||||
}
|
||||
|
||||
delegate: EffectCompositionNode {
|
||||
width: root.width
|
||||
|
||||
|
||||
@@ -5,13 +5,29 @@ pragma Singleton
|
||||
import QtQuick 2.15
|
||||
|
||||
QtObject {
|
||||
id: values
|
||||
id: root
|
||||
|
||||
// counts of sections in each category, allows accessing the count from inside a section
|
||||
property var counts: ({})
|
||||
|
||||
property Item mainScrollView
|
||||
|
||||
property bool contextMenuOpened: false
|
||||
|
||||
function count(category) {
|
||||
if (!root.counts.hasOwnProperty(category))
|
||||
return 0
|
||||
|
||||
return root.counts[category]
|
||||
}
|
||||
|
||||
function setCount(category, count) {
|
||||
root.counts[category] = count
|
||||
root.countChanged(category, count)
|
||||
}
|
||||
|
||||
signal collapseAll(string category)
|
||||
signal expandAll(string category)
|
||||
signal closeContextMenu()
|
||||
signal countChanged(string category, int count)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ Item {
|
||||
property alias showLeftBorder: leftBorder.visible
|
||||
property alias showCloseButton: closeButton.visible
|
||||
property alias closeButtonToolTip: closeButton.tooltip
|
||||
property alias showEyeButton: eyeButton.visible
|
||||
property alias eyeButtonToolTip: eyeButton.tooltip
|
||||
property alias spacing: column.spacing
|
||||
property alias draggable: dragButton.visible
|
||||
property alias fillBackground: sectionBackground.visible
|
||||
@@ -40,6 +42,7 @@ Item {
|
||||
property bool addBottomPadding: true
|
||||
property bool dropEnabled: false
|
||||
property bool highlight: false
|
||||
property bool eyeEnabled: true // eye button enabled (on)
|
||||
|
||||
property bool useDefaulContextMenu: true
|
||||
|
||||
@@ -75,6 +78,10 @@ Item {
|
||||
function onCloseContextMenu() {
|
||||
contextMenu.close()
|
||||
}
|
||||
function onCountChanged(cat, count) {
|
||||
if (section.showEyeButton && cat === section.category)
|
||||
dragButton.enabled = count > 1
|
||||
}
|
||||
}
|
||||
|
||||
signal drop(var drag)
|
||||
@@ -85,6 +92,7 @@ Item {
|
||||
signal expand()
|
||||
signal collapse()
|
||||
signal closeButtonClicked()
|
||||
signal eyeButtonClicked()
|
||||
signal startDrag(var section)
|
||||
signal stopDrag()
|
||||
|
||||
@@ -133,7 +141,7 @@ Item {
|
||||
height: 4
|
||||
source: "image://icons/down-arrow"
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 4 + (section.level * section.levelShift) + (section.draggable ? 20 : 0)
|
||||
anchors.leftMargin: 4 + (section.level * section.levelShift) + (section.draggable ? 20 : 0) + (section.showEyeButton ? 25 : 0)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
@@ -185,11 +193,11 @@ Item {
|
||||
|
||||
icon: StudioTheme.Constants.dragmarks
|
||||
buttonSize: 22
|
||||
iconScale: containsMouse ? 1.2 : 1
|
||||
iconScale: dragButton.enabled && dragButton.containsMouse ? 1.2 : 1
|
||||
transparentBg: true
|
||||
|
||||
visible: false
|
||||
drag.target: section
|
||||
drag.target: dragButton.enabled ? section : null
|
||||
drag.axis: Drag.YAxis
|
||||
|
||||
onPressed: {
|
||||
@@ -202,6 +210,24 @@ Item {
|
||||
section.stopDrag()
|
||||
}
|
||||
}
|
||||
|
||||
IconButton {
|
||||
id: eyeButton
|
||||
|
||||
anchors.left: dragButton.right
|
||||
|
||||
icon: section.eyeEnabled ? StudioTheme.Constants.visible_small : StudioTheme.Constants.invisible_small
|
||||
buttonSize: 22
|
||||
iconScale: eyeButton.containsMouse ? 1.2 : 1
|
||||
transparentBg: true
|
||||
|
||||
visible: false
|
||||
|
||||
onClicked: {
|
||||
section.eyeEnabled = !section.eyeEnabled
|
||||
root.eyeButtonClicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Drag.active: dragButton.drag.active
|
||||
|
||||
@@ -51,7 +51,10 @@ bool CompositionNode::isEnabled() const
|
||||
|
||||
void CompositionNode::setIsEnabled(bool newIsEnabled)
|
||||
{
|
||||
if (newIsEnabled != m_isEnabled) {
|
||||
m_isEnabled = newIsEnabled;
|
||||
emit isEnabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
CompositionNode::NodeType CompositionNode::type() const
|
||||
|
||||
@@ -14,6 +14,7 @@ class CompositionNode : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString nodeName MEMBER m_name CONSTANT)
|
||||
Q_PROPERTY(bool nodeEnabled READ isEnabled WRITE setIsEnabled NOTIFY isEnabledChanged)
|
||||
Q_PROPERTY(QObject *nodeUniformsModel READ uniformsModel NOTIFY uniformsModelChanged)
|
||||
|
||||
public:
|
||||
@@ -40,6 +41,7 @@ public:
|
||||
|
||||
signals:
|
||||
void uniformsModelChanged();
|
||||
void isEnabledChanged();
|
||||
|
||||
private:
|
||||
void parse(const QString &qenPath);
|
||||
@@ -50,7 +52,7 @@ private:
|
||||
QString m_vertexCode;
|
||||
QString m_description;
|
||||
QStringList m_requiredNodes;
|
||||
bool m_isEnabled;
|
||||
bool m_isEnabled = true;
|
||||
|
||||
EffectMakerUniformsModel m_unifomrsModel;
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@ QHash<int, QByteArray> EffectMakerModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "nodeName";
|
||||
roles[EnabledRole] = "nodeEnabled";
|
||||
roles[UniformsRole] = "nodeUniformsModel";
|
||||
return roles;
|
||||
}
|
||||
@@ -42,6 +43,19 @@ QVariant EffectMakerModel::data(const QModelIndex &index, int role) const
|
||||
return m_nodes.at(index.row())->property(roleNames().value(role));
|
||||
}
|
||||
|
||||
bool EffectMakerModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid() || !roleNames().contains(role))
|
||||
return false;
|
||||
|
||||
if (role == EnabledRole) {
|
||||
m_nodes.at(index.row())->setIsEnabled(value.toBool());
|
||||
emit dataChanged(index, index, {role});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EffectMakerModel::addNode(const QString &nodeQenPath)
|
||||
{
|
||||
beginInsertRows({}, m_nodes.size(), m_nodes.size());
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
bool isEmpty() const { return m_isEmpty; }
|
||||
|
||||
@@ -60,6 +61,7 @@ signals:
|
||||
private:
|
||||
enum Roles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
EnabledRole,
|
||||
UniformsRole
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user