Fix monitor scene not correctly showing/hiding on enable/disable effect

parent 3eb8ca51
......@@ -66,7 +66,7 @@ void AbstractEffectItem::setEffectStackEnabled(bool enabled)
for (int i = 0; i < childCount(); ++i) {
std::static_pointer_cast<AbstractEffectItem>(child(i))->setEffectStackEnabled(enabled);
}
updateEnable();
updateEnable(false);
}
bool AbstractEffectItem::isEnabled() const
......
......@@ -65,7 +65,7 @@ public:
protected:
/* @brief Toogles the mlt effect according to the current activation state*/
virtual void updateEnable() = 0;
virtual void updateEnable(bool updateTimeline = true) = 0;
EffectItemType m_effectItemType;
bool m_enabled;
......
......@@ -43,8 +43,9 @@ std::shared_ptr<EffectGroupModel> EffectGroupModel::construct(const QString &nam
return self;
}
void EffectGroupModel::updateEnable()
void EffectGroupModel::updateEnable(bool updateTimeline)
{
Q_UNUSED(updateTimeline);
for (int i = 0; i < childCount(); ++i) {
std::static_pointer_cast<AbstractEffectItem>(child(i))->updateEnable();
}
......
......@@ -52,7 +52,7 @@ public:
protected:
EffectGroupModel(const QList<QVariant> &data, QString name, const std::shared_ptr<AbstractTreeModel> &stack, bool isRoot = false);
void updateEnable() override;
void updateEnable(bool updateTimeline = true) override;
QString m_name;
};
......
......@@ -191,11 +191,13 @@ bool EffectItemModel::isValid() const
return m_asset && m_asset->is_valid();
}
void EffectItemModel::updateEnable()
void EffectItemModel::updateEnable(bool updateTimeline)
{
filter().set("disable", isEnabled() ? 0 : 1);
pCore->refreshProjectItem(m_ownerId);
pCore->invalidateItem(m_ownerId);
if (updateTimeline) {
pCore->refreshProjectItem(m_ownerId);
pCore->invalidateItem(m_ownerId);
}
const QModelIndex start = AssetParameterModel::index(0, 0);
const QModelIndex end = AssetParameterModel::index(rowCount() - 1, 0);
emit dataChanged(start, end, QVector<int>());
......
......@@ -66,7 +66,7 @@ protected:
EffectItemModel(const QList<QVariant> &effectData, std::unique_ptr<Mlt::Properties> effect, const QDomElement &xml, const QString &effectId,
const std::shared_ptr<AbstractTreeModel> &stack, bool isEnabled = true);
QMap<int, std::shared_ptr<EffectItemModel>> m_childEffects;
void updateEnable() override;
void updateEnable(bool updateTimeline = true) override;
int m_childId;
};
......
......@@ -848,11 +848,19 @@ void EffectStackModel::setEffectStackEnabled(bool enabled)
QWriteLocker locker(&m_lock);
m_effectStackEnabled = enabled;
QList<QModelIndex> indexes;
// Recursively updates children states
for (int i = 0; i < rootItem->childCount(); ++i) {
std::static_pointer_cast<AbstractEffectItem>(rootItem->child(i))->setEffectStackEnabled(enabled);
std::shared_ptr<AbstractEffectItem> item = std::static_pointer_cast<AbstractEffectItem>(rootItem->child(i));
item->setEffectStackEnabled(enabled);
indexes << getIndexFromItem(item);
}
emit dataChanged(QModelIndex(), QModelIndex(), {TimelineModel::EffectsEnabledRole});
if (indexes.isEmpty()) {
return;
}
pCore->refreshProjectItem(m_ownerId);
pCore->invalidateItem(m_ownerId);
emit dataChanged(indexes.first(), indexes.last(), {TimelineModel::EffectsEnabledRole});
emit enabledStateChanged();
}
......
......@@ -400,9 +400,17 @@ void CollapsibleEffectView::slotDisable(bool disable)
QString effectId = m_model->getAssetId();
QString effectName = EffectsRepository::get()->getName(effectId);
std::static_pointer_cast<AbstractEffectItem>(m_model)->markEnabled(effectName, !disable);
pCore->getMonitor(m_model->monitorId)->slotShowEffectScene(needsMonitorEffectScene());
m_view->initKeyframeView(!disable);
emit activateEffect(m_model);
}
void CollapsibleEffectView::updateScene()
{
pCore->getMonitor(m_model->monitorId)->slotShowEffectScene(needsMonitorEffectScene());
m_view->initKeyframeView(m_model->isEnabled());
}
void CollapsibleEffectView::slotDeleteEffect()
{
emit deleteEffect(m_model);
......
......@@ -84,6 +84,8 @@ public:
bool isMovable() const;
/** @brief Returns the effect in xml format for saving. */
QDomDocument toXml() const;
/** @brief Update monitor scene depending on effect enabled state. */
void updateScene();
public slots:
void slotSyncEffectsPos(int pos);
......
......@@ -200,7 +200,17 @@ void EffectStackView::setModel(std::shared_ptr<EffectStackModel> model, const QS
loadEffects();
m_scrollTimer.start();
connect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh);
connect(m_model.get(), &EffectStackModel::enabledStateChanged, this, &EffectStackView::updateEnabledState);
connect(m_model.get(), &EffectStackModel::enabledStateChanged, [this]() {
int max = m_model->rowCount();
int currentActive = m_model->getActiveEffect();
if (currentActive < max && currentActive > -1) {
auto item = m_model->getEffectStackRow(currentActive);
QModelIndex ix = m_model->getIndexFromItem(item);
CollapsibleEffectView *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(ix));
w->updateScene();
}
emit updateEnabledState();
});
connect(this, &EffectStackView::removeCurrentEffect, m_model.get(), &EffectStackModel::removeCurrentEffect);
// m_builtStack->setModel(model, stackOwner());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment