Commit c5e507ea authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Merge branch '1908'

parents d40d5e07 4d0c9d43
......@@ -83,7 +83,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;
}
......
......@@ -79,7 +79,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);
......
......@@ -431,7 +431,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();
......
......@@ -769,7 +769,7 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
}
}
int blank_length = getTrackById(trackId)->getBlankSizeNearClip(clipId, after);
int blank_length = getTrackById_const(trackId)->getBlankSizeNearClip(clipId, after);
qDebug() << "Found blank" << blank_length;
if (blank_length < INT_MAX) {
if (after) {
......@@ -785,6 +785,11 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
TRACE_RES(possible ? position : currentPos);
return possible ? position : currentPos;
}
if (trackId != sourceTrackId) {
// Try same track move
possible = requestClipMove(clipId, sourceTrackId, position, moveMirrorTracks, true, false, false);
return possible ? position : currentPos;
}
// find best pos for groups
int groupId = m_groups->getRootId(clipId);
std::unordered_set<int> all_items = m_groups->getLeaves(groupId);
......@@ -814,26 +819,34 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
trackPosition.insert(clipTrack, after ? in + getItemPlaytime(current_clipId) - 1 : in);
}
}
// Now check space on each track
QMapIterator<int, int> i(trackPosition);
int blank_length = -1;
int blank_length = 0;
while (i.hasNext()) {
i.next();
int track_space;
if (!after) {
// Check space before the position
track_space = i.value() - getTrackById(i.key())->getBlankStart(i.value() - 1);
if (blank_length == -1 || blank_length > track_space) {
track_space = i.value() - getTrackById_const(i.key())->getBlankStart(i.value() - 1);
if (blank_length == 0 || blank_length > track_space) {
blank_length = track_space;
}
} else {
// Check space after the position
track_space = getTrackById(i.key())->getBlankEnd(i.value() + 1) - i.value() - 1;
if (blank_length == -1 || blank_length > track_space) {
if (blank_length == 0 || blank_length > track_space) {
blank_length = track_space;
}
}
}
if (snapDistance > 0) {
if (blank_length > 10 * snapDistance) {
blank_length = 0;
}
} else if (blank_length / m_profile->fps() > 5) {
blank_length = 0;
}
if (blank_length != 0) {
int updatedPos = currentPos + (after ? blank_length : -blank_length);
possible = requestClipMove(clipId, trackId, updatedPos, moveMirrorTracks, true, false, false);
......
......@@ -58,7 +58,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