diff --git a/app/dialog/speedduration/speeddurationdialog.cpp b/app/dialog/speedduration/speeddurationdialog.cpp index cf6af022a..e742487a2 100644 --- a/app/dialog/speedduration/speeddurationdialog.cpp +++ b/app/dialog/speedduration/speeddurationdialog.cpp @@ -155,6 +155,34 @@ void SpeedDurationDialog::accept() MultiUndoCommand *command = new MultiUndoCommand(); + // Set duration values + foreach (ClipBlock *c, clips_) { + rational proposed_length = c->length(); + + if (dur_slider_->IsTristate()) { + if (link_box_->isChecked() && !speed_slider_->IsTristate()) { + proposed_length = GetLengthAdjustment(c->length(), c->speed(), speed_slider_->GetValue(), timebase_); + } + } else { + proposed_length = dur_slider_->GetValue(); + } + + if (proposed_length != c->length()) { + // Clip length should ideally change, but check if there's "room" to do so + if (proposed_length > c->length() && c->next()) { + if (GapBlock *gap = dynamic_cast(c->next())) { + proposed_length = qMin(proposed_length, gap->out() - c->in()); + } else { + proposed_length = c->length(); + } + } + + if (proposed_length != c->length()) { + command->add_child(new BlockTrimCommand(c->track(), c, proposed_length, Timeline::kTrimOut)); + } + } + } + // Set speed values if (speed_slider_->IsTristate()) { if (link_box_->isChecked() && !dur_slider_->IsTristate()) { @@ -184,34 +212,6 @@ void SpeedDurationDialog::accept() } } - // Set duration values - foreach (ClipBlock *c, clips_) { - rational proposed_length = c->length(); - - if (dur_slider_->IsTristate()) { - if (link_box_->isChecked() && !speed_slider_->IsTristate()) { - proposed_length = GetLengthAdjustment(c->length(), c->speed(), speed_slider_->GetValue(), timebase_); - } - } else { - proposed_length = dur_slider_->GetValue(); - } - - if (proposed_length != c->length()) { - // Clip length should ideally change, but check if there's "room" to do so - if (proposed_length > c->length() && c->next()) { - if (GapBlock *gap = dynamic_cast(c->next())) { - proposed_length = qMin(proposed_length, gap->out() - c->in()); - } else { - proposed_length = c->length(); - } - } - - if (proposed_length != c->length()) { - command->add_child(new BlockTrimCommand(c->track(), c, proposed_length, Timeline::kTrimOut)); - } - } - } - Core::instance()->undo_stack()->push(command); super::accept();