Make delete key work on effect stack

parent 6fb37452
......@@ -352,3 +352,10 @@ void AssetPanel::enableStack(bool enable)
}
m_effectStackWidget->enableStack(enable);
}
void AssetPanel::deleteCurrentEffect()
{
if (m_effectStackWidget->isVisible()) {
m_effectStackWidget->removeCurrentEffect();
}
}
......@@ -70,6 +70,7 @@ public slots:
/** @brief Clear panel if displaying itemId */
void clearAssetPanel(int itemId);
void parameterChanged(QString name, int value);
void deleteCurrentEffect();
protected:
/** @brief Return the stylesheet used to display the panel (based on current palette). */
......
......@@ -585,11 +585,8 @@ void Core::invalidateItem(ObjectId itemId)
if (!m_mainWindow || m_mainWindow->getCurrentTimeline()->loading) return;
switch (itemId.first) {
case ObjectType::TimelineClip:
m_mainWindow->getCurrentTimeline()->controller()->invalidateItem(itemId.second);
case ObjectType::TimelineComposition:
if (m_mainWindow->getCurrentTimeline()->controller()->getModel()->isComposition(itemId.second)) {
m_mainWindow->getCurrentTimeline()->controller()->invalidateItem(itemId.second);
}
m_mainWindow->getCurrentTimeline()->controller()->invalidateItem(itemId.second);
break;
case ObjectType::TimelineTrack:
// TODO: invalidate all clips in track
......
......@@ -85,6 +85,21 @@ void EffectStackModel::removeService(std::shared_ptr<Mlt::Service> service)
}
}
void EffectStackModel::removeCurrentEffect()
{
int ix = 0;
if (auto ptr = m_services.front().lock()) {
ix = ptr->get_int("kdenlive:activeeffect");
}
if (ix < 0) {
return;
}
std::shared_ptr<EffectItemModel> effect = std::static_pointer_cast<EffectItemModel>(rootItem->child(ix));
if (effect) {
removeEffect(effect);
}
}
void EffectStackModel::removeEffect(std::shared_ptr<EffectItemModel> effect)
{
QWriteLocker locker(&m_lock);
......
......@@ -135,6 +135,8 @@ public:
QDomElement toXml(QDomDocument &document);
/* @brief Load an effect stack from an XML representation */
void fromXml(const QDomElement &effectsXml, Fun &undo, Fun &redo);
/* @brief Delete active effect from stack */
void removeCurrentEffect();
public slots:
/* @brief Delete an effect from the stack */
......
......@@ -182,6 +182,7 @@ void EffectStackView::setModel(std::shared_ptr<EffectStackModel> model, const QS
loadEffects();
connect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh);
connect(m_model.get(), &EffectStackModel::enabledStateChanged, this, &EffectStackView::updateEnabledState);
connect(this, &EffectStackView::removeCurrentEffect, m_model.get(), &EffectStackModel::removeCurrentEffect);
// m_builtStack->setModel(model, stackOwner());
}
......@@ -319,6 +320,7 @@ void EffectStackView::unsetModel(bool reset)
ObjectId item = m_model->getOwnerId();
id = item.first == ObjectType::BinClip ? Kdenlive::ClipMonitor : Kdenlive::ProjectMonitor;
disconnect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh);
disconnect(this, &EffectStackView::removeCurrentEffect, m_model.get(), &EffectStackModel::removeCurrentEffect);
}
if (reset) {
QMutexLocker lock(&m_mutex);
......
......@@ -105,6 +105,7 @@ signals:
void seekToPos(int);
void reloadEffect(const QString &path);
void updateEnabledState();
void removeCurrentEffect();
};
#endif
......@@ -2158,8 +2158,7 @@ void MainWindow::slotDeleteItem()
QWidget *widget = QApplication::focusWidget();
while ((widget != nullptr) && widget != this) {
if (widget == m_effectStackDock) {
// TODO refac: reimplement
// m_effectStack->deleteCurrentEffect();
m_assetPanel->deleteCurrentEffect();
return;
}
widget = widget->parentWidget();
......
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