Commit 30067ab9 authored by Julius Künzel's avatar Julius Künzel
Browse files

Add DropArea to "Master" button to drop effects to it

parent 888ba7bc
......@@ -3660,11 +3660,19 @@ const std::shared_ptr<TrackModel> TimelineModel::getTrackById_const(int trackId)
bool TimelineModel::addTrackEffect(int trackId, const QString &effectId)
{
Q_ASSERT(m_iteratorTable.count(trackId) > 0);
if ((*m_iteratorTable.at(trackId))->addEffect(effectId) == false) {
QString effectName = EffectsRepository::get()->getName(effectId);
pCore->displayMessage(i18n("Cannot add effect %1 to selected track", effectName), InformationMessage, 500);
return false;
if(trackId == -1) {
if(m_masterStack== nullptr || m_masterStack->appendEffect(effectId) == false) {
QString effectName = EffectsRepository::get()->getName(effectId);
pCore->displayMessage(i18n("Cannot add effect %1 to master track", effectName), InformationMessage, 500);
return false;
}
} else {
Q_ASSERT(m_iteratorTable.count(trackId) > 0);
if ((*m_iteratorTable.at(trackId))->addEffect(effectId) == false) {
QString effectName = EffectsRepository::get()->getName(effectId);
pCore->displayMessage(i18n("Cannot add effect %1 to selected track", effectName), InformationMessage, 500);
return false;
}
}
return true;
}
......@@ -3672,14 +3680,26 @@ bool TimelineModel::addTrackEffect(int trackId, const QString &effectId)
bool TimelineModel::copyTrackEffect(int trackId, const QString &sourceId)
{
QStringList source = sourceId.split(QLatin1Char('-'));
Q_ASSERT(m_iteratorTable.count(trackId) > 0 && source.count() == 3);
Q_ASSERT(source.count() == 3);
int itemType = source.at(0).toInt();
int itemId = source.at(1).toInt();
int itemRow = source.at(2).toInt();
std::shared_ptr<EffectStackModel> effectStack = pCore->getItemEffectStack(itemType, itemId);
if ((*m_iteratorTable.at(trackId))->copyEffect(effectStack, itemRow) == false) {
pCore->displayMessage(i18n("Cannot paste effect to selected track"), InformationMessage, 500);
return false;
//AbstractEffectItem::is
if(trackId == -1) {
QWriteLocker locker(&m_lock);
if(m_masterStack== nullptr || m_masterStack->copyEffect(effectStack->getEffectStackRow(itemRow), PlaylistState::Disabled) == false) { //We use "disabled" in a hacky way to accept video and audio on master
pCore->displayMessage(i18n("Cannot paste effect to master track"), InformationMessage, 500);
return false;
}
} else {
Q_ASSERT(m_iteratorTable.count(trackId) > 0);
if ((*m_iteratorTable.at(trackId))->copyEffect(effectStack, itemRow) == false) {
pCore->displayMessage(i18n("Cannot paste effect to selected track"), InformationMessage, 500);
return false;
}
}
return true;
}
......
......@@ -717,6 +717,29 @@ Rectangle {
onClicked: {
timeline.showMasterEffects()
}
DropArea { //Drop area for tracks
anchors.fill: parent
keys: 'kdenlive/effect'
property string dropData
property string dropSource
property int dropRow: -1
onEntered: {
dropData = drag.getDataAsString('kdenlive/effect')
dropSource = drag.getDataAsString('kdenlive/effectsource')
}
onDropped: {
console.log("Add effect: ", dropData)
if (dropSource == '') {
// drop from effects list
controller.addTrackEffect(-1, dropData);
} else {
controller.copyTrackEffect(-1, dropSource);
}
dropSource = ''
dropRow = -1
drag.acceptProposedAction
}
}
}
}
Flickable {
......
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