X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fslideshowclip.cpp;h=dcdbd845c3162986f73e525704bc0a1d50a7e0c4;hb=11a50a78e6d3c8bc7e1d189ec01233c4a33b7387;hp=614fbe2c02ceb704773ba14fc162f6a53d2d979a;hpb=a0d8d105b05a5c282fa90279f19747b6bd18ba2c;p=kdenlive diff --git a/src/slideshowclip.cpp b/src/slideshowclip.cpp index 614fbe2c..dcdbd845 100644 --- a/src/slideshowclip.cpp +++ b/src/slideshowclip.cpp @@ -58,10 +58,16 @@ SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) : m_view.image_type->addItem("TGA (*.tga)", "tga"); m_view.image_type->addItem("TIFF (*.tiff)", "tiff"); m_view.image_type->addItem("Open EXR (*.exr)", "exr"); + m_view.animation->addItem(i18n("None"), QString()); + m_view.animation->addItem(i18n("Pan"), "Pan"); + m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass"); + m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom"); + m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass"); + m_view.animation->addItem(i18n("Zoom"), "Zoom"); + m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass"); 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.luma_duration->setInputMask(""); m_view.luma_duration->setValidator(m_timecode.validator()); m_view.luma_duration->setText(m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps())))); @@ -76,6 +82,7 @@ SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) : connect(m_view.method_mime, SIGNAL(toggled(bool)), this, SLOT(slotMethodChanged(bool))); slotMethodChanged(m_view.method_mime->isChecked()); + // Check for Kdenlive installed luma files QStringList filters; filters << "*.pgm" << "*.png"; @@ -149,6 +156,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(); @@ -240,26 +274,58 @@ void SlideshowClip::slotSetPixmap(const KFileItem &fileItem, const QPixmap &pix) } -QString SlideshowClip::selectedPath() const +QString SlideshowClip::selectedPath() { - QString extension; - QString folder; + return selectedPath(m_view.folder_url->url(), m_view.method_mime->isChecked(), ".all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString(), &m_count); - bool isMime = m_view.method_mime->isChecked(); + +} +// static +QString SlideshowClip::selectedPath(KUrl url, bool isMime, QString extension, int *count) +{ + QString folder; if (isMime) { - folder = m_view.folder_url->url().path(KUrl::AddTrailingSlash); - extension = ".all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString(); + folder = url.path(KUrl::AddTrailingSlash); } else { - folder = m_view.pattern_url->url().directory(KUrl::AppendTrailingSlash); - QString filter = m_view.pattern_url->url().fileName(); - QString ext = filter.section('.', -1); + folder = url.directory(KUrl::AppendTrailingSlash); + QString filter = url.fileName(); + QString ext = '.' + filter.section('.', -1); 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; + // Check that the first image exists and which format it has (image1.jpg or image001.jpg, ...) + + // Find first image in sequence + QString regexp = "^" + filter + "\\d+" + ext + "$"; + QRegExp rx(regexp); + QStringList entries; + + QDir dir(folder); + QStringList result = dir.entryList(QDir::Files); + int precision = 1; + QString pathValue; + QMap sortedList; + foreach(const QString &path, result) { + if (rx.exactMatch(path)) { + pathValue = path.section('.', 0, -2); + pathValue.remove(0, filter.size()); + sortedList.insert(pathValue.toInt(), path); + } + } + *count = sortedList.size(); + if (*count == 0) kDebug() << "No IMAGE FOUND!!!!!!!"; + else { + QMapIterator i(sortedList); + i.next(); + QString result = i.value(); + result.remove(0, filter.size()); + result = result.section('.', 0, -2); + precision = result.size(); + } + extension = filter + "%." + QString::number(precision) + "d" + ext; } return folder + extension; } @@ -294,6 +360,11 @@ bool SlideshowClip::loop() const return m_view.slide_loop->isChecked(); } +bool SlideshowClip::crop() const +{ + return m_view.slide_crop->isChecked(); +} + bool SlideshowClip::fade() const { return m_view.slide_fade->isChecked(); @@ -314,6 +385,12 @@ QString SlideshowClip::lumaFile() const return m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString(); } +QString SlideshowClip::animation() const +{ + if (m_view.animation->itemData(m_view.animation->currentIndex()).isNull()) return QString(); + return m_view.animation->itemData(m_view.animation->currentIndex()).toString(); +} + void SlideshowClip::slotUpdateDurationFormat(int ix) { bool framesFormat = ix == 1; @@ -340,17 +417,39 @@ 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.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.stackedWidget->setCurrentIndex(1); KdenliveSettings::setSlideshowbymime(false); } parseFolder(); } - +// static +QString SlideshowClip::animationToGeometry(const QString &animation, int &ttl) +{ + QString geometry; + if (animation.startsWith("Pan and zoom")) { + geometry = QString().sprintf("0=0,0:100%%x100%%;%d=-14%%,-14%%:120%%x120%%;%d=-5%%,-5%%:110%%x110%%;%d=0,0:110%%x110%%;%d=0,-5%%:110%%x110%%;%d=-5%%,0:110%%x110%%", + ttl - 1, ttl, ttl * 2 - 1, ttl * 2, ttl * 3 - 1); + ttl *= 3; + } else if (animation.startsWith("Pan")) { + geometry = QString().sprintf("0=-5%%,-5%%:110%%x110%%;%d=0,0:110%%x110%%;%d=0,0:110%%x110%%;%d=0,-5%%:110%%x110%%;%d=0,-5%%:110%%x110%%;%d=-5%%,-5%%:110%%x110%%;%d=0,-5%%:110%%x110%%;%d=-5%%,0:110%%x110%%", + ttl - 1, ttl, ttl * 2 - 1, ttl * 2, ttl * 3 - 1, ttl * 3, ttl * 4 - 1); + ttl *= 4; + } else if (animation.startsWith("Zoom")) { + geometry = QString().sprintf("0=0,0:100%%x100%%;%d=-14%%,-14%%:120%%x120%%", ttl - 1); + } + return geometry; +} #include "slideshowclip.moc"