Set thumbnail image for clip from monitor context menu

svn path=/branches/KDE4/; revision=2286
parent b90210ff
......@@ -873,8 +873,8 @@ QMap <QString, QString> ClipItem::addEffect(QDomElement effect, bool animate) {
update(r);
}
if (m_selectedEffect == -1) {
m_selectedEffect = 0;
setSelectedEffect(m_selectedEffect);
m_selectedEffect = 0;
setSelectedEffect(m_selectedEffect);
}
return effectParams;
}
......
......@@ -90,7 +90,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
if (props.contains("aspect_ratio"))
m_view.clip_ratio->setText(props.value("aspect_ratio"));
QPixmap pix = m_clip->thumbProducer()->getImage(url, 240, 180);
QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), 240, 180);
m_view.clip_thumb->setPixmap(pix);
if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB);
} else {
......
......@@ -23,7 +23,7 @@
#include "clipmanager.h"
DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
m_id(id), m_description(QString()), m_refcount(0), m_projectThumbFrame(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL) {
m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL) {
int type = xml.attribute("type").toInt();
m_clipType = (CLIPTYPE) type;
m_name = xml.attribute("name");
......@@ -135,12 +135,12 @@ KUrl DocClipBase::fileURL() const {
return KUrl();
}
void DocClipBase::setProjectThumbFrame(const uint &ix) {
m_projectThumbFrame = ix;
void DocClipBase::setClipThumbFrame(const uint &ix) {
m_properties.insert("thumbnail", QString::number((int) ix));
}
uint DocClipBase::getProjectThumbFrame() const {
return m_projectThumbFrame;
uint DocClipBase::getClipThumbFrame() const {
return (uint) m_properties.value("thumbnail").toInt();
}
const QString DocClipBase::description() const {
......@@ -161,7 +161,7 @@ const GenTime &DocClipBase::duration() const {
const GenTime &DocClipBase::maxDuration() const {
if (m_clipType == COLOR || m_clipType == IMAGE || m_clipType == TEXT || (m_clipType == SLIDESHOW && m_properties.value("loop") == "1")) {
GenTime dur(10000, KdenliveSettings::project_fps());
const GenTime dur(10000, KdenliveSettings::project_fps());
return dur;
}
return m_duration;
......
......@@ -226,7 +226,6 @@ private: // Private attributes
/** a unique numeric id */
uint m_id;
uint m_projectThumbFrame;
void setAudioThumbCreated(bool isDone);
/** Holds clip infos like fps, size,... */
QMap <QString, QString> m_properties;
......@@ -246,8 +245,8 @@ public slots:
void addSnapMarker(const GenTime & time, QString comment);
QList < GenTime > snapMarkers() const;
QString markerComment(GenTime t);
void setProjectThumbFrame(const uint &ix);
uint getProjectThumbFrame() const;
void setClipThumbFrame(const uint &ix);
uint getClipThumbFrame() const;
void setProperties(QMap <QString, QString> properties);
QMap <QString, QString> properties() const;
......
......@@ -189,7 +189,6 @@ QPixmap KThumb::getImage(KUrl url, int frame, int width, int height) {
Mlt::Producer producer(profile, "westley-xml", tmp);
delete[] tmp;
if (producer.is_blank()) {
pix.fill(Qt::black);
......
......@@ -359,6 +359,7 @@ void MainWindow::slotConnectMonitors() {
connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
}
void MainWindow::setupActions() {
......
......@@ -93,12 +93,22 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
render = new Render(m_name, (int) m_monitorRefresh->winId(), -1, this);
m_monitorRefresh->setRenderer(render);
m_contextMenu = new QMenu(this);
m_contextMenu->addMenu(playMenu);
QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame"));
connect(extractFrame, SIGNAL(triggered()), this, SLOT(slotExtractCurrentFrame()));
connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int)));
connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
if (name != "clip") {
connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int)));
} else {
QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"));
connect(setThumbFrame, SIGNAL(triggered()), this, SLOT(slotSetThumbFrame()));
}
//render->createVideoXWindow(ui.video_frame->winId(), -1);
int width = m_ruler->width();
......@@ -106,11 +116,6 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
m_ruler->setMaximum(width);
m_length = 0;
m_contextMenu = new QMenu(this);
m_contextMenu->addMenu(playMenu);
QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame"));
connect(extractFrame, SIGNAL(triggered()), this, SLOT(slotExtractCurrentFrame()));
connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
kDebug() << "/////// BUILDING MONITOR, ID: " << ui.video_frame->winId();
}
......@@ -136,6 +141,14 @@ void Monitor::wheelEvent(QWheelEvent * event) {
}
}
void Monitor::slotSetThumbFrame() {
if (m_currentClip == NULL) {
return;
}
m_currentClip->setClipThumbFrame((uint) m_position);
emit refreshClipThumbnail(m_currentClip->getId());
}
void Monitor::slotExtractCurrentFrame() {
QPixmap frame = render->extractFrame(m_position);
QString outputFile = KFileDialog::getSaveFileName(KUrl(), "image/png");
......
......@@ -81,6 +81,7 @@ private slots:
void seekCursor(int pos);
void rendererStopped(int pos);
void slotExtractCurrentFrame();
void slotSetThumbFrame();
public slots:
void slotOpenFile(const QString &);
......@@ -101,6 +102,7 @@ public slots:
signals:
void renderPosition(int);
void durationChanged(int);
void refreshClipThumbnail(int);
};
#endif
......@@ -447,8 +447,7 @@ void ProjectList::slotRefreshClipThumbnail(ProjectItem *item) {
if (item) {
int height = 50;
int width = (int)(height * m_render->dar());
QPixmap pix = KThumb::getImage(item->toXml(), item->referencedClip()->getProjectThumbFrame(), width, height);
//QPixmap pix = KThumb::getFrame(item->toXml()), 0, width, height);
QPixmap pix = KThumb::getImage(item->toXml(), item->referencedClip()->getClipThumbFrame(), width, height);
item->setIcon(0, pix);
}
}
......
......@@ -403,10 +403,11 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
delete[] tmp;
if (producer.is_blank()) {
kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: " << doc.toString();
return;
}
int frameNumber = xml.attribute("frame_thumbnail", "0").toInt();
int frameNumber = xml.attribute("thumbnail", "0").toInt();
if (frameNumber != 0) producer.seek(frameNumber);
mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer.get_producer());
......@@ -469,15 +470,15 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
if (context != NULL) {
// Get the video_index
int index = mlt_properties_get_int(properties, "video_index");
#if ENABLE_FFMPEG_CODEC_DESCRIPTION
if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name)
if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name) {
filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->long_name;
else
} else
#endif
if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name) {
filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
}
}
} else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!";
context = (AVFormatContext *) mlt_properties_get_data(properties, "audio_context", NULL);
if (context != NULL) {
// Get the video_index
......
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