]> git.sesse.net Git - kdenlive/blobdiff - src/slideshowclip.cpp
Image sequences can now start at an arbitrary frame, just select the first one in...
[kdenlive] / src / slideshowclip.cpp
index dbe15e2dc7c1094bbf5742ecacd4424c4a0c92b7..848780b37f035555c684a948b9490d469204b6a3 100644 (file)
@@ -157,6 +157,7 @@ void SlideshowClip::slotEnableLumaFile(int state)
 }
 
 // static
+//TODO: sequence begin
 int SlideshowClip::sequenceCount(KUrl file)
 {
     // find pattern
@@ -175,12 +176,13 @@ int SlideshowClip::sequenceCount(KUrl file)
 
     // Find number of digits in sequence
     int precision = fullSize - filter.size();
+    int firstFrame = file.fileName().section('.', 0, -2).right(precision).toInt();    
     QString folder = file.directory(KUrl::AppendTrailingSlash);
     // Check how many files we have
     QDir dir(folder);
     QString path;
     int gap = 0;
-    for (int i = 0; gap < 100; i++) {
+    for (int i = firstFrame; gap < 100; i++) {
         path = filter + QString::number(i).rightJustified(precision, '0', false) + ext;
         if (dir.exists(path)) {
             count ++;
@@ -217,12 +219,13 @@ void SlideshowClip::parseFolder()
         filter = filter.section('.', 0, -2);
         int fullSize = filter.size();
         while (filter.at(filter.size() - 1).isDigit()) {
-            filter.remove(filter.size() - 1, 1);
+            filter.chop(1);
         }
         int precision = fullSize - filter.size();
+        int firstFrame = m_view.pattern_url->url().fileName().section('.', 0, -2).right(precision).toInt();
         QString path;
         int gap = 0;
-        for (int i = 0; gap < 100; i++) {
+        for (int i = firstFrame; gap < 100; i++) {
             path = filter + QString::number(i).rightJustified(precision, '0', false) + ext;
             if (dir.exists(path)) {
                 result.append(path);
@@ -297,6 +300,7 @@ QString SlideshowClip::selectedPath()
     else url = m_view.pattern_url->url();
     QString path = selectedPath(url, m_view.method_mime->isChecked(), ".all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString(), &list);
     m_count = list.count();
+    kDebug()<<"// SELECTED PATH: "<<path;
     return path;
 }
 
@@ -324,6 +328,7 @@ QString SlideshowClip::selectedPath(KUrl url, bool isMime, QString extension, QS
         QString ext = '.' + filter.section('.', -1);
         filter = filter.section('.', 0, -2);
         int fullSize = filter.size();
+       QString firstFrameData = filter;
 
         while (filter.at(filter.size() - 1).isDigit()) {
             filter.chop(1);
@@ -331,12 +336,13 @@ QString SlideshowClip::selectedPath(KUrl url, bool isMime, QString extension, QS
 
         // Find number of digits in sequence
         int precision = fullSize - filter.size();
+       int firstFrame = firstFrameData.right(precision).toInt();
 
         // Check how many files we have
         QDir dir(folder);
         QString path;
         int gap = 0;
-        for (int i = 0; gap < 100; i++) {
+        for (int i = firstFrame; gap < 100; i++) {
             path = filter + QString::number(i).rightJustified(precision, '0', false) + ext;
             if (dir.exists(path)) {
                 (*list).append(folder + path);
@@ -345,7 +351,8 @@ QString SlideshowClip::selectedPath(KUrl url, bool isMime, QString extension, QS
                 gap++;
             }
         }
-        extension = filter + "%." + QString::number(precision) + "d" + ext;
+        if (firstFrame > 0) extension = filter + "%" + QString::number(firstFrame).rightJustified(precision, '0', false) + "d" + ext;
+        else extension = filter + "%" + QString::number(precision) + "d" + ext;
     }
     kDebug() << "// FOUND " << (*list).count() << " items for " << url.path();
     return  folder + extension;
@@ -417,15 +424,11 @@ void SlideshowClip::slotUpdateDurationFormat(int ix)
     bool framesFormat = ix == 1;
     if (framesFormat) {
         // switching to frames count, update widget
-        m_view.clip_duration->setInputMask("");
         m_view.clip_duration_frames->setValue(m_timecode.getFrameCount(m_view.clip_duration->text()));
-        m_view.luma_duration->setInputMask("");
         m_view.luma_duration_frames->setValue(m_timecode.getFrameCount(m_view.luma_duration->text()));
     } else {
         // switching to timecode format
-        m_view.clip_duration->setInputMask(m_timecode.mask());
         m_view.clip_duration->setText(m_timecode.getTimecodeFromFrames(m_view.clip_duration_frames->value()));
-        m_view.luma_duration->setInputMask(m_timecode.mask());
         m_view.luma_duration->setText(m_timecode.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
     }
     m_view.clip_duration_frames->setHidden(!framesFormat);
@@ -438,16 +441,12 @@ void SlideshowClip::slotMethodChanged(bool active)
 {
     if (active) {
         // User wants mimetype image sequence
-        if (m_view.clip_duration->text().isEmpty()) {
-            m_view.clip_duration->setText(m_timecode.reformatSeparators(KdenliveSettings::image_duration()));
-        }
+        m_view.clip_duration->setText(m_timecode.reformatSeparators(KdenliveSettings::image_duration()));
         m_view.stackedWidget->setCurrentIndex(0);
         KdenliveSettings::setSlideshowbymime(true);
     } else {
         // User wants pattern image sequence
-        if (m_view.clip_duration->text().isEmpty()) {
-            m_view.clip_duration->setText(m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()));
-        }
+        m_view.clip_duration->setText(m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()));
         m_view.stackedWidget->setCurrentIndex(1);
         KdenliveSettings::setSlideshowbymime(false);
     }
@@ -472,6 +471,7 @@ QString SlideshowClip::animationToGeometry(const QString &animation, int &ttl)
     return geometry;
 }
 
+
 #include "slideshowclip.moc"