Fix Fade out broken on resized title/color/image clips

BUG: 363538
parent f23e07f9
......@@ -640,7 +640,7 @@ void ProjectClip::setProperties(QMap <QString, QString> properties, bool refresh
reload = true;
}
if (refreshAnalysis) emit refreshAnalysisPanel();
if (properties.contains(QStringLiteral("length"))) {
if (properties.contains(QStringLiteral("length")) || properties.contains(QStringLiteral("kdenlive:duration"))) {
m_duration = m_controller->getStringDuration();
bin()->emitItemUpdated(this);
}
......
......@@ -292,12 +292,22 @@ Mlt::Producer *ClipController::getTrackProducer(const QString trackName, Playlis
const QString ClipController::getStringDuration()
{
if (m_masterProducer) return m_masterProducer->get_length_time(mlt_time_smpte);
if (m_masterProducer) {
int playtime = m_masterProducer->get_int("kdenlive:duration");
if (playtime > 0) {
return QString(properties().frames_to_time(playtime, mlt_time_smpte));
}
return m_masterProducer->get_length_time(mlt_time_smpte);
}
return QString(i18n("Unknown"));
}
GenTime ClipController::getPlaytime() const
{
if (!m_hasLimitedDuration) {
int playtime = m_masterProducer->get_int("kdenlive:duration");
return GenTime(playtime == 0 ? m_masterProducer->get_playtime() : playtime, m_binController->fps());
}
return GenTime(m_masterProducer->get_playtime(), m_binController->fps());
}
......
......@@ -238,6 +238,9 @@ ClipPropertiesController::ClipPropertiesController(Timecode tc, ClipController *
if (m_type == Color || m_type == Image || m_type == AV || m_type == Video || m_type == TextTemplate) {
// Edit duration widget
m_originalProperties.insert(QStringLiteral("out"), m_properties.get("out"));
int kdenlive_length = m_properties.get_int("kdenlive:duration");
if (kdenlive_length > 0)
m_originalProperties.insert(QStringLiteral("kdenlive:duration"), QString::number(kdenlive_length));
m_originalProperties.insert(QStringLiteral("length"), m_properties.get("length"));
QHBoxLayout *hlay = new QHBoxLayout;
QCheckBox *box = new QCheckBox(i18n("Duration"), this);
......@@ -245,7 +248,7 @@ ClipPropertiesController::ClipPropertiesController(Timecode tc, ClipController *
hlay->addWidget(box);
TimecodeDisplay *timePos = new TimecodeDisplay(tc, this);
timePos->setObjectName(QStringLiteral("force_duration_value"));
timePos->setValue(m_properties.get_int("out") + 1);
timePos->setValue(kdenlive_length > 0 ? kdenlive_length : m_properties.get_int("length"));
int original_length = m_properties.get_int("kdenlive:original_length");
if (original_length > 0) {
box->setChecked(true);
......@@ -577,11 +580,23 @@ void ClipPropertiesController::slotDurationChanged(int duration)
{
QMap <QString, QString> properties;
int original_length = m_properties.get_int("kdenlive:original_length");
// kdenlive_length is the default duration for image / title clips
int kdenlive_length = m_properties.get_int("kdenlive:duration");
int current_length = m_properties.get_int("length");
if (original_length == 0) {
m_properties.set("kdenlive:original_length", m_properties.get_int("length"));
m_properties.set("kdenlive:original_length", kdenlive_length > 0 ? kdenlive_length : current_length);
}
if (kdenlive_length > 0) {
// special case, image/title clips store default duration in kdenlive:duration property
properties.insert(QStringLiteral("kdenlive:duration"), QString::number(duration));
if (duration > current_length) {
properties.insert(QStringLiteral("length"), QString::number(duration));
properties.insert(QStringLiteral("out"), QString::number(duration - 1));
}
} else {
properties.insert(QStringLiteral("length"), QString::number(duration));
properties.insert(QStringLiteral("out"), QString::number(duration - 1));
}
properties.insert(QStringLiteral("length"), QString::number(duration));
properties.insert(QStringLiteral("out"), QString::number(duration - 1));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
}
......@@ -624,7 +639,8 @@ void ClipPropertiesController::slotEnableForce(int state)
if (param == QLatin1String("force_duration")) {
int original_length = m_properties.get_int("kdenlive:original_length");
if (original_length == 0) {
m_properties.set("kdenlive:original_length", m_properties.get_int("length"));
int kdenlive_duration = m_properties.get_int("kdenlive:duration");
m_properties.set("kdenlive:original_length", kdenlive_duration > 0 ? kdenlive_duration : m_properties.get_int("length"));
}
}
else if (param == QLatin1String("force_fps")) {
......
......@@ -431,6 +431,9 @@ void ProducerQueue::processFileProperties()
}
if (duration == 0) duration = length;
producer->set("length", length);
int kdenlive_duration = EffectsList::property(info.xml, QStringLiteral("kdenlive:duration")).toInt();
producer->set("kdenlive:duration", kdenlive_duration > 0 ? kdenlive_duration : length);
}
if (clipOut > 0) {
producer->set_in_and_out(info.xml.attribute(QStringLiteral("in")).toInt(), clipOut);
......
......@@ -213,6 +213,7 @@ bool Track::resize(qreal t, qreal dt, bool end)
if (in < 0) {out -= in; in = 0;}
if (clip->get_length() < out + 1) {
clip->parent().set("length", out + 2);
clip->parent().set("out", out + 1);
clip->set("length", out + 2);
}
......
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