Commit 4d0c9d43 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Convert old custom effects to new customAudio/Video naming

Related to #336
parent 90d5443c
Pipeline #7088 passed with stage
in 19 minutes and 22 seconds
......@@ -84,7 +84,7 @@ protected:
bool parseInfoFromMlt(const QString &assetId, Info &res);
/* @brief Returns the metadata associated with the given asset*/
virtual Mlt::Properties *getMetadata(const QString &assetId) = 0;
virtual Mlt::Properties *getMetadata(const QString &assetId) const = 0;
/* @brief Parse one asset from its XML content
@param res data structure to fill
......
......@@ -72,7 +72,7 @@ void EffectListWidget::setFilterType(const QString &type)
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Audio);
} else if (type == "customAudio") {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::CustomAudio);
} else if (type == "custom") {
} else if (type == "customVideo") {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Custom);
} else if (type == "favorites") {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Favorites);
......
......@@ -61,7 +61,7 @@ Mlt::Properties *EffectsRepository::retrieveListFromMlt() const
return pCore->getMltRepository()->filters();
}
Mlt::Properties *EffectsRepository::getMetadata(const QString &effectId)
Mlt::Properties *EffectsRepository::getMetadata(const QString &effectId) const
{
return pCore->getMltRepository()->metadata(filter_type, effectId.toLatin1().data());
}
......@@ -121,12 +121,31 @@ void EffectsRepository::parseCustomAssetFile(const QString &file_name, std::unor
QString type = currentEffect.attribute(QStringLiteral("type"), QString());
if (type == QLatin1String("audio")) {
result.type = EffectType::Audio;
} else if (type == QLatin1String("custom")) {
} else if (type == QLatin1String("customVideo")) {
result.type = EffectType::Custom;
} else if (type == QLatin1String("customAudio")) {
result.type = EffectType::CustomAudio;
} else if (type == QLatin1String("hidden")) {
result.type = EffectType::Hidden;
} else if (type == QLatin1String("custom")) {
// Old type effect, update to customVideo / customAudio
const QString effectTag = currentEffect.attribute(QStringLiteral("tag"));
QScopedPointer<Mlt::Properties> metadata(getMetadata(effectTag));
if (metadata && metadata->is_valid()) {
Mlt::Properties tags((mlt_properties)metadata->get_data("tags"));
if (QString(tags.get(0)) == QLatin1String("Audio")) {
result.type = EffectType::CustomAudio;
currentEffect.setAttribute(QStringLiteral("type"), QStringLiteral("customAudio"));
} else {
result.type = EffectType::Custom;
currentEffect.setAttribute(QStringLiteral("type"), QStringLiteral("customVideo"));
}
QFile effectFile(file_name);
if (effectFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
effectFile.write(doc.toString().toUtf8());
}
file.close();
}
} else {
result.type = EffectType::Video;
}
......
......@@ -81,7 +81,7 @@ protected:
void parseType(QScopedPointer<Mlt::Properties> &metadata, Info &res) override;
/* @brief Returns the metadata associated with the given asset*/
Mlt::Properties *getMetadata(const QString &assetId) override;
Mlt::Properties *getMetadata(const QString &assetId) const override;
QPair <QString, QString> fixCustomAssetFile(const QString &path);
......
......@@ -433,7 +433,7 @@ void CollapsibleEffectView::slotSaveEffect()
effect.removeAttribute(QStringLiteral("kdenlive_ix"));
effect.setAttribute(QStringLiteral("id"), name);
QString masterType = effect.attribute(QLatin1String("type"));
effect.setAttribute(QStringLiteral("type"), (masterType == QLatin1String("audio") || masterType == QLatin1String("customAudio")) ? QStringLiteral("customAudio") : QStringLiteral("custom"));
effect.setAttribute(QStringLiteral("type"), (masterType == QLatin1String("audio") || masterType == QLatin1String("customAudio")) ? QStringLiteral("customAudio") : QStringLiteral("customVideo"));
/*
if (m_paramWidget) {
int in = m_paramWidget->range().x();
......
......@@ -60,7 +60,7 @@ Mlt::Properties *TransitionsRepository::retrieveListFromMlt() const
return pCore->getMltRepository()->transitions();
}
Mlt::Properties *TransitionsRepository::getMetadata(const QString &assetId)
Mlt::Properties *TransitionsRepository::getMetadata(const QString &assetId) const
{
return pCore->getMltRepository()->metadata(transition_type, assetId.toLatin1().data());
}
......
......@@ -77,7 +77,7 @@ protected:
void parseType(QScopedPointer<Mlt::Properties> &metadata, Info &res) override;
/* @brief Returns the metadata associated with the given asset*/
Mlt::Properties *getMetadata(const QString &assetId) override;
Mlt::Properties *getMetadata(const QString &assetId) const override;
/* @brief Returns all transitions that can be represented as Single Track Transitions*/
static QSet<QString> getSingleTrackTransitions();
......
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