mirror of
https://invent.kde.org/multimedia/kdenlive
synced 2025-12-05 15:59:59 +01:00
When copy/paste between 2 kdenlive windows, correctly load bin clip effects
This commit is contained in:
@@ -386,6 +386,28 @@ QDomElement EffectStackModel::rowToXml(int row, QDomDocument &document)
|
||||
return container;
|
||||
}
|
||||
|
||||
bool EffectStackModel::fromMltXml(const QDomElement &effectsXml)
|
||||
{
|
||||
QDomNodeList nodeList = effectsXml.elementsByTagName(QStringLiteral("filter"));
|
||||
for (int i = 0; i < nodeList.count(); ++i) {
|
||||
QDomElement node = nodeList.item(i).toElement();
|
||||
if (!Xml::hasXmlProperty(node, QStringLiteral("kdenlive_id")) || Xml::hasXmlProperty(node, QStringLiteral("internal_added"))) {
|
||||
// Internal effect, ignore
|
||||
continue;
|
||||
}
|
||||
if (Xml::hasXmlProperty(node, QStringLiteral("kdenlive:builtin")) && Xml::getXmlProperty(node, QStringLiteral("disable")) == QLatin1String("1")) {
|
||||
// Disabled built-in effect, ignore
|
||||
continue;
|
||||
}
|
||||
const QString effectId = Xml::getXmlProperty(node, QStringLiteral("kdenlive_id"));
|
||||
Fun undo = []() { return true; };
|
||||
Fun redo = []() { return true; };
|
||||
stringMap params = Xml::getXmlPropertyByWildcard(node, QString());
|
||||
doAppendEffect(effectId, false, params, undo, redo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EffectStackModel::fromXml(const QDomElement &effectsXml, Fun &undo, Fun &redo)
|
||||
{
|
||||
QDomNodeList nodeList = effectsXml.elementsByTagName(QStringLiteral("effect"));
|
||||
|
||||
@@ -137,6 +137,8 @@ public:
|
||||
QDomElement rowToXml(int row, QDomDocument &document);
|
||||
/** @brief Load an effect stack from an XML representation */
|
||||
bool fromXml(const QDomElement &effectsXml, Fun &undo, Fun &redo);
|
||||
/** @brief Load an effect stack from an MLT XML representation */
|
||||
bool fromMltXml(const QDomElement &effectsXml);
|
||||
/** @brief Delete active effect from stack */
|
||||
void removeCurrentEffect();
|
||||
|
||||
|
||||
@@ -69,6 +69,9 @@ ClipController::ClipController(const QString &clipId, const std::shared_ptr<Mlt:
|
||||
} else {
|
||||
m_controlUuid = QUuid::createUuid();
|
||||
}
|
||||
if (description.elementsByTagName(QStringLiteral("filter")).count() > 0) {
|
||||
m_effectsToLoad = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,13 +126,19 @@ void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &pro
|
||||
if (!m_masterProducer->is_valid()) {
|
||||
m_masterProducer = std::shared_ptr<Mlt::Producer>(pCore->mediaUnavailable->cut());
|
||||
qCDebug(KDENLIVE_LOG) << "// WARNING, USING INVALID PRODUCER";
|
||||
} else {
|
||||
connectEffectStack();
|
||||
return;
|
||||
}
|
||||
setProducerProperty(QStringLiteral("kdenlive:id"), m_controllerBinId);
|
||||
if (!m_properties->property_exists("kdenlive:control_uuid")) {
|
||||
m_properties->set("kdenlive:control_uuid", m_controlUuid.toString().toUtf8().constData());
|
||||
}
|
||||
getInfoForProducer();
|
||||
checkAudioVideo();
|
||||
if (!m_effectsToLoad.isNull()) {
|
||||
m_effectStack->fromMltXml(m_effectsToLoad);
|
||||
m_effectsToLoad.clear();
|
||||
}
|
||||
if (!m_hasMultipleVideoStreams && m_service.startsWith(QLatin1String("avformat")) && (m_clipType == ClipType::AV || m_clipType == ClipType::Video)) {
|
||||
// Check if clip has multiple video streams
|
||||
QList<int> videoStreams;
|
||||
@@ -174,7 +183,6 @@ void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &pro
|
||||
Q_ARG(QList<int>, videoStreams), Q_ARG(QList<int>, audioStreams));
|
||||
}
|
||||
}
|
||||
}
|
||||
connectEffectStack();
|
||||
}
|
||||
|
||||
|
||||
@@ -251,6 +251,7 @@ private:
|
||||
/** @brief Temporarily store clip properties until producer is available */
|
||||
QMap <QString, QVariant> m_tempProps;
|
||||
QString m_controllerBinId;
|
||||
QDomElement m_effectsToLoad;
|
||||
/** @brief Build the audio info object */
|
||||
void buildAudioInfo(int audioIndex);
|
||||
};
|
||||
|
||||
@@ -218,7 +218,7 @@ QMap<QString, QString> Xml::getXmlPropertyByWildcard(const QDomElement &element,
|
||||
QDomNodeList params = element.elementsByTagName(QStringLiteral("property"));
|
||||
for (int i = 0; i < params.count(); ++i) {
|
||||
QDomElement e = params.item(i).toElement();
|
||||
if (e.attribute(QStringLiteral("name")).startsWith(propertyName)) {
|
||||
if (propertyName.isEmpty() || e.attribute(QStringLiteral("name")).startsWith(propertyName)) {
|
||||
props.insert(e.attribute(QStringLiteral("name")), e.text());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user