* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
+#include <KLocale>
+
#include "addclipcommand.h"
AddClipCommand::AddClipCommand(ProjectList *list, const QStringList &names, const QDomElement &xml, const int id, const KUrl &url, const QString &group, bool doIt)
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
+#include <KLocale>
+
#include "addtimelineclipcommand.h"
AddTimelineClipCommand::AddTimelineClipCommand(CustomTrackView *view, QDomElement xml, int track, int startpos, QRectF rect, int duration, bool doIt)
colour = colour.replace(0, 2, "#");
setBrush(QColor(colour.left(7)));
}
+ else if (m_clipType == IMAGE) {
+ m_startPix = KThumb::getImage(KUrl(xml.attribute("resource")), 50 * KdenliveSettings::project_display_ratio(), 50);
+ }
//m_startPix.load("/home/one/Desktop/thumb.jpg");
}
//painter->fillPath(roundRectPath, brush()); //, QBrush(QColor(Qt::red)));
painter->fillRect(br, brush());
//painter->fillRect(QRectF(br.x() + br.width() - m_endPix.width(), br.y(), m_endPix.width(), br.height()), QBrush(QColor(Qt::black)));
+
+ // draw thumbnails
if (!m_startPix.isNull()) {
- painter->drawPixmap(QPointF(br.x() + br.width() - m_endPix.width(), br.y()), m_endPix);
- QLineF l(br.x() + br.width() - m_endPix.width(), br.y(), br.x() + br.width() - m_endPix.width(), br.y() + br.height());
- painter->drawLine(l);
+ if (m_clipType == IMAGE) {
+ painter->drawPixmap(QPointF(br.x() + br.width() - m_startPix.width(), br.y()), m_startPix);
+ QLineF l(br.x() + br.width() - m_startPix.width(), br.y(), br.x() + br.width() - m_startPix.width(), br.y() + br.height());
+ painter->drawLine(l);
+ } else {
+ painter->drawPixmap(QPointF(br.x() + br.width() - m_endPix.width(), br.y()), m_endPix);
+ QLineF l(br.x() + br.width() - m_endPix.width(), br.y(), br.x() + br.width() - m_endPix.width(), br.y() + br.height());
+ painter->drawLine(l);
+ }
painter->drawPixmap(QPointF(br.x(), br.y()), m_startPix);
QLineF l2(br.x() + m_startPix.width(), br.y(), br.x() + m_startPix.width(), br.y() + br.height());
QPen pen = painter->pen();
pen.setColor(Qt::red);
pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
-
+
+ // Draw clip name
QRectF txtBounding = painter->boundingRect(br, Qt::AlignCenter, " " + m_clipName + " ");
painter->fillRect(txtBounding, QBrush(QColor(255,255,255,150)));
painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
doc.setContent(producer);
QDomElement elem = doc.documentElement();
int in = elem.attribute("in", 0).toInt();
- int out = elem.attribute("duration", 0).toInt();
- if (out == 0) out = elem.attribute("out", 0).toInt() - in;
+ int out = elem.attribute("out", 0).toInt() - in;
+ if (out == 0) out = elem.attribute("duration", 0).toInt();
kDebug()<<"ADDING CLIP: "<<producer<<", OUT: "<<out<<", POS: "<<mapToScene(pos);
int trackTop = ((int) mapToScene(pos).y()/50) * 50 + 1;
- m_dropItem = new ClipItem(elem, ((int) mapToScene(pos).y()/50), in, QRectF(mapToScene(pos).x() * m_scale, trackTop, out * m_scale, 49));
+ m_dropItem = new ClipItem(elem, ((int) mapToScene(pos).y()/50), in, QRectF(mapToScene(pos).x() * m_scale, trackTop, out * m_scale, 49), out);
scene()->addItem(m_dropItem);
}
#define DEFINITIONS_H
#define FRAME_SIZE 90
+#define MAXCLIPDURATION 15000
enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5};
enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9};
//if (thumbProducer.running ()) thumbProducer.exit();
}
+
+//static
+QPixmap KThumb::getImage(KUrl url, int width, int height)
+{
+ if (url.isEmpty()) return QPixmap();
+ QPixmap pix(width, height);
+ char *tmp = Render::decodedString(url.path());
+ Mlt::Producer m_producer(tmp);
+ delete tmp;
+
+ if (m_producer.is_blank()) {
+ pix.fill(Qt::black);
+ return pix;
+ }
+ Mlt::Frame * m_frame;
+ mlt_image_format format = mlt_image_rgb24a;
+ Mlt::Filter m_convert("avcolour_space");
+ m_convert.set("forced", mlt_image_rgb24a);
+ m_producer.attach(m_convert);
+ //m_producer.seek(frame);
+ m_frame = m_producer.get_frame();
+ if (m_frame && m_frame->is_valid()) {
+ uint8_t *thumb = m_frame->get_image(format, width, height);
+ QImage image(thumb, width, height, QImage::Format_ARGB32);
+ if (!image.isNull()) {
+ pix = pix.fromImage(image);
+ }
+ else pix.fill(Qt::black);
+ }
+ if (m_frame) delete m_frame;
+ return pix;
+}
+
void KThumb::extractImage(int frame, int frame2, int width, int height)
{
if (m_url.isEmpty()) return;
char *tmp = Render::decodedString(m_url.path());
Mlt::Producer m_producer(tmp);
delete tmp;
- pix.fill(Qt::black);
if (m_producer.is_blank()) {
+ pix.fill(Qt::black);
emit thumbReady(frame, pix);
return;
}
public slots:
void extractImage( int frame, int frame2, int width, int height);
+ static QPixmap getImage(KUrl url, int width, int height);
/* void getImage(KUrl url, int frame, int width, int height);
void getThumbs(KUrl url, int startframe, int endframe, int width, int height);
void stopAudioThumbs();
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
+#include <KLocale>
+
#include "moveclipcommand.h"
MoveClipCommand::MoveClipCommand(CustomTrackView *view, const QPointF startPos, const QPointF endPos, bool doIt)
#include "projectitem.h"
#include "timecode.h"
+
const int NameRole = Qt::UserRole;
const int DurationRole = NameRole + 1;
const int FullPathRole = NameRole + 2;
const int ClipTypeRole = NameRole + 3;
ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
{
m_element = xml.cloneNode().toElement();
setSizeHint(0, QSize(65, 45));
m_element.setAttribute("id", clipId);
QString cType = m_element.attribute("type", QString::null);
if (!cType.isEmpty()) {
- m_clipType = (DocClipBase::CLIPTYPE) cType.toInt();
+ m_clipType = (CLIPTYPE) cType.toInt();
slotSetToolTip();
}
+
+ if (m_clipType == COLOR || m_clipType == IMAGE) m_element.setAttribute("duration", MAXCLIPDURATION);
+ else if (m_element.attribute("duration").isEmpty() && !m_element.attribute("out").isEmpty()) {
+ m_element.setAttribute("duration", m_element.attribute("out").toInt() - m_element.attribute("in").toInt());
+ }
}
}
ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, QDomElement xml, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
{
m_element = xml.cloneNode().toElement();
setSizeHint(0, QSize(65, 45));
m_element.setAttribute("id", clipId);
QString cType = m_element.attribute("type", QString::null);
if (!cType.isEmpty()) {
- m_clipType = (DocClipBase::CLIPTYPE) cType.toInt();
+ m_clipType = (CLIPTYPE) cType.toInt();
slotSetToolTip();
}
}
}
ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(true), m_groupName(strings.at(1))
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(true), m_groupName(strings.at(1))
{
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
const KUrl ProjectItem::clipUrl() const
{
- if (m_clipType != DocClipBase::COLOR && m_clipType != DocClipBase::VIRTUAL && m_clipType != DocClipBase::NONE)
+ if (m_clipType != COLOR && m_clipType != VIRTUAL && m_clipType != UNKNOWN)
return KUrl(m_element.attribute("resouce"));
else return KUrl();
}
void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata)
{
if (attributes.contains("duration")) {
- if (m_clipType == DocClipBase::AUDIO || m_clipType == DocClipBase::VIDEO || m_clipType == DocClipBase::AV) m_element.setAttribute("duration", attributes["duration"].toInt());
+ if (m_clipType == AUDIO || m_clipType == VIDEO || m_clipType == AV) m_element.setAttribute("duration", attributes["duration"].toInt());
m_duration = GenTime(attributes["duration"].toInt(), 25);
setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
m_durationKnown = true;
//extend attributes -reh
- if (m_clipType == DocClipBase::NONE) {
+ if (m_clipType == UNKNOWN) {
if (attributes.contains("type")) {
if (attributes["type"] == "audio")
- m_clipType = DocClipBase::AUDIO;
+ m_clipType = AUDIO;
else if (attributes["type"] == "video")
- m_clipType = DocClipBase::VIDEO;
+ m_clipType = VIDEO;
else if (attributes["type"] == "av")
- m_clipType = DocClipBase::AV;
+ m_clipType = AV;
else if (attributes["type"] == "playlist")
- m_clipType = DocClipBase::PLAYLIST;
+ m_clipType = PLAYLIST;
} else {
- m_clipType = DocClipBase::AV;
+ m_clipType = AV;
}
}
slotSetToolTip();
if (m_element.isNull()) {
QDomDocument doc;
m_element = doc.createElement("producer");
- m_element.setAttribute("duration", attributes["duration"].toInt());
}
+ if (m_element.attribute("duration") == QString::null) m_element.setAttribute("duration", attributes["duration"].toInt());
m_element.setAttribute("resource", attributes["filename"]);
m_element.setAttribute("type", (int) m_clipType);
/*
#include <QTreeWidget>
#include <QDomElement>
-#include "gentime.h"
-#include "docclipbase.h"
+#include <KUrl>
+#include "gentime.h"
+#include "definitions.h"
class ProjectItem : public QTreeWidgetItem
{
QDomElement m_element;
GenTime m_duration;
bool m_durationKnown;
- DocClipBase::CLIPTYPE m_clipType;
+ CLIPTYPE m_clipType;
int m_clipId;
void slotSetToolTip();
bool m_isGroup;
#include "ui_colorclip_ui.h"
#include "addclipcommand.h"
+#include "definitions.h"
#include <QtGui>
for (it = list.begin(); it != list.end(); it++) {
QStringList itemEntry;
+ QDomDocument doc;
+ QDomElement prod = doc.createElement("producer");
+ prod.setAttribute("resource", (*it).path());
itemEntry.append(QString::null);
itemEntry.append((*it).fileName());
- AddClipCommand *command = new AddClipCommand(this, itemEntry, QDomElement(), m_clipIdCounter++, *it, group, true);
+ KMimeType::Ptr type = KMimeType::findByUrl(*it);
+ if (type->name().startsWith("image/")) {
+ prod.setAttribute("type", (int) IMAGE);
+ prod.setAttribute("in", "0");
+ prod.setAttribute("out", m_timecode.getFrameCount(KdenliveSettings::image_duration(), m_fps));
+ }
+ AddClipCommand *command = new AddClipCommand(this, itemEntry, prod, m_clipIdCounter++, *it, group, true);
m_commandStack->push(command);
//item = new ProjectItem(listView, itemEntry, QDomElement());
//item->setData(1, FullPathRole, (*it).path());
QString color = dia_ui->clip_color->color().name();
color = color.replace(0, 1, "0x") + "ff";
element.setAttribute("colour", color);
- element.setAttribute("type", (int) DocClipBase::COLOR);
+ element.setAttribute("type", (int) COLOR);
element.setAttribute("in", "0");
element.setAttribute("out", m_timecode.getFrameCount(dia_ui->clip_duration->text(), m_fps));
element.setAttribute("name", dia_ui->clip_name->text());
void ProjectList::addProducer(QDomElement producer, int parentId)
{
if (!m_commandStack) kDebug()<<"!!!!!!!!!!!!!!!! NO CMD STK";
- DocClipBase::CLIPTYPE type = (DocClipBase::CLIPTYPE) producer.attribute("type").toInt();
+ CLIPTYPE type = (CLIPTYPE) producer.attribute("type").toInt();
/*QDomDocument doc;
QDomElement prods = doc.createElement("list");
// item is a westley playlist, adjust subproducers ids
id = (parentId + 1) * 10000 + id;
}
- if (type == DocClipBase::AUDIO || type == DocClipBase::VIDEO || type == DocClipBase::AV || type == DocClipBase::IMAGE || type == DocClipBase::PLAYLIST)
+ if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST)
{
KUrl resource = KUrl(producer.attribute("resource"));
if (!resource.isEmpty()) {
}
}
- else if (type == DocClipBase::COLOR) {
+ else if (type == COLOR) {
QString colour = producer.attribute("colour");
QPixmap pix(60, 40);
colour = colour.replace(0, 2, "#");
#include <KUndoStack>
#include <KTreeWidgetSearchLine>
-#include "docclipbase.h"
+#include "definitions.h"
#include "kdenlivedoc.h"
#include "renderer.h"
#include "timecode.h"
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
+#include <KLocale>
+
#include "resizeclipcommand.h"
ResizeClipCommand::ResizeClipCommand(CustomTrackView *view, const QPointF startPos, const QPointF endPos, bool resizeClipStart, bool doIt)