+void ClipProperties::slotFillMarkersList() {
+ m_view.markers_list->clear();
+ QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
+ for (uint count = 0; count < marks.count(); ++count) {
+ QString time = m_tc.getTimecode(marks[count].time(), m_tc.fps());
+ QStringList itemtext;
+ itemtext << time << marks[count].comment();
+ (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
+ }
+}
+
+void ClipProperties::slotAddMarker() {
+ CommentedTime marker(GenTime(), i18n("Marker"));
+ MarkerDialog d(m_clip, marker, m_tc, i18n("Add Marker"), this);
+ if (d.exec() == QDialog::Accepted) {
+ emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
+ }
+ QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
+}
+
+void ClipProperties::slotEditMarker() {
+ QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
+ int pos = m_view.markers_list->currentIndex().row();
+ if (pos < 0 || pos > marks.count() - 1) return;
+ MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
+ if (d.exec() == QDialog::Accepted) {
+ emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
+ }
+ QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
+}
+
+void ClipProperties::slotDeleteMarker() {
+ QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
+ int pos = m_view.markers_list->currentIndex().row();
+ if (pos < 0 || pos > marks.count() - 1) return;
+ emit addMarker(m_clip->getId(), marks.at(pos).time(), QString());
+
+ QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
+}
+
+const QString &ClipProperties::clipId() const {
+ return m_clip->getId();
+}
+
+
+QMap <QString, QString> ClipProperties::properties() {
+ QMap <QString, QString> props;
+ CLIPTYPE t = m_clip->clipType();
+ QMap <QString, QString> old_props = m_clip->properties();
+
+ if (old_props.value("description") != m_view.clip_description->text())
+ props["description"] = m_view.clip_description->text();
+
+ double aspect = m_view.clip_ar->value();
+ if (m_view.clip_force_ar->isChecked()) {
+ if (aspect != old_props.value("force_aspect_ratio").toDouble()) {
+ props["force_aspect_ratio"] = QString::number(aspect);
+ m_clipNeedsRefresh = true;
+ }
+ } else if (old_props.contains("force_aspect_ratio")) {
+ props["force_aspect_ratio"] = QString();
+ m_clipNeedsRefresh = true;
+ }
+
+ int threads = m_view.clip_threads->value();
+ if (m_view.clip_force_threads->isChecked()) {
+ if (threads != old_props.value("threads").toInt()) {
+ props["threads"] = QString::number(threads);
+ }
+ } else if (old_props.contains("threads")) {
+ props["threads"] = QString();
+ }
+
+ int vindex = m_view.clip_vindex->value();
+ if (m_view.clip_force_vindex->isChecked()) {
+ if (vindex != old_props.value("video_index").toInt()) {
+ props["video_index"] = QString::number(vindex);
+ }
+ } else if (old_props.contains("video_index")) {
+ props["video_index"] = QString();
+ }
+
+ int aindex = m_view.clip_aindex->value();
+ if (m_view.clip_force_aindex->isChecked()) {
+ if (aindex != old_props.value("audio_index").toInt()) {
+ props["audio_index"] = QString::number(aindex);
+ }
+ } else if (old_props.contains("audio_index")) {
+ props["audio_index"] = QString();
+ }
+
+ if (t == COLOR) {
+ QString new_color = m_view.clip_color->color().name();
+ if (new_color != QString("#" + old_props.value("colour").right(8).left(6))) {
+ m_clipNeedsRefresh = true;
+ props["colour"] = "0x" + new_color.right(6) + "ff";
+ }
+ int duration = m_tc.getFrameCount(m_view.clip_duration->text(), m_fps);
+ if (duration != m_clip->duration().frames(m_fps)) {
+ props["out"] = QString::number(duration);
+ }
+ } else if (t == IMAGE) {
+ if ((int) m_view.image_transparency->isChecked() != old_props.value("transparency").toInt()) {
+ props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
+ m_clipNeedsRefresh = true;
+ }
+ int duration = m_tc.getFrameCount(m_view.clip_duration->text(), m_fps);
+ if (duration != m_clip->duration().frames(m_fps)) {
+ props["out"] = QString::number(duration);
+ }
+ } else if (t == SLIDESHOW) {
+ QString value = QString::number((int) m_view.slide_loop->isChecked());
+ if (old_props.value("loop") != value) props["loop"] = value;
+ value = QString::number((int) m_view.slide_fade->isChecked());
+ if (old_props.value("fade") != value) props["fade"] = value;
+ value = QString::number((int) m_view.luma_softness->value());
+ if (old_props.value("softness") != value) props["softness"] = value;
+
+ QString extension;
+ switch (m_view.image_type->currentIndex()) {
+ case TYPE_PNG:
+ extension = "/.all.png";
+ break;
+ case TYPE_BMP:
+ extension = "/.all.bmp";
+ break;
+ case TYPE_GIF:
+ extension = "/.all.gif";
+ break;
+ default:
+ extension = "/.all.jpg";
+ break;
+ }
+ QString new_path = m_view.clip_path->text() + extension;
+ if (new_path != old_props.value("resource")) {
+ m_clipNeedsRefresh = true;
+ props["resource"] = new_path;
+ kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << old_props.value("resource");
+ }
+ int duration = m_tc.getFrameCount(m_view.slide_duration->text(), m_fps);
+ if (duration != old_props.value("ttl").toInt()) {
+ m_clipNeedsRefresh = true;
+ props["ttl"] = QString::number(duration);
+ props["out"] = QString::number(duration * m_count);
+ }
+ if (duration * m_count != old_props.value("out").toInt()) {
+ m_clipNeedsRefresh = true;
+ props["out"] = QString::number(duration * m_count);
+ }
+ if (m_view.slide_fade->isChecked()) {
+ int luma_duration = m_tc.getFrameCount(m_view.luma_duration->text(), m_fps);
+ if (luma_duration != old_props.value("luma_duration").toInt()) {
+ m_clipNeedsRefresh = true;
+ props["luma_duration"] = QString::number(luma_duration);
+ }
+ QString lumaFile;
+ if (m_view.slide_luma->isChecked())
+ lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
+ if (lumaFile != old_props.value("luma_file")) {
+ m_clipNeedsRefresh = true;
+ props["luma_file"] = lumaFile;
+ }
+ } else {
+ if (old_props.value("luma_file") != QString()) {
+ props["luma_file"] = QString();
+ }
+ }
+
+ }
+ return props;
+}
+
+bool ClipProperties::needsTimelineRefresh() const {
+ return m_clipNeedsRefresh;
+}
+
+void ClipProperties::parseFolder() {
+
+ QDir dir(m_view.clip_path->text());
+ QStringList filters;
+ QString extension;
+ switch (m_view.image_type->currentIndex()) {
+ case TYPE_PNG:
+ filters << "*.png";
+ extension = "/.all.png";
+ break;
+ case TYPE_BMP:
+ filters << "*.bmp";
+ extension = "/.all.bmp";
+ break;
+ case TYPE_GIF:
+ filters << "*.gif";
+ extension = "/.all.gif";
+ break;
+ default:
+ filters << "*.jpg";
+ // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
+ // << "*.jpeg";
+ extension = "/.all.jpg";
+ break;
+ }
+
+ dir.setNameFilters(filters);
+ QStringList result = dir.entryList(QDir::Files);
+ m_count = result.count();
+ m_view.slide_info->setText(i18n("%1 images found", m_count));
+ QDomElement xml = m_clip->toXML();
+ xml.setAttribute("resource", m_view.clip_path->text() + extension);
+ QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(m_view.clip_path->text() + extension), 1, 240, 180);
+ QMap <QString, QString> props = m_clip->properties();
+ m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
+ m_view.clip_thumb->setPixmap(pix);
+}
+