]> git.sesse.net Git - kdenlive/blobdiff - src/slideshowclip.cpp
Correctly update monitor when changing a title clip duration
[kdenlive] / src / slideshowclip.cpp
index 0169630fad7016b1e060f44729578aeef9c5bcd5..26028f2abc6cad1c194bceb5c362ad93441c3bd5 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;
@@ -63,7 +69,8 @@ SlideshowClip::SlideshowClip(QWidget * parent) :
     foreach(const QString &folder, customLumas) {
         QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
         foreach(const QString &fname, filesnames) {
-            m_view.luma_file->addItem(KIcon(folder + '/' + fname), fname, folder + '/' + fname);
+            QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
+            m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
         }
     }
 
@@ -74,10 +81,11 @@ SlideshowClip::SlideshowClip(QWidget * parent) :
     QDir lumafolder(folder);
     QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
     foreach(const QString &fname, filesnames) {
-        m_view.luma_file->addItem(KIcon(folder + '/' + fname), fname, folder + '/' + fname);
+        QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
+        m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
     }
 
-    adjustSize();
+    //adjustSize();
 }
 
 void SlideshowClip::slotEnableLuma(int state)
@@ -85,6 +93,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());
@@ -118,7 +127,7 @@ void SlideshowClip::parseFolder()
     m_count = result.count();
     if (m_count == 0) m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
     else m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
-    m_view.label_info->setText(i18n("%1 images found", m_count));
+    m_view.label_info->setText(i18np("1 image found", "%1 images found", m_count));
     QListWidgetItem *item;
     int i = 0;
     KIcon unknownicon("unknown");
@@ -164,6 +173,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 +202,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 +215,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_view.luma_duration_frames->setValue(m_timecode.getFrameCount(m_view.luma_duration->text()));
+    } 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"