Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 77de1090 authored by Nicolas Carion's avatar Nicolas Carion

New version of transitionlist

parent c3c254d7
......@@ -94,6 +94,7 @@ kconfig_add_kcfg_files(kdenlive_SRCS kdenlivesettings.kcfgc)
add_subdirectory(abstractmodel)
add_subdirectory(assets)
add_subdirectory(effects)
add_subdirectory(transitions)
add_subdirectory(doc)
add_subdirectory(project)
add_subdirectory(timeline)
......
......@@ -66,6 +66,7 @@ public:
protected:
struct Info
{
QString id;
QString name, description, author, version_str;
double version;
QString custom_xml_path;
......
......@@ -56,6 +56,7 @@ void AbstractAssetsRepository<AssetType>::init()
for (int i = 0; i < max; ++i) {
Info info;
QString name = assets->get_name(i);
info.id = name;
if (!m_blacklist.contains(name) && parseInfoFromMlt(name, info)) {
m_assets[name] = info;
} else {
......
......@@ -21,6 +21,7 @@
#include "assettreemodel.hpp"
#include "effects/effectsrepository.hpp"
#include "transitions/transitionsrepository.hpp"
#include "abstractmodel/treeitem.hpp"
int AssetTreeModel::nameCol = 0;
......@@ -65,7 +66,13 @@ QString AssetTreeModel::getDescription(const QModelIndex& index) const
return QString();
} else {
auto id = item->data(AssetTreeModel::idCol).toString();
return EffectsRepository::get()->getDescription(id);
if (EffectsRepository::get()->exists(id)){
return EffectsRepository::get()->getDescription(id);
}
if (TransitionsRepository::get()->exists(id)){
return TransitionsRepository::get()->getDescription(id);
}
return QString();
}
}
......
......@@ -108,7 +108,7 @@ Rectangle {
iconName: "help-about"
checkable:true
checked: true
tooltip: i18n('Show/hide description of the ') + assetName()
tooltip: i18n('Show/hide description of the ') + assetType()
onCheckedChanged:{
if (!checked) {
assetDescription.visible = false
......
......@@ -21,6 +21,7 @@
#include "asseticonprovider.hpp"
#include "effects/effectsrepository.hpp"
#include "transitions/transitionsrepository.hpp"
#include <QDebug>
#include <QIcon>
#include <QPainter>
......@@ -53,6 +54,12 @@ QImage AssetIconProvider::requestImage(const QString &id, QSize *size, const QSi
if (size) {
*size = result.size();
}
} else if (!m_effect && TransitionsRepository::get()->exists(id)) {
QString name = TransitionsRepository::get()->getName(id);
result = makeIcon(id, name, requestedSize);
if (size) {
*size = result.size();
}
} else {
qDebug() << "Asset not found "<<id;
}
......@@ -75,6 +82,9 @@ QImage AssetIconProvider::makeIcon(const QString &effectId, const QString &effec
bool isAudio = false;
if (m_effect) {
isAudio = EffectsRepository::get()->getType(effectId) == EffectType::Audio;
} else {
auto type = TransitionsRepository::get()->getType(effectId);
isAudio = (type == TransitionType::AudioComposition) || (type == TransitionType::AudioTransition);
}
if (isAudio) {
pix.fill(Qt::transparent);
......
......@@ -136,14 +136,6 @@ enum MonitorSceneType {
MonitorSceneRipple
};
enum TransitionType {
/** TRANSITIONTYPE: between 0-99: video trans, 100-199: video+audio trans, 200-299: audio trans */
LumaTransition = 0,
CompositeTransition = 1,
PipTransition = 2,
LumaFileTransition = 3,
MixTransition = 200
};
enum MessageType {
DefaultMessage,
......
......@@ -42,6 +42,7 @@
#include "effectslist/effectslistview.h"
#include "effectslist/effectbasket.h"
#include "effects/effectlist/view/effectlistwidget.hpp"
#include "transitions/transitionlist/view/transitionlistwidget.hpp"
#include "effectstack/effectstackview2.h"
#include "project/transitionsettings.h"
#include "mltcontroller/bincontroller.h"
......@@ -341,7 +342,10 @@ void MainWindow::init(const QString &MltPath, const QUrl &Url, const QString &cl
m_effectListDock = addDock(i18n("Effects"), QStringLiteral("effect_list"), effectList);
m_transitionList = new EffectsListView(EffectsListView::TransitionMode);
m_transitionListDock = addDock(i18n("Transitions"), QStringLiteral("transition_list"), m_transitionList);
auto transitionList = new TransitionListWidget(this);
// m_transitionListDock = addDock(i18n("Transitions"), QStringLiteral("transition_list"), m_transitionList);
m_transitionListDock = addDock(i18n("Transitions"), QStringLiteral("transition_list"), transitionList);
// Add monitors here to keep them at the right of the window
m_clipMonitorDock = addDock(i18n("Clip Monitor"), QStringLiteral("clip_monitor"), m_clipMonitor);
......
......@@ -97,11 +97,6 @@ private:
int m_transitionTrack;
/** @brief Returns the display name for a transition type. */
QString getTransitionName(const TransitionType &type);
/** @brief Returns the transition type for a given name. */
TransitionType getTransitionForName(const QString &type);
};
#endif
set(kdenlive_SRCS
${kdenlive_SRCS}
transitions/transitionsrepository.cpp
transitions/transitionlist/view/transitionlistwidget.cpp
transitions/transitionlist/model/transitiontreemodel.cpp
PARENT_SCOPE)
/***************************************************************************
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "transitiontreemodel.hpp"
#include "transitions/transitionsrepository.hpp"
#include "abstractmodel/treeitem.hpp"
#include <KLocalizedString>
#include <QDebug>
TransitionTreeModel::TransitionTreeModel(QObject *parent)
: AssetTreeModel(parent)
{
QList<QVariant> rootData;
rootData << "Name" << "ID" << "Type" << "isFav";
rootItem = new TreeItem(rootData);
//We create categories
TreeItem *compoCategory = rootItem->appendChild(QList<QVariant>{i18n("Compositions")});
TreeItem *transCategory = rootItem->appendChild(QList<QVariant>{i18n("Transitions")});
//We parse transitions
auto allTransitions = TransitionsRepository::get()->getNames();
for (const auto& transition : allTransitions) {
TreeItem *targetCategory = compoCategory;
TransitionType type = TransitionsRepository::get()->getType(transition.first);
if (type == TransitionType::AudioTransition || type == TransitionType::VideoTransition) {
targetCategory = transCategory;
}
// we create the data list corresponding to this transition
QList<QVariant> data;
bool isFav = TransitionsRepository::get()->isFavorite(transition.first);
qDebug()<<transition.second << transition.first << "in "<<targetCategory->data(0).toString();
data << transition.second << transition.first << QVariant::fromValue(type) << isFav;
targetCategory->appendChild(data);
}
}
/***************************************************************************
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef TRANSITIONTREEMODEL_H
#define TRANSITIONTREEMODEL_H
#include "abstractmodel/abstracttreemodel.hpp"
#include "assets/assetlist/model/assettreemodel.hpp"
/* @brief This class represents a transition hierarchy to be displayed as a tree
*/
class TreeItem;
class TransitionTreeModel : public AssetTreeModel
{
public:
explicit TransitionTreeModel(QObject *parent = 0);
protected:
};
#endif
/***************************************************************************
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "transitionlistwidget.hpp"
#include "../model/transitiontreemodel.hpp"
#include "assets/assetlist/model/assetfilter.hpp"
#include <QQmlContext>
TransitionListWidget::TransitionListWidget(QWidget *parent)
: AssetListWidget(parent)
{
m_model.reset(new TransitionTreeModel(this));
m_proxyModel.reset(new AssetFilter(this));
m_proxyModel->setSourceModel(m_model.get());
m_proxyModel->setSortRole(AssetTreeModel::NameRole);
m_proxyModel->sort(0, Qt::AscendingOrder);
rootContext()->setContextProperty("assetlist", this);
rootContext()->setContextProperty("assetListModel", m_proxyModel.get());
rootContext()->setContextProperty("isEffectList", false);
m_assetIconProvider.reset(new AssetIconProvider(false));
setup();
}
/***************************************************************************
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef TRANSITIONLISTWIDGET_H
#define TRANSITIONLISTWIDGET_H
#include "assets/assetlist/view/assetlistwidget.hpp"
/* @brief This class is a widget that display the list of available effects
*/
class TransitionListWidget : public AssetListWidget
{
Q_OBJECT
public:
TransitionListWidget(QWidget *parent = Q_NULLPTR);
};
#endif
/***************************************************************************
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "transitionsrepository.hpp"
#include "core.h"
#include "xml/xml.hpp"
#include <QFile>
#include <QDir>
#include <QStandardPaths>
#include <QTextStream>
#include <mlt++/Mlt.h>
std::unique_ptr<TransitionsRepository> TransitionsRepository::instance;
std::once_flag TransitionsRepository::m_onceFlag;
TransitionsRepository::TransitionsRepository()
: AbstractAssetsRepository<TransitionType>()
{
init();
}
Mlt::Properties* TransitionsRepository::retrieveListFromMlt()
{
return pCore->getMltRepository()->transitions();
}
Mlt::Properties* TransitionsRepository::getMetadata(const QString& assetId)
{
return pCore->getMltRepository()->metadata(transition_type, assetId.toLatin1().data());
}
void TransitionsRepository::parseCustomAssetFile(const QString& file_name)
{
QFile file(file_name);
QDomDocument doc;
doc.setContent(&file, false);
file.close();
QDomElement base = doc.documentElement();
QDomNodeList transitions = doc.elementsByTagName(QStringLiteral("transition"));
int nbr_transition = transitions.count();
if (nbr_transition == 0) {
qDebug() << "+++++++++++++\n Transition broken: " << file_name << "\n+++++++++++";
return;
}
for (int i = 0; i < nbr_transition; ++i) {
QDomNode currentNode = transitions.item(i);
if (currentNode.isNull()) {
continue;
}
auto id = parseInfoFromXml(currentNode.toElement());
if (id.isEmpty()) {
continue;
}
m_assets[id].custom_xml_path = file_name;
}
}
std::unique_ptr<TransitionsRepository> & TransitionsRepository::get()
{
std::call_once(m_onceFlag, []{instance.reset(new TransitionsRepository());});
return instance;
}
QStringList TransitionsRepository::assetDirs() const
{
return QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("transitions"), QStandardPaths::LocateDirectory);
}
void TransitionsRepository::parseType(QScopedPointer<Mlt::Properties>& metadata, Info & res)
{
Mlt::Properties tags((mlt_properties) metadata->get_data("tags"));
bool audio = QString(tags.get(0)) == QLatin1String("Audio");
if (getSingleTrackTransitions().contains(res.id)) {
if (audio) {
res.type = TransitionType::AudioTransition;
} else {
res.type = TransitionType::VideoTransition;
}
} else {
if (audio) {
res.type = TransitionType::AudioComposition;
} else {
res.type = TransitionType::VideoComposition;
}
}
}
QSet<QString> TransitionsRepository::getSingleTrackTransitions()
{
return {QStringLiteral("composite"),QStringLiteral("dissolve")};
}
/***************************************************************************
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef TRANSITIONSREPOSITORY_H
#define TRANSITIONSREPOSITORY_H
#include <memory>
#include <mutex>
#include "definitions.h"
#include "assets/abstractassetsrepository.hpp"
/** @brief This class stores all the transitions that can be added by the user.
* You can query any transitions based on its name.
* Note that this class is a Singleton
*/
enum class TransitionType {
AudioComposition,
VideoComposition,
AudioTransition,
VideoTransition
};
Q_DECLARE_METATYPE(TransitionType)
class TransitionsRepository : public AbstractAssetsRepository<TransitionType>
{
public:
//Returns the instance of the Singleton
static std::unique_ptr<TransitionsRepository>& get();
protected:
// Constructor is protected because class is a Singleton
TransitionsRepository();
/* Retrieves the list of all available effects from Mlt*/
Mlt::Properties* retrieveListFromMlt() override;
/* @brief Retrieves additional info about effects from a custom XML file
*/
void parseCustomAssetFile(const QString& file_name) override;
QStringList assetDirs() const override;
void parseType(QScopedPointer<Mlt::Properties>& metadata, Info & res) override;
/* @brief Returns the metadata associated with the given asset*/
Mlt::Properties* getMetadata(const QString& assetId) override;
/* @brief Returns all transitions that can be represented as Single Track Transitions*/
static QSet<QString> getSingleTrackTransitions();
static std::unique_ptr<TransitionsRepository> instance;
static std::once_flag m_onceFlag; //flag to create the repository only once;
};
#endif
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