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

Add option to seek to clip on add effect (enabled by default, can be disabled...

Add option to seek to clip on add effect (enabled by default, can be disabled from Kdenlive Settings > timeline)
Fixes #703 #1218
parent 00c38496
Pipeline #148124 passed with stage
in 5 minutes and 26 seconds
......@@ -1174,6 +1174,10 @@ void KdenliveSettingsDialog::updateSettings()
if (m_configTimeline.kcfg_pauseonseek->isChecked() != KdenliveSettings::pauseonseek()) {
KdenliveSettings::setPauseonseek(m_configTimeline.kcfg_pauseonseek->isChecked());
}
if (m_configTimeline.kcfg_seekonaddeffect->isChecked() != KdenliveSettings::seekonaddeffect()) {
KdenliveSettings::setSeekonaddeffect(m_configTimeline.kcfg_seekonaddeffect->isChecked());
}
if (m_configTimeline.kcfg_scrollvertically->isChecked() != KdenliveSettings::scrollvertically()) {
KdenliveSettings::setScrollvertically(m_configTimeline.kcfg_scrollvertically->isChecked());
......
......@@ -371,9 +371,9 @@
<default>true</default>
</entry>
<entry name="verticalzoom" type="Bool">
<label>Vertical drag in timeline ruler zooms.</label>
<default>false</default>
<entry name="seekonaddeffect" type="Bool">
<label>Seek to clip when adding an effect.</label>
<default>true</default>
</entry>
<entry name="scrollvertically" type="Bool">
......
......@@ -460,3 +460,8 @@ const QPoint MonitorProxy::clipBoundary(int ix)
return m_clipBounds.at(ix);
}
bool MonitorProxy::seekOnDrop() const
{
return KdenliveSettings::seekonaddeffect();
}
......@@ -101,6 +101,7 @@ public:
Q_INVOKABLE void switchAutoKeyframe();
Q_INVOKABLE bool autoKeyframe() const;
Q_INVOKABLE void setWidgetKeyBinding(const QString &text = QString()) const;
Q_INVOKABLE bool seekOnDrop() const;
QPoint profile();
void setClipProperties(int clipId, ClipType::ProducerType type, bool hasAV, const QString &clipName);
void setAudioThumb(const QList <int> &streamIndexes = QList <int>(), const QList <int> &channels = QList <int>());
......
......@@ -267,9 +267,13 @@ Rectangle {
console.log("Add effect: ", dropData)
if (dropSource == '') {
// drop from effects list
controller.addClipEffect(clipRoot.clipId, dropData);
controller.addClipEffect(clipRoot.clipId, dropData)
if (proxy.seekOnDrop() && (proxy.position < clipRoot.modelStart || proxy.position > clipRoot.modelStart + clipRoot.clipDuration)) {
// If timeline cursor is not inside clip, seek to drop position
proxy.position = clipRoot.modelStart + drag.x / timeScale
}
} else {
controller.copyClipEffect(clipRoot.clipId, dropSource);
controller.copyClipEffect(clipRoot.clipId, dropSource)
}
dropSource = ''
dropRow = -1
......
......@@ -1284,6 +1284,8 @@ void TimelineController::addAsset(const QVariantMap &data)
QString effect = data.value(QStringLiteral("kdenlive/effect")).toString();
const auto selection = m_model->getCurrentSelection();
bool audioEffect = EffectsRepository::get()->isAudioEffect(effect);
int affectedClips = 0;
int cid = -1;
if (!selection.empty()) {
QList<int> effectSelection;
for (int id : selection) {
......@@ -1291,15 +1293,23 @@ void TimelineController::addAsset(const QVariantMap &data)
effectSelection << id;
}
}
bool foundMatch = false;
for (int id : qAsConst(effectSelection)) {
if (m_model->addClipEffect(id, effect, false)) {
foundMatch = true;
cid = id;
affectedClips++;
}
}
if (!foundMatch) {
if (affectedClips == 0) {
QString effectName = EffectsRepository::get()->getName(effect);
pCore->displayMessage(i18n("Cannot add effect %1 to selected clip", effectName), ErrorMessage, 500);
} else if (KdenliveSettings::seekonaddeffect() && effectSelection.count() == 1) {
// Move timeline cursor inside clip if it is not
int in = m_model->getClipPosition(cid);
int out = in + m_model->getClipPlaytime(cid);
int position = pCore->getTimelinePosition();
if (position < in || position > out) {
emit seeked(in);
}
}
} else {
pCore->displayMessage(i18n("Select a clip to apply an effect"), ErrorMessage, 500);
......@@ -3071,8 +3081,15 @@ void TimelineController::addEffectToClip(const QString &assetId, int clipId)
return;
}
}
qDebug() << "/// ADDING ASSET: " << assetId;
m_model->addClipEffect(clipId, assetId);
if (m_model->addClipEffect(clipId, assetId) && KdenliveSettings::seekonaddeffect()) {
// Move timeline cursor inside clip if it is not
int in = m_model->getClipPosition(clipId);
int out = in + m_model->getClipPlaytime(clipId);
int position = pCore->getTimelinePosition();
if (position < in || position > out) {
emit seeked(in);
}
}
}
bool TimelineController::splitAV()
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>589</width>
<height>532</height>
<width>694</width>
<height>646</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
......@@ -68,9 +68,9 @@
</spacer>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_verticalzoom">
<widget class="QCheckBox" name="kcfg_seekonaddeffect">
<property name="text">
<string>Zoom using vertical drag in ruler</string>
<string>Seek to clip when adding effect</string>
</property>
</widget>
</item>
......@@ -253,7 +253,7 @@
<tabstop>kcfg_ffmpegaudiothumbnails</tabstop>
<tabstop>kcfg_showmarkers</tabstop>
<tabstop>kcfg_autoscroll</tabstop>
<tabstop>kcfg_verticalzoom</tabstop>
<tabstop>kcfg_seekonaddeffect</tabstop>
<tabstop>kcfg_scrollvertically</tabstop>
<tabstop>kcfg_trackheight</tabstop>
</tabstops>
......
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