diff --git a/src/effects/effectlist/model/effecttreemodel.cpp b/src/effects/effectlist/model/effecttreemodel.cpp
index 21cdd71e7..96ea0e187 100644
--- a/src/effects/effectlist/model/effecttreemodel.cpp
+++ b/src/effects/effectlist/model/effecttreemodel.cpp
@@ -1,154 +1,151 @@
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see . *
***************************************************************************/
#include "effecttreemodel.hpp"
#include "abstractmodel/treeitem.hpp"
#include "effects/effectsrepository.hpp"
#include "kdenlivesettings.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
EffectTreeModel::EffectTreeModel(QObject *parent)
: AssetTreeModel(parent)
, m_customCategory(nullptr)
{
}
std::shared_ptr EffectTreeModel::construct(const QString &categoryFile, QObject *parent)
{
std::shared_ptr self(new EffectTreeModel(parent));
QList rootData;
rootData << "Name"
<< "ID"
<< "Type"
<< "isFav";
self->rootItem = TreeItem::construct(rootData, self, true);
QHash> effectCategory; // category in which each effect should land.
std::shared_ptr miscCategory = nullptr;
std::shared_ptr audioCategory = nullptr;
// We parse category file
if (!categoryFile.isEmpty()) {
QDomDocument doc;
QFile file(categoryFile);
doc.setContent(&file, false);
file.close();
QDomNodeList groups = doc.documentElement().elementsByTagName(QStringLiteral("group"));
// Create favorite group
auto groupFav = self->rootItem->appendChild(QList{i18n("Favorites"), QStringLiteral("root")});
auto groupLegacy = self->rootItem->appendChild(QList{i18n("Legacy"), QStringLiteral("root")});
for (int i = 0; i < groups.count(); i++) {
QString groupName = i18n(groups.at(i).firstChild().firstChild().nodeValue().toUtf8().constData());
if (!KdenliveSettings::gpu_accel() && groupName == i18n("GPU effects")) {
continue;
}
QStringList list = groups.at(i).toElement().attribute(QStringLiteral("list")).split(QLatin1Char(','), QString::SkipEmptyParts);
auto groupItem = self->rootItem->appendChild(QList{groupName, QStringLiteral("root")});
for (const QString &effect : list) {
if (KdenliveSettings::favorite_effects().contains(effect)) {
effectCategory[effect] = groupFav;
} else {
effectCategory[effect] = groupItem;
}
}
}
// We also create "Misc", "Audio" and "Custom" categories
miscCategory = self->rootItem->appendChild(QList{i18n("Misc"), QStringLiteral("root")});
audioCategory = self->rootItem->appendChild(QList{i18n("Audio"), QStringLiteral("root")});
self->m_customCategory = self->rootItem->appendChild(QList{i18n("Custom"), QStringLiteral("root")});
} else {
// Flat view
miscCategory = self->rootItem;
audioCategory = self->rootItem;
self->m_customCategory = self->rootItem;
}
// We parse effects
auto allEffects = EffectsRepository::get()->getNames();
for (const auto &effect : allEffects) {
if (!KdenliveSettings::gpu_accel() && effect.first.contains(QLatin1String("movit."))) {
continue;
}
auto targetCategory = miscCategory;
EffectType type = EffectsRepository::get()->getType(effect.first);
if (effectCategory.contains(effect.first)) {
targetCategory = effectCategory[effect.first];
} else if (type == EffectType::Audio) {
targetCategory = audioCategory;
}
if (type == EffectType::Custom) {
targetCategory = self->m_customCategory;
}
// we create the data list corresponding to this profile
- QList data;
bool isFav = KdenliveSettings::favorite_effects().contains(effect.first);
- qDebug() << effect.second << effect.first << "in " << targetCategory->dataColumn(0).toString();
- data << effect.second << effect.first << QVariant::fromValue(type) << isFav;
-
+ //qDebug() << effect.second << effect.first << "in " << targetCategory->dataColumn(0).toString();
+ QList data {effect.second, effect.first, QVariant::fromValue(type), isFav};
targetCategory->appendChild(data);
}
return self;
}
void EffectTreeModel::reloadEffect(const QString &path)
{
QPair asset = EffectsRepository::get()->reloadCustom(path);
if (asset.first.isEmpty() || m_customCategory == nullptr) {
return;
}
- QList data;
bool isFav = KdenliveSettings::favorite_effects().contains(asset.first);
- data << asset.second << asset.first << QVariant::fromValue(EffectType::Custom) << isFav;
+ QList data {asset.second, asset.first, QVariant::fromValue(EffectType::Custom), isFav};
m_customCategory->appendChild(data);
}
void EffectTreeModel::reloadAssetMenu(QMenu *effectsMenu, KActionCategory *effectActions)
{
for (int i = 0; i < rowCount(); i++) {
std::shared_ptr item = rootItem->child(i);
if (item->childCount() > 0) {
QMenu *catMenu = new QMenu(item->dataColumn(nameCol).toString(), effectsMenu);
effectsMenu->addMenu(catMenu);
for (int j = 0; j < item->childCount(); j++) {
std::shared_ptr child = item->child(j);
QAction *a = new QAction(child->dataColumn(nameCol).toString(), catMenu);
const QString id = child->dataColumn(idCol).toString();
a->setData(id);
catMenu->addAction(a);
effectActions->addAction("transition_" + id, a);
}
}
}
}
diff --git a/src/transitions/transitionlist/model/transitiontreemodel.cpp b/src/transitions/transitionlist/model/transitiontreemodel.cpp
index e43ffee06..00d7a5480 100644
--- a/src/transitions/transitionlist/model/transitiontreemodel.cpp
+++ b/src/transitions/transitionlist/model/transitiontreemodel.cpp
@@ -1,97 +1,96 @@
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see . *
***************************************************************************/
#include "transitiontreemodel.hpp"
#include "abstractmodel/treeitem.hpp"
#include "kdenlivesettings.h"
#include "transitions/transitionsrepository.hpp"
#include
#include
#include
#include
TransitionTreeModel::TransitionTreeModel(QObject *parent)
: AssetTreeModel(parent)
{
}
std::shared_ptr TransitionTreeModel::construct(bool flat, QObject *parent)
{
std::shared_ptr self(new TransitionTreeModel(parent));
QList rootData;
rootData << "Name"
<< "ID"
<< "Type"
<< "isFav";
self->rootItem = TreeItem::construct(rootData, self, true);
// We create categories, if requested
std::shared_ptr compoCategory, transCategory;
if (!flat) {
compoCategory = self->rootItem->appendChild(QList{i18n("Compositions"), QStringLiteral("root")});
transCategory = self->rootItem->appendChild(QList{i18n("Transitions"), QStringLiteral("root")});
}
// We parse transitions
auto allTransitions = TransitionsRepository::get()->getNames();
for (const auto &transition : allTransitions) {
if (!KdenliveSettings::gpu_accel() && transition.first.contains(QLatin1String("movit."))) {
// Hide GPU compositions when movit disabled
continue;
}
std::shared_ptr targetCategory = compoCategory;
TransitionType type = TransitionsRepository::get()->getType(transition.first);
if (type == TransitionType::AudioTransition || type == TransitionType::VideoTransition) {
targetCategory = transCategory;
}
if (flat) {
targetCategory = self->rootItem;
}
// we create the data list corresponding to this transition
- QList data;
bool isFav = KdenliveSettings::favorite_transitions().contains(transition.first);
- qDebug() << transition.second << transition.first << "in " << targetCategory->dataColumn(0).toString();
- data << transition.second << transition.first << QVariant::fromValue(type) << isFav;
+ //qDebug() << transition.second << transition.first << "in " << targetCategory->dataColumn(0).toString();
+ QList data {transition.second, transition.first, QVariant::fromValue(type), isFav};
targetCategory->appendChild(data);
}
return self;
}
void TransitionTreeModel::reloadAssetMenu(QMenu *effectsMenu, KActionCategory *effectActions)
{
for (int i = 0; i < rowCount(); i++) {
std::shared_ptr item = rootItem->child(i);
if (item->childCount() > 0) {
QMenu *catMenu = new QMenu(item->dataColumn(nameCol).toString(), effectsMenu);
effectsMenu->addMenu(catMenu);
for (int j = 0; j < item->childCount(); j++) {
std::shared_ptr child = item->child(j);
QAction *a = new QAction(child->dataColumn(nameCol).toString(), catMenu);
const QString id = child->dataColumn(idCol).toString();
a->setData(id);
catMenu->addAction(a);
effectActions->addAction("transition_" + id, a);
}
}
}
}