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
e27d3f48
Commit
e27d3f48
authored
Aug 11, 2020
by
Jean-Baptiste Mardelle
Browse files
Don't allow adding unique effect (like fades) twice
parent
e9baf895
Pipeline
#30367
passed with stage
in 21 minutes and 1 second
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/assets/abstractassetsrepository.hpp
View file @
e27d3f48
...
...
@@ -49,6 +49,9 @@ public:
/* @brief Return type of asset */
AssetType
getType
(
const
QString
&
assetId
)
const
;
/* @brief Return type of asset */
bool
isUnique
(
const
QString
&
assetId
)
const
;
/* @brief Return name of asset */
Q_INVOKABLE
QString
getName
(
const
QString
&
assetId
)
const
;
...
...
src/assets/abstractassetsrepository.ipp
View file @
e27d3f48
...
...
@@ -286,6 +286,14 @@ template <typename AssetType> AssetType AbstractAssetsRepository<AssetType>::get
return m_assets.at(assetId).type;
}
template <typename AssetType> bool AbstractAssetsRepository<AssetType>::isUnique(const QString &assetId) const
{
if (m_assets.count(assetId) > 0) {
return m_assets.at(assetId).xml.hasAttribute(QStringLiteral("unique"));
}
return false;
}
template <typename AssetType> QString AbstractAssetsRepository<AssetType>::getName(const QString &assetId) const
{
Q_ASSERT(m_assets.count(assetId) > 0);
...
...
src/effects/effectstack/model/abstracteffectitem.hpp
View file @
e27d3f48
...
...
@@ -53,6 +53,8 @@ public:
/* @brief Return true if the effect or effect group applies only to audio */
virtual
bool
isAudio
()
const
=
0
;
/* @brief Return true if this effect can only have one instance in an effect stack */
virtual
bool
isUnique
()
const
=
0
;
/* @brief This function plants the effect into the given service in last position
*/
...
...
src/effects/effectstack/model/effectgroupmodel.cpp
View file @
e27d3f48
...
...
@@ -60,6 +60,11 @@ bool EffectGroupModel::isAudio() const
return
result
;
}
bool
EffectGroupModel
::
isUnique
()
const
{
return
false
;
}
void
EffectGroupModel
::
plant
(
const
std
::
weak_ptr
<
Mlt
::
Service
>
&
service
)
{
for
(
int
i
=
0
;
i
<
childCount
();
++
i
)
{
...
...
src/effects/effectstack/model/effectgroupmodel.hpp
View file @
e27d3f48
...
...
@@ -39,6 +39,7 @@ public:
/* @brief Return true if the effect applies only to audio */
bool
isAudio
()
const
override
;
bool
isUnique
()
const
override
;
/* @brief This function plants the effect into the given service in last position
*/
...
...
src/effects/effectstack/model/effectitemmodel.cpp
View file @
e27d3f48
...
...
@@ -223,3 +223,8 @@ bool EffectItemModel::isAudio() const
AssetListType
::
AssetType
type
=
EffectsRepository
::
get
()
->
getType
(
m_assetId
);
return
type
==
AssetListType
::
AssetType
::
Audio
||
type
==
AssetListType
::
AssetType
::
CustomAudio
;
}
bool
EffectItemModel
::
isUnique
()
const
{
return
EffectsRepository
::
get
()
->
isUnique
(
m_assetId
);
}
src/effects/effectstack/model/effectitemmodel.hpp
View file @
e27d3f48
...
...
@@ -57,6 +57,7 @@ public:
/* @brief Return true if the effect applies only to audio */
bool
isAudio
()
const
override
;
bool
isUnique
()
const
override
;
void
setCollapsed
(
bool
collapsed
);
bool
isCollapsed
();
...
...
src/effects/effectstack/model/effectstackmodel.cpp
View file @
e27d3f48
...
...
@@ -284,6 +284,10 @@ bool EffectStackModel::fromXml(const QDomElement &effectsXml, Fun &undo, Fun &re
}
else
if
(
state
!=
PlaylistState
::
VideoOnly
)
{
continue
;
}
if
(
EffectsRepository
::
get
()
->
isUnique
(
effectId
)
&&
hasEffect
(
effectId
))
{
pCore
->
displayMessage
(
i18n
(
"Effect %1 cannot be added twice."
,
EffectsRepository
::
get
()
->
getName
(
effectId
)),
InformationMessage
);
return
false
;
}
bool
effectEnabled
=
true
;
if
(
Xml
::
hasXmlProperty
(
node
,
QLatin1String
(
"disable"
)))
{
effectEnabled
=
Xml
::
getXmlProperty
(
node
,
QLatin1String
(
"disable"
)).
toInt
()
!=
1
;
...
...
@@ -365,6 +369,10 @@ bool EffectStackModel::copyEffect(const std::shared_ptr<AbstractEffectItem> &sou
}
std
::
shared_ptr
<
EffectItemModel
>
sourceEffect
=
std
::
static_pointer_cast
<
EffectItemModel
>
(
sourceItem
);
const
QString
effectId
=
sourceEffect
->
getAssetId
();
if
(
EffectsRepository
::
get
()
->
isUnique
(
effectId
)
&&
hasEffect
(
effectId
))
{
pCore
->
displayMessage
(
i18n
(
"Effect %1 cannot be added twice."
,
EffectsRepository
::
get
()
->
getName
(
effectId
)),
InformationMessage
);
return
false
;
}
bool
enabled
=
sourceEffect
->
isEnabled
();
auto
effect
=
EffectItemModel
::
construct
(
effectId
,
shared_from_this
(),
enabled
);
effect
->
setParameters
(
sourceEffect
->
getAllParameters
());
...
...
@@ -408,6 +416,10 @@ bool EffectStackModel::copyEffect(const std::shared_ptr<AbstractEffectItem> &sou
bool
EffectStackModel
::
appendEffect
(
const
QString
&
effectId
,
bool
makeCurrent
)
{
QWriteLocker
locker
(
&
m_lock
);
if
(
EffectsRepository
::
get
()
->
isUnique
(
effectId
)
&&
hasEffect
(
effectId
))
{
pCore
->
displayMessage
(
i18n
(
"Effect %1 cannot be added twice."
,
EffectsRepository
::
get
()
->
getName
(
effectId
)),
InformationMessage
);
return
false
;
}
std
::
unordered_set
<
int
>
previousFadeIn
=
m_fadeIns
;
std
::
unordered_set
<
int
>
previousFadeOut
=
m_fadeOuts
;
if
(
EffectsRepository
::
get
()
->
isGroup
(
effectId
))
{
...
...
@@ -915,6 +927,10 @@ void EffectStackModel::importEffects(const std::weak_ptr<Mlt::Service> &service,
continue
;
}
const
QString
effectId
=
qstrdup
(
filter
->
get
(
"kdenlive_id"
));
if
(
EffectsRepository
::
get
()
->
isUnique
(
effectId
)
&&
hasEffect
(
effectId
))
{
pCore
->
displayMessage
(
i18n
(
"Effect %1 cannot be added twice."
,
EffectsRepository
::
get
()
->
getName
(
effectId
)),
InformationMessage
);
continue
;
}
if
(
filter
->
get_int
(
"disable"
)
==
0
)
{
effectEnabled
=
true
;
}
...
...
@@ -1293,3 +1309,13 @@ bool EffectStackModel::hasKeyFrame(int frame)
std
::
shared_ptr
<
KeyframeModelList
>
listModel
=
sourceEffect
->
getKeyframeModel
();
return
listModel
->
hasKeyframe
(
frame
);
}
bool
EffectStackModel
::
hasEffect
(
const
QString
&
assetId
)
const
{
for
(
int
i
=
0
;
i
<
rootItem
->
childCount
();
++
i
)
{
if
(
std
::
static_pointer_cast
<
EffectItemModel
>
(
rootItem
->
child
(
i
))
->
getAssetId
()
==
assetId
)
{
return
true
;
}
}
return
false
;
}
src/effects/effectstack/model/effectstackmodel.hpp
View file @
e27d3f48
...
...
@@ -142,6 +142,9 @@ public:
/* @brief This is a convenience function that helps check if the tree is in a valid state */
bool
checkConsistency
()
override
;
/* @brief Return true if an asset id is already added to this effect stack */
bool
hasEffect
(
const
QString
&
assetId
)
const
;
public
slots
:
/* @brief Delete an effect from the stack */
void
removeEffect
(
const
std
::
shared_ptr
<
EffectItemModel
>
&
effect
);
...
...
Write
Preview
Markdown
is supported
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