]> git.sesse.net Git - kdenlive/commitdiff
Add combobox to select between hh:mm:ss::ff and frame count in slideshow dialog
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 29 May 2009 09:33:24 +0000 (09:33 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 29 May 2009 09:33:24 +0000 (09:33 +0000)
svn path=/trunk/kdenlive/; revision=3441

src/clipproperties.cpp
src/clipproperties.h
src/projectlist.cpp
src/slideshowclip.cpp
src/slideshowclip.h
src/timecode.cpp
src/timecode.h

index a79524337d9d9178b6d4a3bb97645c25c4cd2a09..a24140a9b092db9aae18559178802f744eb031b2 100644 (file)
@@ -157,6 +157,13 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
         else if (path.endsWith("bmp")) m_view.image_type->setCurrentIndex(TYPE_BMP);
         else if (path.endsWith("gif")) m_view.image_type->setCurrentIndex(TYPE_GIF);
         m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
+
+        m_view.slide_duration_format->addItem(i18n("hh:mm:ss::ff"));
+        m_view.slide_duration_format->addItem(i18n("Frames"));
+        connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
+        m_view.slide_duration_frames->setHidden(true);
+        m_view.luma_duration_frames->setHidden(true);
+
         parseFolder();
 
         m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
@@ -247,6 +254,7 @@ void ClipProperties::slotEnableLuma(int state)
     bool enable = false;
     if (state == Qt::Checked) enable = true;
     m_view.luma_duration->setEnabled(enable);
+    m_view.luma_duration_frames->setEnabled(enable);
     m_view.slide_luma->setEnabled(enable);
     if (enable) {
         m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
@@ -409,7 +417,11 @@ QMap <QString, QString> ClipProperties::properties()
             props["resource"] = new_path;
             kDebug() << "////  SLIDE EDIT, NEW:" << new_path << ", OLD; " << old_props.value("resource");
         }
-        int duration = m_tc.getFrameCount(m_view.slide_duration->text(), m_fps);
+        int duration;
+        if (m_view.slide_duration_format->currentIndex() == 1) {
+            // we are in frames mode
+            duration = m_view.slide_duration_frames->value();
+        } else duration = m_tc.getFrameCount(m_view.slide_duration->text(), m_fps);
         if (duration != old_props.value("ttl").toInt()) {
             m_clipNeedsRefresh = true;
             props["ttl"] = QString::number(duration);
@@ -420,7 +432,11 @@ QMap <QString, QString> ClipProperties::properties()
             props["out"] = QString::number(duration * m_count);
         }
         if (m_view.slide_fade->isChecked()) {
-            int luma_duration = m_tc.getFrameCount(m_view.luma_duration->text(), m_fps);
+            int luma_duration;
+            if (m_view.slide_duration_format->currentIndex() == 1) {
+                // we are in frames mode
+                luma_duration = m_view.luma_duration_frames->value();
+            } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text(), m_fps);
             if (luma_duration != old_props.value("luma_duration").toInt()) {
                 m_clipNeedsRefresh = true;
                 props["luma_duration"] = QString::number(luma_duration);
@@ -494,6 +510,28 @@ void ClipProperties::slotCheckMaxLength()
     }
 }
 
+void ClipProperties::slotUpdateDurationFormat(int ix)
+{
+    bool framesFormat = ix == 1;
+    if (framesFormat) {
+        // switching to frames count, update widget
+        m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text(), m_tc.fps()));
+        m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text(), m_tc.fps()));
+        m_view.slide_duration->setHidden(true);
+        m_view.luma_duration->setHidden(true);
+        m_view.slide_duration_frames->setHidden(false);
+        m_view.luma_duration_frames->setHidden(false);
+    } else {
+        // switching to timecode format
+        m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
+        m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
+        m_view.slide_duration_frames->setHidden(true);
+        m_view.luma_duration_frames->setHidden(true);
+        m_view.slide_duration->setHidden(false);
+        m_view.luma_duration->setHidden(false);
+    }
+}
+
 #include "clipproperties.moc"
 
 
index 8d7f8c13a0badf5be26eda7b26a7046716441aaf..bcf971420d5f3fbc3a414926c6e73cef02781405 100644 (file)
@@ -46,6 +46,7 @@ private slots:
     void slotCheckMaxLength();
     void slotEnableLuma(int state);
     void slotEnableLumaFile(int state);
+    void slotUpdateDurationFormat(int ix);
 
 private:
     Ui::ClipProperties_UI m_view;
index 5092babf5db5b5fba09c08eddd0b0ac1e205c167..857b51e88a9902e8c14f63cd9be97cf8bbbac4d7 100644 (file)
@@ -677,7 +677,7 @@ void ProjectList::slotAddColorClip()
 void ProjectList::slotAddSlideshowClip()
 {
     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    SlideshowClip *dia = new SlideshowClip(this);
+    SlideshowClip *dia = new SlideshowClip(m_timecode, this);
 
     if (dia->exec() == QDialog::Accepted) {
 
index 0169630fad7016b1e060f44729578aeef9c5bcd5..d5a16fd2e49fb214bfcb32221b950a8e3878ec57 100644 (file)
 
 #include <QDir>
 
-SlideshowClip::SlideshowClip(QWidget * parent) :
+SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) :
         QDialog(parent),
-        m_count(0)
+        m_count(0),
+        m_timecode(tc)
 {
     setFont(KGlobalSettings::toolBarFont());
     setWindowTitle(i18n("Add Slideshow Clip"));
@@ -54,6 +55,11 @@ SlideshowClip::SlideshowClip(QWidget * parent) :
     m_view.luma_duration->setText("00:00:00:24");
     m_view.folder_url->setUrl(QDir::homePath());
 
+    m_view.clip_duration_format->addItem(i18n("hh:mm:ss::ff"));
+    m_view.clip_duration_format->addItem(i18n("Frames"));
+    connect(m_view.clip_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
+    m_view.clip_duration_frames->setHidden(true);
+    m_view.luma_duration_frames->setHidden(true);
 
     // Check for Kdenlive installed luma files
     QStringList filters;
@@ -85,6 +91,7 @@ void SlideshowClip::slotEnableLuma(int state)
     bool enable = false;
     if (state == Qt::Checked) enable = true;
     m_view.luma_duration->setEnabled(enable);
+    m_view.luma_duration_frames->setEnabled(enable);
     m_view.luma_fade->setEnabled(enable);
     if (enable) {
         m_view.luma_file->setEnabled(m_view.luma_fade->isChecked());
@@ -164,6 +171,10 @@ QString SlideshowClip::clipName() const
 
 QString SlideshowClip::clipDuration() const
 {
+    if (m_view.clip_duration_format->currentIndex() == 1) {
+        // we are in frames mode
+        return m_timecode.getTimecodeFromFrames(m_view.clip_duration_frames->value());
+    }
     return m_view.clip_duration->text();
 }
 
@@ -189,6 +200,10 @@ bool SlideshowClip::fade() const
 
 QString SlideshowClip::lumaDuration() const
 {
+    if (m_view.clip_duration_format->currentIndex() == 1) {
+        // we are in frames mode
+        return m_timecode.getTimecodeFromFrames(m_view.luma_duration_frames->value());
+    }
     return m_view.luma_duration->text();
 }
 
@@ -198,6 +213,24 @@ QString SlideshowClip::lumaFile() const
     return m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
 }
 
+void SlideshowClip::slotUpdateDurationFormat(int ix)
+{
+    bool framesFormat = ix == 1;
+    if (framesFormat) {
+        // switching to frames count, update widget
+        m_view.clip_duration_frames->setValue(m_timecode.getFrameCount(m_view.clip_duration->text(), m_timecode.fps()));
+        m_view.luma_duration_frames->setValue(m_timecode.getFrameCount(m_view.luma_duration->text(), m_timecode.fps()));
+    } else {
+        // switching to timecode format
+        m_view.clip_duration->setText(m_timecode.getTimecodeFromFrames(m_view.clip_duration_frames->value()));
+        m_view.luma_duration->setText(m_timecode.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
+    }
+    m_view.clip_duration_frames->setHidden(!framesFormat);
+    m_view.clip_duration->setHidden(framesFormat);
+    m_view.luma_duration_frames->setHidden(!framesFormat);
+    m_view.luma_duration->setHidden(framesFormat);
+}
+
 #include "slideshowclip.moc"
 
 
index f185f64fc61b74a95d687a5b4607189e02a63bab..d9b571729345ec48efb8103e2bced12d76d6a4b5 100644 (file)
@@ -32,7 +32,7 @@ class SlideshowClip : public QDialog
     Q_OBJECT
 
 public:
-    SlideshowClip(QWidget * parent = 0);
+    SlideshowClip(Timecode tc, QWidget * parent = 0);
     /** return selected path for slideshow in MLT format */
     QString selectedPath() const;
     QString clipName() const;
@@ -49,10 +49,12 @@ private slots:
     void slotEnableLuma(int state);
     void slotEnableLumaFile(int state);
     void slotSetItemIcon(int row);
+    void slotUpdateDurationFormat(int ix);
 
 private:
     Ui::SlideshowClip_UI m_view;
     int m_count;
+    Timecode m_timecode;
 };
 
 
index e2fe09e26a0eb38d0ece6b2ce324e33e6db3a577..118e2354c3861433930f26a9624b86af9dc4d729 100644 (file)
@@ -91,7 +91,7 @@ QString Timecode::getTimecode(const GenTime & time, double fps) const
     }
 }
 
-QString Timecode::getTimecodeFromFrames(int frames)
+QString Timecode::getTimecodeFromFrames(int frames) const
 {
     return getTimecodeHH_MM_SS_FF(frames);
 }
index c431b6f5bcadd3ccfd026844303ac03617298a14..e4b32548e275886573e9d7025000df5e70e20fe3 100644 (file)
@@ -52,7 +52,7 @@ public:
     int getFrameCount(const QString duration, double fps) const;
     static QString getEasyTimecode(const GenTime & time, const double &fps);
     static QString getStringTimecode(int frames, const double &fps);
-    QString getTimecodeFromFrames(int frames);
+    QString getTimecodeFromFrames(int frames) const;
     int fps() const;
 
 private: