Fix geometry effects sometimes incorrectly focused on click

parent a78d04de
Pipeline #15368 passed with stage
in 18 minutes and 25 seconds
......@@ -337,10 +337,10 @@ bool CollapsibleEffectView::isEnabled() const
return m_enabledButton->isActive();
}
void CollapsibleEffectView::slotActivateEffect(QModelIndex ix)
void CollapsibleEffectView::slotActivateEffect(QModelIndex ix, bool active)
{
// m_colorIcon->setEnabled(active);
bool active = ix.row() == m_model->row();
// bool active = ix.row() == m_model->row();
decoframe->setProperty("active", active);
decoframe->setStyleSheet(decoframe->styleSheet());
if (active) {
......
......@@ -88,7 +88,7 @@ public slots:
void slotDisable(bool disable);
void slotResetEffect();
void importKeyframes(const QString &keyframes);
void slotActivateEffect(QModelIndex ix);
void slotActivateEffect(QModelIndex ix, bool active);
void updateHeight();
/** @brief Should we block wheel event (if parent is a view with scrollbar) */
void blockWheenEvent(bool block);
......
......@@ -212,6 +212,7 @@ void EffectStackView::loadEffects()
return;
}
int active = qBound(0, m_model->getActiveEffect(), max - 1);
QModelIndex activeIndex;
for (int i = 0; i < max; i++) {
std::shared_ptr<AbstractEffectItem> item = m_model->getEffectStackRow(i);
QSize size;
......@@ -237,7 +238,7 @@ void EffectStackView::loadEffects()
int clipIn = pCore->getItemPosition(m_model->getOwnerId());
emit seekToPos(pos + clipIn);
});
connect(this, &EffectStackView::doActivateEffect, view, &CollapsibleEffectView::slotActivateEffect);
//connect(this, &EffectStackView::doActivateEffect, view, &CollapsibleEffectView::slotActivateEffect);
connect(this, &EffectStackView::switchCollapsedView, view, &CollapsibleEffectView::switchCollapsed);
QModelIndex ix = m_model->getIndexFromItem(effectModel);
m_effectsTree->setIndexWidget(ix, view);
......@@ -247,9 +248,12 @@ void EffectStackView::loadEffects()
view->buttonDown->setEnabled(i < max - 1);
if (i == active) {
m_model->setActiveEffect(i);
emit doActivateEffect(ix);
activeIndex = ix;
}
}
if (activeIndex.isValid()) {
doActivateEffect(activeIndex);
}
updateTreeHeight();
qDebug() << "MUTEX UNLOCK!!!!!!!!!!!! loadEffects";
}
......@@ -279,7 +283,7 @@ void EffectStackView::slotActivateEffect(const std::shared_ptr<EffectItemModel>
QMutexLocker lock(&m_mutex);
m_model->setActiveEffect(effectModel->row());
QModelIndex activeIx = m_model->getIndexFromItem(effectModel);
emit doActivateEffect(activeIx);
doActivateEffect(activeIx);
qDebug() << "MUTEX UNLOCK!!!!!!!!!!!! slotactivateeffect";
}
......@@ -410,6 +414,30 @@ void EffectStackView::switchCollapsed()
}
}
void EffectStackView::doActivateEffect(QModelIndex activeIx)
{
int max = m_model->rowCount();
for (int i = 0; i < max; ++i) {
auto item = m_model->getEffectStackRow(i);
if (item->childCount() > 0) {
// TODO: group
continue;
}
std::shared_ptr<EffectItemModel> eff = std::static_pointer_cast<EffectItemModel>(item);
QModelIndex ix = m_model->getIndexFromItem(eff);
if (ix != activeIx) {
CollapsibleEffectView *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(ix));
if (w) {
w->slotActivateEffect(ix, false);
}
}
}
CollapsibleEffectView *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(activeIx));
if (w) {
w->slotActivateEffect(activeIx, true);
}
}
/*
void EffectStackView::switchBuiltStack(bool show)
{
......
......@@ -104,11 +104,11 @@ private slots:
void slotActivateEffect(const std::shared_ptr<EffectItemModel> &effectModel);
void loadEffects();
void updateTreeHeight();
void doActivateEffect(QModelIndex);
// void switchBuiltStack(bool show);
signals:
void doActivateEffect(QModelIndex);
void switchCollapsedView(int row);
void seekToPos(int);
void reloadEffect(const QString &path);
......
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