Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
026791e9
Commit
026791e9
authored
Jan 29, 2022
by
Jean-Baptiste Mardelle
Browse files
Fix fade effects not correctly saved or pasted.
Related to
#1286
parent
14e5b345
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/assets/model/assetparametermodel.cpp
View file @
026791e9
...
...
@@ -886,6 +886,13 @@ QVector<QPair<QString, QVariant>> AssetParameterModel::getAllParameters() const
for
(
const
auto
&
param
:
m_params
)
{
if
(
!
param
.
first
.
isEmpty
())
{
QModelIndex
ix
=
index
(
m_rows
.
indexOf
(
param
.
first
),
0
);
if
(
m_params
.
at
(
param
.
first
).
type
==
ParamType
::
MultiSwitch
)
{
// Multiswitch param value is not updated on change, fo fetch real value now
QVariant
multiVal
=
data
(
ix
,
AssetParameterModel
::
ValueRole
).
toString
();
res
.
push_back
(
QPair
<
QString
,
QVariant
>
(
param
.
first
,
multiVal
));
continue
;
}
res
.
push_back
(
QPair
<
QString
,
QVariant
>
(
param
.
first
,
param
.
second
.
value
));
}
}
...
...
@@ -1328,3 +1335,12 @@ Mlt::Properties *AssetParameterModel::getAsset()
{
return
m_asset
.
get
();
}
const
QVariant
AssetParameterModel
::
getParamFromName
(
const
QString
&
paramName
)
{
QModelIndex
ix
=
index
(
m_rows
.
indexOf
(
paramName
),
0
);
if
(
ix
.
isValid
())
{
return
data
(
ix
,
ValueRole
);
}
return
QVariant
();
}
src/assets/model/assetparametermodel.hpp
View file @
026791e9
...
...
@@ -149,6 +149,8 @@ public:
/** @brief Return all the parameters as pairs (parameter name, parameter value) */
QVector
<
QPair
<
QString
,
QVariant
>>
getAllParameters
()
const
;
/** @brief Get a parameter value from its name */
const
QVariant
getParamFromName
(
const
QString
&
paramName
);
/** @brief Returns a json definition of the effect with all param values */
QJsonDocument
toJson
(
bool
includeFixed
=
true
)
const
;
/** @brief Returns the interpolated value at the given position with all param values as json*/
...
...
src/core.cpp
View file @
026791e9
...
...
@@ -919,7 +919,7 @@ void Core::updateItemKeyframes(ObjectId id)
void
Core
::
updateItemModel
(
ObjectId
id
,
const
QString
&
service
)
{
if
(
m_guiConstructed
&&
id
.
first
==
ObjectType
::
TimelineClip
&&
!
m_mainWindow
->
getCurrentTimeline
()
->
loading
&&
service
.
startsWith
(
QLatin1String
(
"fade"
)))
{
bool
startFade
=
service
==
QLatin1String
(
"fadein"
)
||
service
==
QLatin1String
(
"fade_from_
black
"
);
bool
startFade
=
service
.
startsWith
(
QLatin1String
(
"fadein"
)
)
||
service
.
startsWith
(
QLatin1String
(
"fade_from_"
)
);
m_mainWindow
->
getCurrentTimeline
()
->
controller
()
->
updateClip
(
id
.
second
,
{
startFade
?
TimelineModel
::
FadeInRole
:
TimelineModel
::
FadeOutRole
});
}
}
...
...
src/doc/documentvalidator.cpp
View file @
026791e9
...
...
@@ -1839,7 +1839,7 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
QDomElement
t
=
effects
.
at
(
i
).
toElement
();
QString
kdenliveId
=
Xml
::
getXmlProperty
(
t
,
QStringLiteral
(
"kdenlive_id"
));
if
(
kdenliveId
.
startsWith
(
QLatin1String
(
"fade_"
)))
{
bool
fadeIn
=
kdenliveId
==
QLatin1String
(
"fade_from_
black
"
);
bool
fadeIn
=
kdenliveId
.
startsWith
(
QLatin1String
(
"fade_from_"
)
);
bool
isAlpha
=
Xml
::
getXmlProperty
(
t
,
QStringLiteral
(
"alpha"
)).
toInt
()
==
-
1
;
// Clear unused properties
Xml
::
removeXmlProperty
(
t
,
QStringLiteral
(
"start"
));
...
...
src/effects/effectstack/model/effectstackmodel.cpp
View file @
026791e9
...
...
@@ -357,7 +357,7 @@ bool EffectStackModel::fromXml(const QDomElement &effectsXml, Fun &undo, Fun &re
connect
(
effect
.
get
(),
&
AssetParameterModel
::
modelChanged
,
this
,
&
EffectStackModel
::
modelChanged
);
connect
(
effect
.
get
(),
&
AssetParameterModel
::
replugEffect
,
this
,
&
EffectStackModel
::
replugEffect
,
Qt
::
DirectConnection
);
connect
(
effect
.
get
(),
&
AssetParameterModel
::
showEffectZone
,
this
,
&
EffectStackModel
::
updateEffectZones
);
if
(
effectId
==
QLatin1String
(
"fadein"
)
||
effectId
==
QLatin1String
(
"fade_from_
black
"
))
{
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadein"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_from_"
)
))
{
m_fadeIns
.
insert
(
effect
->
getId
());
int
duration
=
effect
->
filter
().
get_length
()
-
1
;
effect
->
filter
().
set
(
"in"
,
currentIn
);
...
...
@@ -370,7 +370,7 @@ bool EffectStackModel::fromXml(const QDomElement &effectsXml, Fun &undo, Fun &re
effect
->
filter
().
set
(
"alpha"
,
"0=0;-1=1"
);
}
}
}
else
if
(
effectId
==
QLatin1String
(
"fadeout"
)
||
effectId
==
QLatin1String
(
"fade_to_
black
"
))
{
}
else
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadeout"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_to_"
)
))
{
m_fadeOuts
.
insert
(
effect
->
getId
());
int
duration
=
effect
->
filter
().
get_length
()
-
1
;
int
filterOut
=
pCore
->
getItemIn
(
m_ownerId
)
+
pCore
->
getItemDuration
(
m_ownerId
)
-
1
;
...
...
@@ -439,14 +439,14 @@ bool EffectStackModel::copyEffect(const std::shared_ptr<AbstractEffectItem> &sou
connect
(
effect
.
get
(),
&
AssetParameterModel
::
replugEffect
,
this
,
&
EffectStackModel
::
replugEffect
,
Qt
::
DirectConnection
);
connect
(
effect
.
get
(),
&
AssetParameterModel
::
showEffectZone
,
this
,
&
EffectStackModel
::
updateEffectZones
);
QVector
<
int
>
roles
=
{
TimelineModel
::
EffectNamesRole
};
if
(
effectId
==
QLatin1String
(
"fadein"
)
||
effectId
==
QLatin1String
(
"fade_from_
black
"
))
{
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadein"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_from_"
)
))
{
m_fadeIns
.
insert
(
effect
->
getId
());
int
duration
=
effect
->
filter
().
get_length
()
-
1
;
int
in
=
pCore
->
getItemIn
(
m_ownerId
);
effect
->
filter
().
set
(
"in"
,
in
);
effect
->
filter
().
set
(
"out"
,
in
+
duration
);
roles
<<
TimelineModel
::
FadeInRole
;
}
else
if
(
effectId
==
QLatin1String
(
"fadeout"
)
||
effectId
==
QLatin1String
(
"fade_to_
black
"
))
{
}
else
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadeout"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_to_"
)
))
{
m_fadeOuts
.
insert
(
effect
->
getId
());
int
duration
=
effect
->
filter
().
get_length
()
-
1
;
int
out
=
pCore
->
getItemIn
(
m_ownerId
)
+
pCore
->
getItemDuration
(
m_ownerId
)
-
1
;
...
...
@@ -511,13 +511,13 @@ bool EffectStackModel::appendEffect(const QString &effectId, bool makeCurrent)
if
(
res
)
{
int
inFades
=
0
;
int
outFades
=
0
;
if
(
effectId
==
QLatin1String
(
"fadein"
)
||
effectId
==
QLatin1String
(
"fade_from_
black
"
))
{
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadein"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_from_"
)
))
{
int
duration
=
effect
->
filter
().
get_length
()
-
1
;
int
in
=
pCore
->
getItemIn
(
m_ownerId
);
effect
->
filter
().
set
(
"in"
,
in
);
effect
->
filter
().
set
(
"out"
,
in
+
duration
);
inFades
++
;
}
else
if
(
effectId
==
QLatin1String
(
"fadeout"
)
||
effectId
==
QLatin1String
(
"fade_to_
black
"
))
{
}
else
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadeout"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_to_"
)
))
{
/*int duration = effect->filter().get_length() - 1;
int out = pCore->getItemIn(m_ownerId) + pCore->getItemDuration(m_ownerId) - 1;
effect->filter().set("in", out - duration);
...
...
@@ -883,9 +883,9 @@ void EffectStackModel::registerItem(const std::shared_ptr<TreeItem> &item)
}
effectItem
->
setEffectStackEnabled
(
m_effectStackEnabled
);
const
QString
&
effectId
=
effectItem
->
getAssetId
();
if
(
effectId
==
QLatin1String
(
"fadein"
)
||
effectId
==
QLatin1String
(
"fade_from_
black
"
))
{
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadein"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_from_"
)
))
{
m_fadeIns
.
insert
(
effectItem
->
getId
());
}
else
if
(
effectId
==
QLatin1String
(
"fadeout"
)
||
effectId
==
QLatin1String
(
"fade_to_
black
"
))
{
}
else
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadeout"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_to_"
)
))
{
m_fadeOuts
.
insert
(
effectItem
->
getId
());
}
if
(
!
effectItem
->
isAudio
()
&&
!
m_loadingExisting
)
{
...
...
@@ -1038,7 +1038,7 @@ void EffectStackModel::importEffects(const std::weak_ptr<Mlt::Service> &service,
Fun
redo
=
addItem_lambda
(
effect
,
rootItem
->
getId
());
effect
->
prepareKeyframes
();
if
(
redo
())
{
if
(
effectId
==
QLatin1String
(
"fadein"
)
||
effectId
==
QLatin1String
(
"fade_from_
black
"
))
{
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadein"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_from_"
)
))
{
m_fadeIns
.
insert
(
effect
->
getId
());
int
clipIn
=
ptr
->
get_int
(
"in"
);
if
(
effect
->
filter
().
get_int
(
"in"
)
!=
clipIn
)
{
...
...
@@ -1047,7 +1047,7 @@ void EffectStackModel::importEffects(const std::weak_ptr<Mlt::Service> &service,
effect
->
filter
().
set
(
"in"
,
clipIn
);
effect
->
filter
().
set
(
"out"
,
clipIn
+
filterLength
);
}
}
else
if
(
effectId
==
QLatin1String
(
"fadeout"
)
||
effectId
==
QLatin1String
(
"fade_to_
black
"
))
{
}
else
if
(
effectId
.
startsWith
(
QLatin1String
(
"fadeout"
)
)
||
effectId
.
startsWith
(
QLatin1String
(
"fade_to_"
)
))
{
m_fadeOuts
.
insert
(
effect
->
getId
());
int
clipOut
=
ptr
->
get_int
(
"out"
);
if
(
effect
->
filter
().
get_int
(
"out"
)
!=
clipOut
)
{
...
...
src/effects/effectstack/view/collapsibleeffectview.cpp
View file @
026791e9
...
...
@@ -520,12 +520,31 @@ void CollapsibleEffectView::slotSaveEffect()
if
(
paramType
==
QLatin1String
(
"fixed"
)
||
!
values
.
contains
(
paramName
))
{
continue
;
}
if
(
paramType
==
QLatin1String
(
"multiswitch"
))
{
// Multiswitch param value is not updated on change, fo fetch real value now
QString
val
=
m_model
->
getParamFromName
(
paramName
).
toString
();
params
.
item
(
i
).
toElement
().
setAttribute
(
QStringLiteral
(
"value"
),
val
);
continue
;
}
params
.
item
(
i
).
toElement
().
setAttribute
(
QStringLiteral
(
"value"
),
values
.
value
(
paramName
));
}
doc
.
appendChild
(
doc
.
importNode
(
effect
,
true
));
effect
=
doc
.
firstChild
().
toElement
();
effect
.
removeAttribute
(
QStringLiteral
(
"kdenlive_ix"
));
effect
.
setAttribute
(
QStringLiteral
(
"id"
),
name
);
QString
namedId
=
name
;
QString
sourceId
=
effect
.
attribute
(
"id"
);
// When saving an effect as custom, it might be necessary to keep track of the original
// effect id as it is sometimes used in Kdenlive to trigger special behaviors
if
(
sourceId
.
startsWith
(
QStringLiteral
(
"fade_to_"
)))
{
namedId
.
prepend
(
QStringLiteral
(
"fade_to_"
));
}
else
if
(
sourceId
.
startsWith
(
QStringLiteral
(
"fade_from_"
)))
{
namedId
.
prepend
(
QStringLiteral
(
"fade_from_"
));
}
if
(
sourceId
.
startsWith
(
QStringLiteral
(
"fadein"
)))
{
namedId
.
prepend
(
QStringLiteral
(
"fadein_"
));
}
if
(
sourceId
.
startsWith
(
QStringLiteral
(
"fadeout"
)))
{
namedId
.
prepend
(
QStringLiteral
(
"fadeout_"
));
}
effect
.
setAttribute
(
QStringLiteral
(
"id"
),
namedId
);
QString
masterType
=
effect
.
attribute
(
QLatin1String
(
"type"
));
effect
.
setAttribute
(
QStringLiteral
(
"type"
),
(
masterType
==
QLatin1String
(
"audio"
)
||
masterType
==
QLatin1String
(
"customAudio"
))
?
QStringLiteral
(
"customAudio"
)
:
QStringLiteral
(
"customVideo"
));
...
...
@@ -547,7 +566,7 @@ void CollapsibleEffectView::slotSaveEffect()
QDomText
text
=
doc
.
createTextNode
(
enteredDescription
);
newNodeTag
.
appendChild
(
text
);
root
.
replaceChild
(
newNodeTag
,
nodelist
);
}
}
if
(
file
.
open
(
QFile
::
WriteOnly
|
QFile
::
Truncate
))
{
QTextStream
out
(
&
file
);
...
...
src/timeline2/model/clipmodel.cpp
View file @
026791e9
...
...
@@ -758,12 +758,12 @@ bool ClipModel::adjustEffectLength(const QString &effectName, int duration, int
QWriteLocker
locker
(
&
m_lock
);
qDebug
()
<<
".... ADJUSTING FADE LENGTH: "
<<
duration
<<
" / "
<<
effectName
;
Fun
operation
=
[
this
,
duration
,
effectName
,
originalDuration
]()
{
return
m_effectStack
->
adjustFadeLength
(
duration
,
effectName
==
QLatin1String
(
"fadein"
)
||
effectName
==
QLatin1String
(
"fade_to_
black
"
),
audioEnabled
(),
return
m_effectStack
->
adjustFadeLength
(
duration
,
effectName
.
startsWith
(
QLatin1String
(
"fadein"
)
)
||
effectName
.
startsWith
(
QLatin1String
(
"fade_to_"
)
),
audioEnabled
(),
!
isAudioOnly
(),
originalDuration
>
0
);
};
if
(
operation
()
&&
originalDuration
>
0
)
{
Fun
reverse
=
[
this
,
originalDuration
,
effectName
]()
{
return
m_effectStack
->
adjustFadeLength
(
originalDuration
,
effectName
==
QLatin1String
(
"fadein"
)
||
effectName
==
QLatin1String
(
"fade_to_
black
"
),
return
m_effectStack
->
adjustFadeLength
(
originalDuration
,
effectName
.
startsWith
(
QLatin1String
(
"fadein"
)
)
||
effectName
.
startsWith
(
QLatin1String
(
"fade_to_"
)
),
audioEnabled
(),
!
isAudioOnly
(),
true
);
};
UPDATE_UNDO_REDO
(
operation
,
reverse
,
undo
,
redo
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment