Commit ad3f67d6 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Merge branch 'blacklisted_effects' into 'Applications/19.04'

New categorization and main effects filtering

See merge request kde/kdenlive!32
parents 652944e1 7836478b
......@@ -137,6 +137,10 @@ Effects can be blacklisted in kdenlive/data/blacklisted_effects.txt
All effects with a custom XML GUI need to be blacklisted.
==========
==========
Effects can be added to "Main effects" list in kdenlive/data/preferred_effects.txt
==========
==========
Effects can be assigned to an effect category in kdenlive/data/kdenliveeffectscategory.rc.
==========
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<data name="effects" version="0">
<group list="lift_gamma_gain,brightness,gamma,frei0r.colgate,frei0r.balanc0r,frei0r.brightness,frei0r.levels,frei0r.three_point_balance,frei0r.curves,frei0r.coloradj_RGB,frei0r.sopsat,frei0r.bezier_curves,avfilter.selectivecolor,avfilter.lut3d">
<text>Colour correction</text>
</group>
<group list="invert,sepia,tcolor,greyscale,frei0r.B,frei0r.G,frei0r.R,frei0r.contrast0r,frei0r.saturat0r,frei0r.tint0r,frei0r.primaries,chroma_hold,frei0r.colorize,frei0r.equaliz0r,frei0r.hueshift0r,frei0r.luminance,lumaliftgaingamma">
<group list="invert,sepia,tcolor,greyscale,frei0r.B,frei0r.G,frei0r.R,frei0r.contrast0r,frei0r.saturat0r,frei0r.tint0r,frei0r.primaries,chroma_hold,frei0r.colorize,frei0r.equaliz0r,frei0r.hueshift0r,frei0r.luminance,lumaliftgaingamma,lift_gamma_gain,brightness,gamma,frei0r.colgate,frei0r.balanc0r,frei0r.brightness,frei0r.levels,frei0r.three_point_balance,frei0r.curves,frei0r.coloradj_RGB,frei0r.sopsat,frei0r.bezier_curves,avfilter.selectivecolor,avfilter.lut3d">
<text>Colour</text>
</group>
<group list="frei0r.letterb0xed,pan_zoom,frei0r.scale0tilt,crop,affine,affinerotate,frei0r.nosync0r,qtblend">
<text>Crop and transform</text>
</group>
<group list="volume,normalise,gain,ladspa.1049,ladspa.1048,ladspa.1413,mute">
<group list="volume,normalise,gain,ladspa.1049,ladspa.1048,ladspa.1413,mute,fadein,fadeout,audiobalance,audiopan,swapchannels,ladspa.1406,channelcopy">
<text>Audio correction</text>
</group>
<group list="audiobalance,audiopan,swapchannels,ladspa.1406,channelcopy">
<text>Audio channels</text>
</group>
<group list="audiowave,audiospectrum,frei0r.pr0be,frei0r.pr0file,frei0r.rgbparade,frei0r.timeout,frei0r.vectorscope">
<text>Analysis and data</text>
</group>
<group list="fade_from_black,fade_to_black,fadein,fadeout">
<text>Fade</text>
</group>
<group list="fade_from_black,fade_to_black,fadein,fadeout">
<group list="fade_from_black,fade_to_black,boxblur,obscure,autotrack_rectangle,frei0r.squareblur,frei0r.glow,frei0r.IIRblur,frei0r.edgeglow,frei0r.medians,frei0r.softglow,burningtv,charcoal,dust,frei0r.cartoon,frei0r.dither,frei0r.emboss,frei0r.posterize,frei0r.rgbnoise,frei0r.sigmoidaltransfer,frei0r.sobel,frei0r.threelay0r,frei0r.threshold0r,frei0r.twolay0r,frei0r.vignette,grain,lines,lightgraffiti,oldfilm,threshold,wave,mirror,frei0r.distort0r,frei0r.lenscorrection,frei0r.defish0r,frei0r.pixeliz0r,frei0r.d90stairsteppingfix,frei0r.hqdn3d,frei0r.sharpness,frei0r.spillsupress">
<text>Image adjustment</text>
</group>
<group list="burningtv,charcoal,dust,frei0r.cartoon,frei0r.dither,frei0r.emboss,frei0r.posterize,frei0r.rgbnoise,frei0r.sigmoidaltransfer,frei0r.sobel,frei0r.threelay0r,frei0r.threshold0r,frei0r.twolay0r,frei0r.vignette,grain,lines,lightgraffiti,oldfilm,threshold,vignette">
<text>Artistic</text>
</group>
<group list="boxblur,obscure,autotrack_rectangle,frei0r.squareblur,frei0r.glow,frei0r.IIRblur,frei0r.edgeglow,frei0r.medians,frei0r.softglow">
<text>Blur and hide</text>
</group>
<group list="speed,freeze">
<text>Motion</text>
</group>
<group list="wave,mirror,frei0r.distort0r,frei0r.lenscorrection,frei0r.c0rners,frei0r.defish0r,frei0r.pixeliz0r">
<text>Distort</text>
</group>
<group list="chroma,frei0r.alpha0ps,frei0r.alphagrad,frei0r.alphaspot,frei0r.transparency,frei0r.select0r,frei0r.mask0mate,rotoscoping,frei0r.keyspillm0pup">
<group list="chroma,frei0r.alpha0ps,frei0r.alphagrad,frei0r.alphaspot,frei0r.transparency,frei0r.select0r,frei0r.mask0mate,rotoscoping,frei0r.keyspillm0pup,frei0r.c0rners,crop,affine,qtblend,vignette,frei0r.letterb0xed,pan_zoom,frei0r.scale0tilt,affinerotate,frei0r.nosync0r">
<text>Alpha/Transform</text>
</group>
<group list="frei0r.d90stairsteppingfix,frei0r.hqdn3d,frei0r.sharpness,frei0r.spillsupress">
<text>Enhancement</text>
</group>
<group list="movit.blur,movit.sharpen,movit.diffusion,movit.glow,movit.lift_gamma_gain,movit.mirror,movit.opacity,movit.rect,movit.saturation,movit.unsharp_mask,movit.vignette,movit.white_balance">
<text>GPU effects</text>
</group>
......
affinerotate
audiopan
audiospectrum
boxblur
brightness
charcoal
crop
frei0r.alphagrad
frei0r.bezier_curves
frei0r.c0rners
frei0r.colgate
frei0r.coloradj_RGB
frei0r.colorize
frei0r.contrast0r
frei0r.defish0r
frei0r.distort0r
frei0r.dither
frei0r.edgeglow
frei0r.emboss
frei0r.hqdn3d
frei0r.IIRblur
frei0r.keyspillm0pup
frei0r.lenscorrection
frei0r.pixeliz0r
frei0r.pr0be
frei0r.pr0file
frei0r.rgbnoise
frei0r.rgbparade
frei0r.saturat0r
frei0r.select0r
frei0r.sharpness
frei0r.sigmoidaltransfer
frei0r.softglow
frei0r.three_point_balance
frei0r.vectorscope
gain
gamma
grain
invert
lift_gamma_gain
mirror
mute
normalise
oldfilm
qtblend
rotoscoping
speed
vignette
volume
......@@ -71,8 +71,8 @@ protected:
AssetType type;
};
// Reads the blacklist file and populate appropriate structure
void parseBlackList(const QString &path);
// Reads the asset list from file and populates appropriate structure
void parseAssetList(const QString &filePath, QSet<QString> &destination);
void init();
virtual Mlt::Properties *retrieveListFromMlt() const = 0;
......@@ -106,9 +106,14 @@ protected:
/* @brief Returns the path to the assets' blacklist*/
virtual QString assetBlackListPath() const = 0;
/* @brief Returns the path to the assets' preferred list*/
virtual QString assetPreferredListPath() const = 0;
std::unordered_map<QString, Info> m_assets;
QSet<QString> m_blacklist;
QSet<QString> m_preferred_list;
};
#include "abstractassetsrepository.ipp"
......
......@@ -43,7 +43,10 @@ template <typename AssetType> void AbstractAssetsRepository<AssetType>::init()
#endif
// Parse effects blacklist
parseBlackList(assetBlackListPath());
parseAssetList(assetBlackListPath(), m_blacklist);
// Parse preferred effects' list
parseAssetList(assetPreferredListPath(), m_preferred_list);
// Retrieve the list of MLT's available assets.
QScopedPointer<Mlt::Properties> assets(retrieveListFromMlt());
......@@ -108,19 +111,19 @@ template <typename AssetType> void AbstractAssetsRepository<AssetType>::init()
}
}
template <typename AssetType> void AbstractAssetsRepository<AssetType>::parseBlackList(const QString &path)
template <typename AssetType> void AbstractAssetsRepository<AssetType>::parseAssetList(const QString &filePath, QSet<QString> &destination)
{
QFile blacklist_file(path);
if (blacklist_file.open(QIODevice::ReadOnly)) {
QTextStream stream(&blacklist_file);
QFile assetFile(filePath);
if (assetFile.open(QIODevice::ReadOnly)) {
QTextStream stream(&assetFile);
QString line;
while (stream.readLineInto(&line)) {
line = line.simplified();
if (!line.isEmpty() && !line.startsWith('#')) {
m_blacklist.insert(line);
destination.insert(line);
}
}
blacklist_file.close();
assetFile.close();
}
}
......
......@@ -28,6 +28,7 @@ int AssetTreeModel::nameCol = 0;
int AssetTreeModel::idCol = 1;
int AssetTreeModel::typeCol = 2;
int AssetTreeModel::favCol = 3;
int AssetTreeModel::preferredCol = 5;
AssetTreeModel::AssetTreeModel(QObject *parent)
: AbstractTreeModel(parent)
......
......@@ -50,7 +50,7 @@ public:
virtual void setFavorite(const QModelIndex &index, bool favorite, bool isEffect) = 0;
// for convenience, we store the column of each data field
static int nameCol, idCol, favCol, typeCol;
static int nameCol, idCol, favCol, typeCol, preferredCol;
protected:
};
......
......@@ -49,7 +49,7 @@ public:
/* @brief Returns true if this effect belongs to favorites */
bool isFavorite(const QModelIndex &index) const;
/* @brief Returns true if this effect belongs to favorites */
/* @brief Sets whether this effect belongs to favorites */
void setFavorite(const QModelIndex &index, bool favorite = true, bool isEffect = true);
/* @brief Returns the description of the asset given its model index */
......
......@@ -80,7 +80,8 @@ Rectangle {
ToolButton {
id: showAll
iconName: "show-all-effects"
checkable:true
checkable: true
checked: true
exclusiveGroup: filterGroup
tooltip: i18n('Main %1', assetType())
onClicked: {
......
......@@ -56,6 +56,9 @@ bool EffectFilter::filterType(const std::shared_ptr<TreeItem> &item) const
if (m_type_value == EffectType::Favorites) {
return item->dataColumn(AssetTreeModel::favCol).toBool();
}
if (m_type_value == EffectType::Preferred) {
return item->dataColumn(AssetTreeModel::preferredCol).toBool();
}
return itemType == m_type_value;
}
......
......@@ -107,8 +107,9 @@ std::shared_ptr<EffectTreeModel> EffectTreeModel::construct(const QString &categ
// we create the data list corresponding to this profile
bool isFav = KdenliveSettings::favorite_effects().contains(effect.first);
bool isPreferred = EffectsRepository::get()->isPreferred(effect.first);
//qDebug() << effect.second << effect.first << "in " << targetCategory->dataColumn(0).toString();
QList<QVariant> data {effect.second, effect.first, QVariant::fromValue(type), isFav, targetCategory->row()};
QList<QVariant> data {effect.second, effect.first, QVariant::fromValue(type), isFav, targetCategory->row(), isPreferred};
if (KdenliveSettings::favorite_effects().contains(effect.first) && effectCategory.contains(favCategory)) {
targetCategory = effectCategory[favCategory];
}
......
......@@ -47,6 +47,8 @@ EffectListWidget::EffectListWidget(QWidget *parent)
m_assetIconProvider = new AssetIconProvider(true);
setup();
// Activate "Main effects" filter
setFilterType("");
}
void EffectListWidget::updateFavorite(const QModelIndex &index)
......@@ -73,7 +75,7 @@ void EffectListWidget::setFilterType(const QString &type)
} else if (type == "favorites") {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Favorites);
} else {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(false, EffectType::Video);
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Preferred);
}
}
......
......@@ -158,6 +158,16 @@ QString EffectsRepository::assetBlackListPath() const
return QStringLiteral(":data/blacklisted_effects.txt");
}
QString EffectsRepository::assetPreferredListPath() const
{
return QStringLiteral(":data/preferred_effects.txt");
}
bool EffectsRepository::isPreferred(const QString &effectId) const
{
return m_preferred_list.contains(effectId);
}
std::unique_ptr<Mlt::Filter> EffectsRepository::getEffect(const QString &effectId) const
{
Q_ASSERT(exists(effectId));
......
......@@ -35,7 +35,7 @@
* Note that this class is a Singleton
*/
enum class EffectType { Video, Audio, Custom, Favorites, Hidden };
enum class EffectType { Preferred, Video, Audio, Custom, Favorites, Hidden };
Q_DECLARE_METATYPE(EffectType)
class EffectsRepository : public AbstractAssetsRepository<EffectType>
......@@ -51,6 +51,9 @@ public:
bool hasInternalEffect(const QString &effectId) const;
QPair<QString, QString> reloadCustom(const QString &path);
/* @brief Returns whether this belongs to main effects */
bool isPreferred(const QString &effectId) const;
protected:
// Constructor is protected because class is a Singleton
EffectsRepository();
......@@ -66,6 +69,9 @@ protected:
/* @brief Returns the path to the effects' blacklist*/
QString assetBlackListPath() const override;
/* @brief Returns the path to the effects' preferred list*/
QString assetPreferredListPath() const override;
QStringList assetDirs() const override;
void parseType(QScopedPointer<Mlt::Properties> &metadata, Info &res) override;
......
......@@ -146,6 +146,13 @@ QString TransitionsRepository::assetBlackListPath() const
return QStringLiteral(":data/blacklisted_transitions.txt");
}
QString TransitionsRepository::assetPreferredListPath() const
{
// Transitions do not have "Main" filter implemented, so we return an empty
// string instead of path to a file with that list
return QStringLiteral("");
}
std::unique_ptr<Mlt::Transition> TransitionsRepository::getTransition(const QString &transitionId) const
{
Q_ASSERT(exists(transitionId));
......
......@@ -71,6 +71,9 @@ protected:
/* @brief Returns the path to the transitions' blacklist*/
QString assetBlackListPath() const override;
/* @brief Returns the path to the effects' preferred list*/
QString assetPreferredListPath() const override;
void parseType(QScopedPointer<Mlt::Properties> &metadata, Info &res) override;
/* @brief Returns the metadata associated with the given asset*/
......
......@@ -45,6 +45,7 @@
<qresource prefix="data">
<file alias="blacklisted_effects.txt">../data/blacklisted_effects.txt</file>
<file alias="blacklisted_transitions.txt">../data/blacklisted_transitions.txt</file>
<file alias="preferred_effects.txt">../data/preferred_effects.txt</file>
<file alias="kdenlive_renderprofiles.knsrc">../data/kdenlive_renderprofiles.knsrc</file>
<file alias="kdenlive_titles.knsrc">../data/kdenlive_titles.knsrc</file>
<file alias="kdenlive_wipes.knsrc">../data/kdenlive_wipes.knsrc</file>
......
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