QmlDesigner: Add empty placeholder to effect maker's view

Fixes: QDS-10592
Change-Id: Icc6193b358b83fce2a229321e30880e35e074055
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:
Mahmoud Badri
2023-09-08 11:07:10 +03:00
parent 8ce8bd4300
commit 7fbcf4a38e
4 changed files with 28 additions and 1 deletions

View File

@@ -136,4 +136,17 @@ Item {
} // Column } // Column
} // ScrollView } // ScrollView
} }
Text {
id: emptyText
text: qsTr("Add an effect node to start")
color: StudioTheme.Values.themeTextColor
font.pixelSize: StudioTheme.Values.baseFontSize
x: scrollView.x + (scrollView.width - emptyText.width) * .5
y: scrollView.y + scrollView.height * .5
visible: EffectMakerBackend.effectMakerModel.isEmpty
}
} }

View File

@@ -177,7 +177,7 @@ Item {
IconButton { IconButton {
id: closeButton id: closeButton
icon: StudioTheme.Constants.close_small icon: StudioTheme.Constants.closeCross
buttonSize: 22 buttonSize: 22
iconScale: containsMouse ? 1.2 : 1 iconScale: containsMouse ? 1.2 : 1
transparentBg: true transparentBg: true

View File

@@ -56,12 +56,22 @@ bool EffectMakerModel::setData(const QModelIndex &index, const QVariant &value,
return true; return true;
} }
void EffectMakerModel::setIsEmpty(bool val)
{
if (m_isEmpty != val) {
m_isEmpty = val;
emit isEmptyChanged();
}
}
void EffectMakerModel::addNode(const QString &nodeQenPath) void EffectMakerModel::addNode(const QString &nodeQenPath)
{ {
beginInsertRows({}, m_nodes.size(), m_nodes.size()); beginInsertRows({}, m_nodes.size(), m_nodes.size());
auto *node = new CompositionNode(nodeQenPath); auto *node = new CompositionNode(nodeQenPath);
m_nodes.append(node); m_nodes.append(node);
endInsertRows(); endInsertRows();
setIsEmpty(false);
} }
void EffectMakerModel::moveNode(int fromIdx, int toIdx) void EffectMakerModel::moveNode(int fromIdx, int toIdx)
@@ -82,6 +92,9 @@ void EffectMakerModel::removeNode(int idx)
m_nodes.removeAt(idx); m_nodes.removeAt(idx);
delete node; delete node;
endRemoveRows(); endRemoveRows();
if (m_nodes.isEmpty())
setIsEmpty(true);
} }
const QList<Uniform *> EffectMakerModel::allUniforms() const QList<Uniform *> EffectMakerModel::allUniforms()

View File

@@ -43,6 +43,7 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role) override; bool setData(const QModelIndex &index, const QVariant &value, int role) override;
bool isEmpty() const { return m_isEmpty; } bool isEmpty() const { return m_isEmpty; }
void setIsEmpty(bool val);
void addNode(const QString &nodeQenPath); void addNode(const QString &nodeQenPath);