X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fslideshowclip.cpp;h=c4c88cdaea75d6c6e84c8a23a7eb7a7a44400ac8;hb=b6d6c25f1bd07f11a0ceaf32a3a5bcaeab367336;hp=8a0b5c9716709a61684e8e7606f2c26cff913dbd;hpb=3b176bab2ad91159c0a4a7dbe5f278f646115218;p=kdenlive diff --git a/src/slideshowclip.cpp b/src/slideshowclip.cpp index 8a0b5c97..c4c88cda 100644 --- a/src/slideshowclip.cpp +++ b/src/slideshowclip.cpp @@ -28,7 +28,7 @@ #include -SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) : +SlideshowClip::SlideshowClip(const Timecode &tc, QWidget * parent) : QDialog(parent), m_count(0), m_timecode(tc), @@ -42,9 +42,9 @@ SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) : m_view.icon_list->setIconSize(QSize(50, 50)); m_view.show_thumbs->setChecked(KdenliveSettings::showslideshowthumbs()); - connect(m_view.folder_url, SIGNAL(textChanged(const QString &)), this, SLOT(parseFolder())); + connect(m_view.folder_url, SIGNAL(textChanged(QString)), this, SLOT(parseFolder())); connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder())); - connect(m_view.pattern_url, SIGNAL(textChanged(const QString &)), this, SLOT(parseFolder())); + connect(m_view.pattern_url, SIGNAL(textChanged(QString)), this, SLOT(parseFolder())); connect(m_view.show_thumbs, SIGNAL(stateChanged(int)), this, SLOT(slotEnableThumbs(int))); connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int))); @@ -112,9 +112,7 @@ SlideshowClip::SlideshowClip(Timecode tc, QWidget * parent) : SlideshowClip::~SlideshowClip() { - if (m_thumbJob) { - delete m_thumbJob; - } + delete m_thumbJob; } void SlideshowClip::slotEnableLuma(int state) @@ -139,7 +137,7 @@ void SlideshowClip::slotEnableThumbs(int state) } else { KdenliveSettings::setShowslideshowthumbs(false); if (m_thumbJob) { - disconnect(m_thumbJob, SIGNAL(gotPreview(const KFileItem &, const QPixmap &)), this, SLOT(slotSetPixmap(const KFileItem &, const QPixmap &))); + disconnect(m_thumbJob, SIGNAL(gotPreview(KFileItem,QPixmap)), this, SLOT(slotSetPixmap(KFileItem,QPixmap))); m_thumbJob->kill(); m_thumbJob = NULL; } @@ -156,44 +154,6 @@ void SlideshowClip::slotEnableLumaFile(int state) m_view.label_softness->setEnabled(enable); } -// static -//TODO: sequence begin -int SlideshowClip::sequenceCount(KUrl file) -{ - // find pattern - int count = 0; - QString filter = file.fileName(); - QString ext = filter.section('.', -1); - filter = filter.section('.', 0, -2); - int fullSize = filter.size(); - bool hasDigit = false; - while (filter.at(filter.size() - 1).isDigit()) { - hasDigit = true; - filter.remove(filter.size() - 1, 1); - } - if (!hasDigit) return 0; - - - // 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 = firstFrame; gap < 100; i++) { - path = filter + QString::number(i).rightJustified(precision, '0', false) + ext; - if (dir.exists(path)) { - count ++; - gap = 0; - } else { - gap++; - } - } - return count; -} - void SlideshowClip::parseFolder() { m_view.icon_list->clear(); @@ -230,7 +190,7 @@ void SlideshowClip::parseFolder() int firstFrame = m_view.pattern_url->url().fileName().section('.', 0, -2).right(precision).toInt(); QString path; int gap = 0; - for (int i = firstFrame; 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); @@ -259,7 +219,7 @@ void SlideshowClip::slotGenerateThumbs() delete m_thumbJob; }; KFileItemList fileList; - for (int i = 0; i < m_view.icon_list->count(); i++) { + for (int i = 0; i < m_view.icon_list->count(); ++i) { QListWidgetItem* item = m_view.icon_list->item(i); if (item) { QString path = item->data(Qt::UserRole).toString(); @@ -276,13 +236,13 @@ void SlideshowClip::slotGenerateThumbs() #endif m_thumbJob->setAutoDelete(false); - connect(m_thumbJob, SIGNAL(gotPreview(const KFileItem &, const QPixmap &)), this, SLOT(slotSetPixmap(const KFileItem &, const QPixmap &))); + connect(m_thumbJob, SIGNAL(gotPreview(KFileItem,QPixmap)), this, SLOT(slotSetPixmap(KFileItem,QPixmap))); m_thumbJob->start(); } void SlideshowClip::slotSetPixmap(const KFileItem &fileItem, const QPixmap &pix) { - for (int i = 0; i < m_view.icon_list->count(); i++) { + for (int i = 0; i < m_view.icon_list->count(); ++i) { QListWidgetItem* item = m_view.icon_list->item(i); if (item) { QString path = item->data(Qt::UserRole).toString(); @@ -309,7 +269,7 @@ QString SlideshowClip::selectedPath() } // static -int SlideshowClip::getFrameNumberFromPath(KUrl path) +int SlideshowClip::getFrameNumberFromPath(const KUrl &path) { QString filter = path.fileName(); filter = filter.section('.', 0, -2); @@ -321,7 +281,7 @@ int SlideshowClip::getFrameNumberFromPath(KUrl path) } // static -QString SlideshowClip::selectedPath(KUrl url, bool isMime, QString extension, QStringList *list) +QString SlideshowClip::selectedPath(const KUrl &url, bool isMime, QString extension, QStringList *list) { QString folder; if (isMime) { @@ -348,14 +308,11 @@ QString SlideshowClip::selectedPath(KUrl url, bool isMime, QString extension, QS int precision = fullSize - filter.size(); int firstFrame = firstFrameData.right(precision).toInt(); - // Workaround bug in MLT image sequence detection - if (firstFrame < 3) firstFrame = 0; - // Check how many files we have QDir dir(folder); QString path; int gap = 0; - for (int i = firstFrame; 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); @@ -364,8 +321,8 @@ QString SlideshowClip::selectedPath(KUrl url, bool isMime, QString extension, QS gap++; } } - if (firstFrame > 0) extension = filter + '%' + QString::number(firstFrame).rightJustified(precision, '0', false) + 'd' + ext; - else extension = filter + "%0" + QString::number(precision) + 'd' + ext; + extension = filter + "%0" + QString::number(precision) + 'd' + ext; + if (firstFrame > 0) extension.append(QString("?begin:%1").arg(firstFrame)); } kDebug() << "// FOUND " << (*list).count() << " items for " << url.path(); return folder + extension;