From d5363787d623deff631d695dead90aabba0610a3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 15 Aug 2010 18:37:41 +0000 Subject: [PATCH] Allow to add image sequence through the usual "add clip" dialog svn path=/trunk/kdenlive/; revision=4723 --- src/clipmanager.cpp | 2 +- src/kdenlivesettings.kcfg | 12 +++++++++++- src/projectlist.cpp | 37 ++++++++++++++++++++++++++++++++++-- src/slideshowclip.cpp | 31 ++++++++++++++++++++++++++++-- src/slideshowclip.h | 3 +++ src/widgets/configmisc_ui.ui | 32 +++++++++++++++++++++++++++---- 6 files changed, 107 insertions(+), 10 deletions(-) diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 9e7d0fdf..2e9367b9 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -316,7 +316,7 @@ void ClipManager::slotAddClipList(const KUrl::List urls, const QString group, co if (out > 0) prod.setAttribute("out", out); else - prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration()) - 1); + prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); } else txtfile.close(); } diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 0b0713fc..c81bd7a3 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -34,7 +34,17 @@ 00:00:05:00 - + + + + 00:00:00:01 + + + + + true + + 00:00:05:00 diff --git a/src/projectlist.cpp b/src/projectlist.cpp index dc5d2398..b3ede704 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -1077,8 +1077,41 @@ void ProjectList::slotAddClip(const QList givenList, const QString &group if (givenList.isEmpty()) { QString allExtensions = getExtensions(); const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files"); - list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), dialogFilter, this); - + QCheckBox *b = new QCheckBox(i18n("Import image sequence")); + b->setChecked(KdenliveSettings::autoimagesequence()); + KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, this, b); + d->setOperationMode(KFileDialog::Opening); + d->setMode(KFile::Files); + d->exec(); + list = d->selectedUrls(); + if (b->isChecked() && list.count() == 1) { + // Check for image sequence + KUrl url = list.at(0); + QString fileName = url.fileName().section('.', 0, -2); + if (fileName.at(fileName.size() - 1).isDigit()) { + KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); + if (item.mimetype().startsWith("image")) { + int count = SlideshowClip::sequenceCount(url); + // import as sequence if we found at least 5 images in the sequence + if (count > 4) { + delete d; + QStringList groupInfo = getGroup(); + + // get image sequence base name + while (fileName.at(fileName.size() - 1).isDigit()) { + fileName.chop(1); + } + QString folder = url.directory(KUrl::AppendTrailingSlash); + QString ext = url.path().section('.', -1); + folder.append(fileName + "%d." + ext); + + m_doc->slotCreateSlideshowClipFile(fileName, folder, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()), false, false, m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0, groupInfo.at(0), groupInfo.at(1)); + return; + } + } + } + } + delete d; } else { for (int i = 0; i < givenList.count(); i++) list << givenList.at(i); diff --git a/src/slideshowclip.cpp b/src/slideshowclip.cpp index 614fbe2c..46923c52 100644 --- a/src/slideshowclip.cpp +++ b/src/slideshowclip.cpp @@ -61,7 +61,7 @@ SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) : m_view.clip_duration->setInputMask(""); m_view.clip_duration->setValidator(m_timecode.validator()); - m_view.clip_duration->setText(m_timecode.reformatSeparators(KdenliveSettings::image_duration())); + m_view.clip_duration->setText(m_timecode.reformatSeparators(KdenliveSettings::sequence_duration())); m_view.luma_duration->setInputMask(""); m_view.luma_duration->setValidator(m_timecode.validator()); m_view.luma_duration->setText(m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps())))); @@ -149,6 +149,33 @@ void SlideshowClip::slotEnableLumaFile(int state) m_view.label_softness->setEnabled(enable); } +// static +int SlideshowClip::sequenceCount(KUrl file) +{ + // find pattern + QString filter = file.fileName(); + QString ext = filter.section('.', -1); + filter = filter.section('.', 0, -2); + bool hasDigit = false; + while (filter.at(filter.size() - 1).isDigit()) { + hasDigit = true; + filter.remove(filter.size() - 1, 1); + } + if (!hasDigit) return 0; + + QString regexp = "^" + filter + "\\d+\\." + ext + "$"; + QRegExp rx(regexp); + + QDir dir(file.directory()); + QStringList result = dir.entryList(QDir::Files); + + int count = 0; + foreach(const QString &path, result) { + if (rx.exactMatch(path)) count ++; + } + return count; +} + void SlideshowClip::parseFolder() { m_view.icon_list->clear(); @@ -257,7 +284,7 @@ QString SlideshowClip::selectedPath() const filter = filter.section('.', 0, -2); while (filter.at(filter.size() - 1).isDigit()) { - filter.remove(filter.size() - 1, 1); + filter.chop(1); } extension = filter + "%d." + ext; } diff --git a/src/slideshowclip.h b/src/slideshowclip.h index 2bd70acb..9120de9a 100644 --- a/src/slideshowclip.h +++ b/src/slideshowclip.h @@ -47,6 +47,9 @@ public: QString lumaFile() const; int softness() const; + /** @brief Check if there are several files with filename pattern, like: image_001.jpg, image_002.jpg,... */ + static int sequenceCount(KUrl file); + private slots: void parseFolder(); void slotEnableLuma(int state); diff --git a/src/widgets/configmisc_ui.ui b/src/widgets/configmisc_ui.ui index 0d155884..d1dc0f9b 100644 --- a/src/widgets/configmisc_ui.ui +++ b/src/widgets/configmisc_ui.ui @@ -6,8 +6,8 @@ 0 0 - 348 - 242 + 329 + 245 @@ -37,7 +37,7 @@ Default Durations - + @@ -80,10 +80,27 @@ + + + + Image sequence + + + + + + + 99:99:99:99; + + + ::: + + + - + Qt::Vertical @@ -110,6 +127,13 @@ + + + + Automatically import image sequences + + + -- 2.39.2