1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "markerdialog.h"
23 #include "kdenlivesettings.h"
25 #include <QWheelEvent>
29 MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, const QString &caption, QWidget * parent) :
35 setFont(KGlobalSettings::toolBarFont());
37 setWindowTitle(caption);
39 m_in = new TimecodeDisplay(tc, this);
40 inputLayout->addWidget(m_in);
41 m_in->setValue(t.time());
43 m_previewTimer = new QTimer(this);
46 m_in->setRange(0, m_clip->duration().frames(tc.fps()));
47 m_previewTimer->setInterval(500);
48 connect(m_previewTimer, SIGNAL(timeout()), this, SLOT(slotUpdateThumb()));
49 m_profile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
50 m_dar = m_profile->dar();
52 QDomElement mlt = doc.createElement("mlt");
53 QDomElement play = doc.createElement("mlt");
55 mlt.appendChild(play);
56 play.appendChild(doc.importNode(clip->toXML(), true));
57 //char *tmp = doc.toString().toUtf8().data();
58 m_producer = new Mlt::Producer(*m_profile, "xml-string", doc.toString().toUtf8().data());
60 int width = 100.0 * m_dar;
61 if (width % 2 == 1) width++;
62 QPixmap p(width, 100);
63 QString colour = clip->getProperty("colour");
65 switch (m_clip->clipType()) {
70 connect(this, SIGNAL(updateThumb()), m_previewTimer, SLOT(start()));
73 p = QPixmap::fromImage(KThumb::getFrame(m_producer, m_in->value(), width, 100));
76 colour = colour.replace(0, 2, "#");
77 p.fill(QColor(colour.left(7)));
84 clip_thumb->setFixedWidth(p.width());
85 clip_thumb->setFixedHeight(p.height());
86 clip_thumb->setPixmap(p);
88 connect(m_in, SIGNAL(editingFinished()), this, SIGNAL(updateThumb()));
90 clip_thumb->setHidden(true);
93 marker_comment->setText(t.comment());
94 marker_comment->selectAll();
95 marker_comment->setFocus();
100 MarkerDialog::~MarkerDialog()
102 delete m_previewTimer;
107 void MarkerDialog::slotUpdateThumb()
109 m_previewTimer->stop();
110 int pos = m_in->value();
111 int width = 100.0 * m_dar;
112 if (width % 2 == 1) width++;
113 QPixmap p = QPixmap::fromImage(KThumb::getFrame(m_producer, pos, width, 100));
115 clip_thumb->setPixmap(p);
117 kDebug() << "!!!!!!!!!!! ERROR CREATING THUMB";
120 CommentedTime MarkerDialog::newMarker()
122 return CommentedTime(m_in->gentime(), marker_comment->text());
125 #include "markerdialog.moc"