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 61573a47 authored by Nicolas Carion's avatar Nicolas Carion

start moving clip creation in its own facility

parent 6947a59b
......@@ -4,6 +4,7 @@ set(kdenlive_SRCS
bin/bin.cpp
bin/bincommands.cpp
bin/binplaylist.cpp
bin/clipcreator.cpp
bin/generators/generators.cpp
bin/model/markerlistmodel.cpp
bin/projectclip.cpp
......
/***************************************************************************
* 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 "clipcreator.hpp"
#include "projectitemmodel.h"
#include "xml/xml.hpp"
#include "klocalizedstring.h"
#include <QDomDocument>
QString ClipCreator::createColorClip(const QString& color, int duration, const QString& name, const QString& parentFolder, std::shared_ptr<ProjectItemModel> model)
{
QDomDocument xml;
QDomElement prod = xml.createElement(QStringLiteral("producer"));
xml.appendChild(prod);
prod.setAttribute(QStringLiteral("type"), (int) Color);
prod.setAttribute(QStringLiteral("in"), QStringLiteral("0"));
prod.setAttribute(QStringLiteral("length"), duration);
QMap<QString, QString> properties;
properties.insert(QStringLiteral("resource"), color);
properties.insert(QStringLiteral("kdenlive:clipname"), name);
properties.insert(QStringLiteral("mlt_service"), QStringLiteral("color"));
Xml::addXmlProperties(prod, properties);
QString id;
model->requestAddBinClip(id, xml.documentElement(), parentFolder, i18n("Create color clip"));
return id;
}
/***************************************************************************
* 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 CLIPCREATOR_H
#define CLIPCREATOR_H
#include <QString>
#include <memory>
/** @brief This namespace provides convenienc function to create clips based on various parameters
*/
class ProjectItemModel;
namespace ClipCreator
{
/* @brief Create and inserts a color clip
@param color : a string of the form "0xff0000ff" (solid red in RGBA)
@param duration : duration expressed in number of frames
@param name: name of the clip
@param parentFolder: the binId of the containing folder
@param model: a shared pointer to the bin item model
@return the binId of the created clip
*/
QString createColorClip(const QString& color, int duration, const QString& name, const QString& parentFolder, std::shared_ptr<ProjectItemModel> model);
}
#endif
......@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "clipcreationdialog.h"
#include "bin/bin.h"
#include "bin/bincommands.h"
#include "bin/projectitemmodel.h"
#include "bin/clipcreator.hpp"
#include "bin/projectclip.h"
#include "doc/docundostack.hpp"
#include "doc/kdenlivedoc.h"
......@@ -125,21 +125,10 @@ void ClipCreationDialog::createColorClip(KdenliveDoc *doc, const QString &parent
QString color = dia_ui.clip_color->color().name();
KdenliveSettings::setColorclipcolor(color);
color = color.replace(0, 1, QStringLiteral("0x")) + "ff";
// Everything is ready. create clip xml
QDomDocument xml;
QDomElement prod = xml.createElement(QStringLiteral("producer"));
xml.appendChild(prod);
prod.setAttribute(QStringLiteral("type"), (int) Color);
prod.setAttribute(QStringLiteral("in"), QStringLiteral("0"));
prod.setAttribute(QStringLiteral("length"), doc->getFramePos(doc->timecode().getTimecode(t->gentime())));
QMap<QString, QString> properties;
properties.insert(QStringLiteral("resource"), color);
properties.insert(QStringLiteral("kdenlive:clipname"), dia_ui.clip_name->text());
properties.insert(QStringLiteral("mlt_service"), QStringLiteral("color"));
Xml::addXmlProperties(prod, properties);
int duration = doc->getFramePos(doc->timecode().getTimecode(t->gentime()));
QString name = dia_ui.clip_name->text();
QString id;
model->requestAddBinClip(id, xml.documentElement(), parentFolder, i18n("Create color clip"));
ClipCreator::createColorClip(color, duration, name, parentFolder, model);
}
}
......
......@@ -38,7 +38,7 @@ public:
* @brief A widget for inserting a timecode value.
* @author Jean-Baptiste Mardelle
*
* TimecodeDisplay can be used to insert eigther frames
* TimecodeDisplay can be used to insert either frames
* or a timecode in the format HH:MM:SS:FF
*/
class TimecodeDisplay : public QAbstractSpinBox
......
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