Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
259
Issues
259
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
e27d3f48
Commit
e27d3f48
authored
Aug 11, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Showing
9 changed files
with
54 additions
and
0 deletions
+54
-0
src/assets/abstractassetsrepository.hpp
src/assets/abstractassetsrepository.hpp
+3
-0
src/assets/abstractassetsrepository.ipp
src/assets/abstractassetsrepository.ipp
+8
-0
src/effects/effectstack/model/abstracteffectitem.hpp
src/effects/effectstack/model/abstracteffectitem.hpp
+2
-0
src/effects/effectstack/model/effectgroupmodel.cpp
src/effects/effectstack/model/effectgroupmodel.cpp
+5
-0
src/effects/effectstack/model/effectgroupmodel.hpp
src/effects/effectstack/model/effectgroupmodel.hpp
+1
-0
src/effects/effectstack/model/effectitemmodel.cpp
src/effects/effectstack/model/effectitemmodel.cpp
+5
-0
src/effects/effectstack/model/effectitemmodel.hpp
src/effects/effectstack/model/effectitemmodel.hpp
+1
-0
src/effects/effectstack/model/effectstackmodel.cpp
src/effects/effectstack/model/effectstackmodel.cpp
+26
-0
src/effects/effectstack/model/effectstackmodel.hpp
src/effects/effectstack/model/effectstackmodel.hpp
+3
-0
No files found.
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