]> git.sesse.net Git - kdenlive/commitdiff
Set thumbnail image for clip from monitor context menu
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 28 Jun 2008 12:35:46 +0000 (12:35 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 28 Jun 2008 12:35:46 +0000 (12:35 +0000)
svn path=/branches/KDE4/; revision=2286

src/clipitem.cpp
src/clipproperties.cpp
src/docclipbase.cpp
src/docclipbase.h
src/kthumb.cpp
src/mainwindow.cpp
src/monitor.cpp
src/monitor.h
src/projectlist.cpp
src/renderer.cpp

index 2eece5225e1504be17576560b28d0b635fe52443..28b428c2c3dd6a56102ebfab549c0ace2bcc88ea 100644 (file)
@@ -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;
 }
index bec7b3906d83e35b8ffa506a7b2e58cf2f14d64e..8e9436aec9aca2941898badb0516dcfe517a457b 100644 (file)
@@ -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 {
index 15b4d92b170b1758f18cfd1256b30eadb0341bb3..ed0a33fc87efeaeaef4a5f489f88339c8cbcb23c 100644 (file)
@@ -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;
index 753ec2bbcfd95b3905c0f655fea1841f6a09595a..6c1738a735b61ed810b308f95a86c0daecc8206a 100644 (file)
@@ -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;
 
index 82a8f08a2a96ee4cebe6ab6598b1c0fd9a487842..accd897f5f61d858f3dda172e7da9260a250145a 100644 (file)
@@ -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);
index 589befd761926c909a1a9ee1774b5dc27ddb49e2..bbaa9455df684d000241c617334549ad653ad46f 100644 (file)
@@ -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() {
index c9c537909d7555b3a18f1263286392c1c9f103dc..519e9c00071f623d3edd3be332617900d9821c1b 100644 (file)
@@ -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");
index 1d4c1dd62adbb50136c58ce64c736117ed1ca6f0..5f86a8169f9524e701f57d9bf45152544b7d0d52 100644 (file)
@@ -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
index 96ec5e74d906de1b4cce7d3f7c317403948d16be..8ac3babf0c62b0c6d4a0e09278411dc598df09cd 100644 (file)
@@ -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);
     }
 }
index 127ee7bfd782b0f94a5c6f7f7573d0751dc94e1d..3b5f6fb8244ec64a4ed3bb911b2f6bbab0854ee4 100644 (file)
@@ -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