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
01c26990
Commit
01c26990
authored
Nov 15, 2021
by
Julius Künzel
Browse files
Add infrastruture for template effects
Template effects are basically pre-installed custom effects
parent
87785e11
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/assets/assetlist/view/qmltypes/asseticonprovider.cpp
View file @
01c26990
...
...
@@ -51,8 +51,8 @@ QImage AssetIconProvider::makeIcon(const QString &effectName, const QSize &size)
bool
isGroup
=
false
;
AssetListType
::
AssetType
type
=
AssetListType
::
AssetType
(
effectName
.
section
(
QLatin1Char
(
'/'
),
-
1
).
toInt
());
if
(
m_effect
)
{
isAudio
=
type
==
AssetListType
::
AssetType
::
Audio
||
type
==
AssetListType
::
AssetType
::
CustomAudio
;
isCustom
=
type
==
AssetListType
::
AssetType
::
CustomAudio
||
type
==
AssetListType
::
AssetType
::
Custom
;
isAudio
=
type
==
AssetListType
::
AssetType
::
Audio
||
type
==
AssetListType
::
AssetType
::
CustomAudio
||
type
==
AssetListType
::
AssetType
::
TemplateAudio
;
isCustom
=
type
==
AssetListType
::
AssetType
::
CustomAudio
||
type
==
AssetListType
::
AssetType
::
Custom
||
type
==
AssetListType
::
AssetType
::
Template
||
type
==
AssetListType
::
AssetType
::
TemplateAudio
;
if
(
isCustom
)
{
//isGroup = EffectsRepository::get()->isGroup(effectId);
}
...
...
src/definitions.h
View file @
01c26990
...
...
@@ -87,7 +87,7 @@ enum EditMode { NormalEdit = 0, OverwriteEdit = 1, InsertEdit = 2 };
namespace
AssetListType
{
Q_NAMESPACE
enum
AssetType
{
Preferred
,
Video
,
Audio
,
Custom
,
CustomAudio
,
Favorites
,
AudioComposition
,
VideoShortComposition
,
VideoComposition
,
AudioTransition
,
VideoTransition
,
Hidden
=
-
1
};
enum
AssetType
{
Preferred
,
Video
,
Audio
,
Custom
,
CustomAudio
,
Template
,
TemplateAudio
,
Favorites
,
AudioComposition
,
VideoShortComposition
,
VideoComposition
,
AudioTransition
,
VideoTransition
,
Hidden
=
-
1
};
Q_ENUM_NS
(
AssetType
)
}
...
...
src/effects/effectlist/model/effectfilter.cpp
View file @
01c26990
...
...
@@ -44,7 +44,7 @@ bool EffectFilter::filterType(const std::shared_ptr<TreeItem> &item) const
return
item
->
dataColumn
(
AssetTreeModel
::
preferredCol
).
toBool
();
}
if
(
m_type_value
==
AssetListType
::
AssetType
::
Custom
)
{
return
itemType
==
m_type_value
||
itemType
==
AssetListType
::
AssetType
::
CustomAudio
;
return
itemType
==
m_type_value
||
itemType
==
AssetListType
::
AssetType
::
CustomAudio
||
itemType
==
AssetListType
::
Template
||
itemType
==
AssetListType
::
TemplateAudio
;
}
return
itemType
==
m_type_value
;
}
...
...
src/effects/effectlist/model/effecttreemodel.cpp
View file @
01c26990
...
...
@@ -21,6 +21,7 @@
EffectTreeModel
::
EffectTreeModel
(
QObject
*
parent
)
:
AssetTreeModel
(
parent
)
,
m_customCategory
(
nullptr
)
,
m_templateCategory
(
nullptr
)
{
}
...
...
@@ -62,11 +63,13 @@ std::shared_ptr<EffectTreeModel> EffectTreeModel::construct(const QString &categ
miscCategory
=
self
->
rootItem
->
appendChild
(
QList
<
QVariant
>
{
i18n
(
"Misc"
),
QStringLiteral
(
"root"
)});
audioCategory
=
self
->
rootItem
->
appendChild
(
QList
<
QVariant
>
{
i18n
(
"Audio"
),
QStringLiteral
(
"root"
)});
self
->
m_customCategory
=
self
->
rootItem
->
appendChild
(
QList
<
QVariant
>
{
i18n
(
"Custom"
),
QStringLiteral
(
"root"
)});
self
->
m_templateCategory
=
self
->
rootItem
->
appendChild
(
QList
<
QVariant
>
{
i18n
(
"Templates"
),
QStringLiteral
(
"root"
)});
}
else
{
// Flat view
miscCategory
=
self
->
rootItem
;
audioCategory
=
self
->
rootItem
;
self
->
m_customCategory
=
self
->
rootItem
;
self
->
m_templateCategory
=
self
->
rootItem
;
}
// We parse effects
...
...
@@ -84,6 +87,9 @@ std::shared_ptr<EffectTreeModel> EffectTreeModel::construct(const QString &categ
if
(
type
==
AssetListType
::
AssetType
::
Custom
||
type
==
AssetListType
::
AssetType
::
CustomAudio
)
{
targetCategory
=
self
->
m_customCategory
;
}
if
(
type
==
AssetListType
::
AssetType
::
Template
||
type
==
AssetListType
::
AssetType
::
TemplateAudio
)
{
targetCategory
=
self
->
m_templateCategory
;
}
// we create the data list corresponding to this profile
bool
isFav
=
KdenliveSettings
::
favorite_effects
().
contains
(
effect
.
first
);
...
...
src/effects/effectlist/model/effecttreemodel.hpp
View file @
01c26990
...
...
@@ -30,6 +30,7 @@ public:
protected:
std
::
shared_ptr
<
TreeItem
>
m_customCategory
;
std
::
shared_ptr
<
TreeItem
>
m_templateCategory
;
};
#endif
src/effects/effectsrepository.cpp
View file @
01c26990
...
...
@@ -81,9 +81,17 @@ void EffectsRepository::parseCustomAssetFile(const QString &file_name, std::unor
}
QString
type
=
base
.
attribute
(
QStringLiteral
(
"type"
),
QString
());
if
(
type
==
QLatin1String
(
"customAudio"
))
{
result
.
type
=
AssetListType
::
AssetType
::
CustomAudio
;
if
(
file_name
.
contains
(
QStringLiteral
(
"effect-templates"
)))
{
result
.
type
=
AssetListType
::
AssetType
::
TemplateAudio
;
}
else
{
result
.
type
=
AssetListType
::
AssetType
::
CustomAudio
;
}
}
else
{
result
.
type
=
AssetListType
::
AssetType
::
Custom
;
if
(
file_name
.
contains
(
QStringLiteral
(
"effect-templates"
)))
{
result
.
type
=
AssetListType
::
AssetType
::
Template
;
}
else
{
result
.
type
=
AssetListType
::
AssetType
::
Custom
;
}
}
result
.
id
=
base
.
attribute
(
QStringLiteral
(
"id"
),
QString
());
if
(
result
.
id
.
isEmpty
())
{
...
...
@@ -165,7 +173,9 @@ std::unique_ptr<EffectsRepository> &EffectsRepository::get()
QStringList
EffectsRepository
::
assetDirs
()
const
{
return
QStandardPaths
::
locateAll
(
QStandardPaths
::
AppDataLocation
,
QStringLiteral
(
"effects"
),
QStandardPaths
::
LocateDirectory
);
QStringList
dirs
=
QStandardPaths
::
locateAll
(
QStandardPaths
::
AppDataLocation
,
QStringLiteral
(
"effect-templates"
),
QStandardPaths
::
LocateDirectory
);
dirs
.
append
(
QStandardPaths
::
locateAll
(
QStandardPaths
::
AppDataLocation
,
QStringLiteral
(
"effects"
),
QStandardPaths
::
LocateDirectory
));
return
dirs
;
}
void
EffectsRepository
::
parseType
(
QScopedPointer
<
Mlt
::
Properties
>
&
metadata
,
Info
&
res
)
...
...
@@ -394,7 +404,7 @@ bool EffectsRepository::isAudioEffect(const QString &assetId) const
{
if
(
m_assets
.
count
(
assetId
)
>
0
)
{
AssetListType
::
AssetType
type
=
m_assets
.
at
(
assetId
).
type
;
return
type
==
AssetListType
::
AssetType
::
Audio
||
type
==
AssetListType
::
AssetType
::
CustomAudio
;
return
type
==
AssetListType
::
AssetType
::
Audio
||
type
==
AssetListType
::
AssetType
::
CustomAudio
||
type
==
AssetListType
::
AssetType
::
TemplateAudio
;
}
return
false
;
}
src/effects/effectstack/model/effectitemmodel.cpp
View file @
01c26990
...
...
@@ -222,8 +222,7 @@ bool EffectItemModel::hasForcedInOut() const
bool
EffectItemModel
::
isAudio
()
const
{
AssetListType
::
AssetType
type
=
EffectsRepository
::
get
()
->
getType
(
m_assetId
);
return
type
==
AssetListType
::
AssetType
::
Audio
||
type
==
AssetListType
::
AssetType
::
CustomAudio
;
return
EffectsRepository
::
get
()
->
isAudioEffect
(
m_assetId
);
}
bool
EffectItemModel
::
isUnique
()
const
...
...
src/effects/effectstack/model/effectstackmodel.cpp
View file @
01c26990
...
...
@@ -309,8 +309,7 @@ bool EffectStackModel::fromXml(const QDomElement &effectsXml, Fun &undo, Fun &re
for
(
int
i
=
0
;
i
<
nodeList
.
count
();
++
i
)
{
QDomElement
node
=
nodeList
.
item
(
i
).
toElement
();
const
QString
effectId
=
node
.
attribute
(
QStringLiteral
(
"id"
));
AssetListType
::
AssetType
type
=
EffectsRepository
::
get
()
->
getType
(
effectId
);
bool
isAudioEffect
=
type
==
AssetListType
::
AssetType
::
Audio
||
type
==
AssetListType
::
AssetType
::
CustomAudio
;
bool
isAudioEffect
=
EffectsRepository
::
get
()
->
isAudioEffect
(
effectId
);
if
(
isAudioEffect
)
{
if
(
state
!=
PlaylistState
::
AudioOnly
)
{
continue
;
...
...
src/timeline2/model/clipmodel.cpp
View file @
01c26990
...
...
@@ -719,8 +719,7 @@ void ClipModel::setTimelineEffectsEnabled(bool enabled)
bool
ClipModel
::
addEffect
(
const
QString
&
effectId
)
{
QWriteLocker
locker
(
&
m_lock
);
AssetListType
::
AssetType
type
=
EffectsRepository
::
get
()
->
getType
(
effectId
);
if
(
type
==
AssetListType
::
AssetType
::
Audio
||
type
==
AssetListType
::
AssetType
::
CustomAudio
)
{
if
(
EffectsRepository
::
get
()
->
isAudioEffect
(
effectId
))
{
if
(
m_currentState
==
PlaylistState
::
VideoOnly
)
{
return
false
;
}
...
...
Bruno Santos
@bsantos
·
Nov 15, 2021
Reporter
This is awesome!
This is awesome!
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