1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "clipproperties.h"
22 #include "kdenlivesettings.h"
24 #include "markerdialog.h"
26 #include <KStandardDirs>
32 static const int VIDEOTAB = 0;
33 static const int AUDIOTAB = 1;
34 static const int COLORTAB = 2;
35 static const int SLIDETAB = 3;
36 static const int IMAGETAB = 4;
37 static const int MARKERTAB = 5;
38 static const int METATAB = 6;
39 static const int ADVANCEDTAB = 7;
41 ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidget * parent) :
47 m_clipNeedsRefresh(false),
48 m_clipNeedsReLoad(false)
50 setFont(KGlobalSettings::toolBarFont());
52 KUrl url = m_clip->fileURL();
53 m_view.clip_path->setText(url.path());
54 m_view.clip_description->setText(m_clip->description());
55 QMap <QString, QString> props = m_clip->properties();
57 m_view.clip_force_out->setHidden(true);
58 m_view.clip_out->setHidden(true);
60 if (props.contains("force_aspect_ratio") && props.value("force_aspect_ratio").toDouble() > 0) {
61 m_view.clip_force_ar->setChecked(true);
62 m_view.clip_ar->setEnabled(true);
63 m_view.clip_ar->setValue(props.value("force_aspect_ratio").toDouble());
66 if (props.contains("force_fps") && props.value("force_fps").toDouble() > 0) {
67 m_view.clip_force_framerate->setChecked(true);
68 m_view.clip_framerate->setEnabled(true);
69 m_view.clip_framerate->setValue(props.value("force_fps").toDouble());
72 if (props.contains("force_progressive")) {
73 m_view.clip_force_progressive->setChecked(true);
74 m_view.clip_progressive->setEnabled(true);
75 m_view.clip_progressive->setValue(props.value("force_progressive").toInt());
78 if (props.contains("threads") && props.value("threads").toInt() != 1) {
79 m_view.clip_force_threads->setChecked(true);
80 m_view.clip_threads->setEnabled(true);
81 m_view.clip_threads->setValue(props.value("threads").toInt());
84 if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
85 m_view.clip_force_vindex->setChecked(true);
86 m_view.clip_vindex->setEnabled(true);
87 m_view.clip_vindex->setValue(props.value("video_index").toInt());
90 if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
91 m_view.clip_force_aindex->setChecked(true);
92 m_view.clip_aindex->setEnabled(true);
93 m_view.clip_aindex->setValue(props.value("audio_index").toInt());
96 if (props.contains("audio_max")) {
97 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
100 if (props.contains("video_max")) {
101 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
104 // Check for Metadata
105 QMap<QString, QString> meta = m_clip->metadata();
106 QMap<QString, QString>::const_iterator i = meta.constBegin();
107 while (i != meta.constEnd()) {
108 QTreeWidgetItem *metaitem = new QTreeWidgetItem(m_view.metadata_list);
109 metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
110 metaitem->setText(1, i.value());
114 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
115 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
116 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
117 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
118 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
119 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
121 if (props.contains("audiocodec"))
122 m_view.clip_acodec->setText(props.value("audiocodec"));
123 if (props.contains("frequency"))
124 m_view.clip_frequency->setText(props.value("frequency"));
125 if (props.contains("channels"))
126 m_view.clip_channels->setText(props.value("channels"));
128 CLIPTYPE t = m_clip->clipType();
129 if (t != AUDIO && t != AV) {
130 m_view.clip_force_aindex->setEnabled(false);
133 if (t != VIDEO && t != AV) {
134 m_view.clip_force_vindex->setEnabled(false);
138 m_view.tabWidget->removeTab(SLIDETAB);
139 m_view.tabWidget->removeTab(COLORTAB);
140 m_view.tabWidget->removeTab(AUDIOTAB);
141 m_view.tabWidget->removeTab(VIDEOTAB);
142 if (props.contains("frame_size"))
143 m_view.image_size->setText(props.value("frame_size"));
144 if (props.contains("transparency"))
145 m_view.image_transparency->setChecked(props.value("transparency").toInt());
146 int width = 180.0 * KdenliveSettings::project_display_ratio();
147 if (width % 2 == 1) width++;
148 m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
149 } else if (t == COLOR) {
150 m_view.clip_path->setEnabled(false);
151 m_view.tabWidget->removeTab(METATAB);
152 m_view.tabWidget->removeTab(IMAGETAB);
153 m_view.tabWidget->removeTab(SLIDETAB);
154 m_view.tabWidget->removeTab(AUDIOTAB);
155 m_view.tabWidget->removeTab(VIDEOTAB);
156 m_view.clip_thumb->setHidden(true);
157 m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
158 } else if (t == SLIDESHOW) {
160 if (url.fileName().startsWith(".all.")) {
161 // the image sequence is defined by mimetype
162 m_view.clip_path->setText(url.directory());
164 // the image sequence is defined by pattern
165 m_view.slide_type_label->setHidden(true);
166 m_view.image_type->setHidden(true);
167 m_view.clip_path->setText(url.path());
171 m_view.tabWidget->removeTab(METATAB);
172 m_view.tabWidget->removeTab(IMAGETAB);
173 m_view.tabWidget->removeTab(COLORTAB);
174 m_view.tabWidget->removeTab(AUDIOTAB);
175 m_view.tabWidget->removeTab(VIDEOTAB);
177 //WARNING: Keep in sync with slideshowclip.cpp
178 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
179 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
180 m_view.image_type->addItem("PNG (*.png)", "png");
181 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
182 m_view.image_type->addItem("GIF (*.gif)", "gif");
183 m_view.image_type->addItem("TGA (*.tga)", "tga");
184 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
185 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
187 m_view.slide_loop->setChecked(props.value("loop").toInt());
188 m_view.slide_crop->setChecked(props.value("crop").toInt());
189 m_view.slide_fade->setChecked(props.value("fade").toInt());
190 m_view.luma_softness->setValue(props.value("softness").toInt());
191 QString path = props.value("resource");
192 QString ext = path.section('.', -1);
193 for (int i = 0; i < m_view.image_type->count(); i++) {
194 if (m_view.image_type->itemData(i).toString() == ext) {
195 m_view.image_type->setCurrentIndex(i);
199 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
201 m_view.slide_duration_format->addItem(i18n("hh:mm:ss::ff"));
202 m_view.slide_duration_format->addItem(i18n("Frames"));
203 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
204 m_view.slide_duration_frames->setHidden(true);
205 m_view.luma_duration_frames->setHidden(true);
209 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
210 QString lumaFile = props.value("luma_file");
212 // Check for Kdenlive installed luma files
214 filters << "*.pgm" << "*.png";
216 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
217 foreach(const QString &folder, customLumas) {
218 QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
219 foreach(const QString &fname, filesnames) {
220 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
221 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
225 // Check for MLT lumas
226 QString profilePath = KdenliveSettings::mltpath();
227 QString folder = profilePath.section('/', 0, -3);
228 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
229 QDir lumafolder(folder);
230 QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
231 foreach(const QString &fname, filesnames) {
232 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
233 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
236 if (!lumaFile.isEmpty()) {
237 m_view.slide_luma->setChecked(true);
238 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
239 } else m_view.luma_file->setEnabled(false);
240 slotEnableLuma(m_view.slide_fade->checkState());
241 slotEnableLumaFile(m_view.slide_luma->checkState());
242 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
243 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
245 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
246 } else if (t != AUDIO) {
247 m_view.tabWidget->removeTab(IMAGETAB);
248 m_view.tabWidget->removeTab(SLIDETAB);
249 m_view.tabWidget->removeTab(COLORTAB);
250 if (props.contains("frame_size"))
251 m_view.clip_size->setText(props.value("frame_size"));
252 if (props.contains("videocodec"))
253 m_view.clip_vcodec->setText(props.value("videocodec"));
254 if (props.contains("fps")) {
255 m_view.clip_fps->setText(props.value("fps"));
256 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
258 if (props.contains("aspect_ratio"))
259 m_view.clip_ratio->setText(props.value("aspect_ratio"));
260 int width = 180.0 * KdenliveSettings::project_display_ratio();
261 if (width % 2 == 1) width++;
262 QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), width, 180);
263 m_view.clip_thumb->setPixmap(pix);
264 if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB);
266 m_view.tabWidget->removeTab(IMAGETAB);
267 m_view.tabWidget->removeTab(SLIDETAB);
268 m_view.tabWidget->removeTab(COLORTAB);
269 m_view.tabWidget->removeTab(VIDEOTAB);
270 m_view.clip_thumb->setHidden(true);
273 if (t != SLIDESHOW && t != COLOR) {
274 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
275 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
277 m_view.clip_filesize->setHidden(true);
278 m_view.label_size->setHidden(true);
280 m_view.clip_duration->setInputMask("");
281 m_view.clip_duration->setValidator(tc.validator());
282 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
283 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
284 else connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
287 m_view.marker_new->setIcon(KIcon("document-new"));
288 m_view.marker_new->setToolTip(i18n("Add marker"));
289 m_view.marker_edit->setIcon(KIcon("document-properties"));
290 m_view.marker_edit->setToolTip(i18n("Edit marker"));
291 m_view.marker_delete->setIcon(KIcon("trash-empty"));
292 m_view.marker_delete->setToolTip(i18n("Delete marker"));
294 slotFillMarkersList();
295 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
296 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
297 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
298 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
304 // Used for multiple clips editing
305 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
311 m_clipNeedsRefresh(false),
312 m_clipNeedsReLoad(false)
314 setFont(KGlobalSettings::toolBarFont());
315 m_view.setupUi(this);
316 QMap <QString, QString> props = cliplist.at(0)->properties();
317 m_old_props = commonproperties;
319 if (commonproperties.contains("force_aspect_ratio") && !commonproperties.value("force_aspect_ratio").isEmpty() && commonproperties.value("force_aspect_ratio").toDouble() > 0) {
320 m_view.clip_force_ar->setChecked(true);
321 m_view.clip_ar->setEnabled(true);
322 m_view.clip_ar->setValue(commonproperties.value("force_aspect_ratio").toDouble());
325 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
326 m_view.clip_force_framerate->setChecked(true);
327 m_view.clip_framerate->setEnabled(true);
328 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
331 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
332 m_view.clip_force_progressive->setChecked(true);
333 m_view.clip_progressive->setEnabled(true);
334 m_view.clip_progressive->setValue(commonproperties.value("force_progressive").toInt());
337 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
338 m_view.clip_force_threads->setChecked(true);
339 m_view.clip_threads->setEnabled(true);
340 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
343 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
344 m_view.clip_force_vindex->setChecked(true);
345 m_view.clip_vindex->setEnabled(true);
346 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
349 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
350 m_view.clip_force_aindex->setChecked(true);
351 m_view.clip_aindex->setEnabled(true);
352 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
355 if (props.contains("audio_max")) {
356 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
359 if (props.contains("video_max")) {
360 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
363 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
364 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
365 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
366 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
367 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
368 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
370 m_view.tabWidget->removeTab(METATAB);
371 m_view.tabWidget->removeTab(MARKERTAB);
372 m_view.tabWidget->removeTab(IMAGETAB);
373 m_view.tabWidget->removeTab(SLIDETAB);
374 m_view.tabWidget->removeTab(COLORTAB);
375 m_view.tabWidget->removeTab(AUDIOTAB);
376 m_view.tabWidget->removeTab(VIDEOTAB);
378 m_view.clip_path->setHidden(true);
379 m_view.label_path->setHidden(true);
380 m_view.label_description->setHidden(true);
381 m_view.label_size->setHidden(true);
382 m_view.clip_filesize->setHidden(true);
383 m_view.clip_filesize->setHidden(true);
384 m_view.clip_path->setHidden(true);
385 m_view.clip_description->setHidden(true);
386 m_view.clip_thumb->setHidden(true);
387 m_view.label_duration->setHidden(true);
388 m_view.clip_duration->setHidden(true);
390 if (commonproperties.contains("out")) {
391 if (commonproperties.value("out").toInt() > 0) {
392 m_view.clip_force_out->setChecked(true);
393 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
394 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
396 m_view.clip_force_out->setHidden(true);
397 m_view.clip_out->setHidden(true);
403 void ClipProperties::slotEnableLuma(int state)
406 if (state == Qt::Checked) enable = true;
407 m_view.luma_duration->setEnabled(enable);
408 m_view.luma_duration_frames->setEnabled(enable);
409 m_view.slide_luma->setEnabled(enable);
411 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
412 } else m_view.luma_file->setEnabled(false);
413 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
414 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
417 void ClipProperties::slotEnableLumaFile(int state)
420 if (state == Qt::Checked) enable = true;
421 m_view.luma_file->setEnabled(enable);
422 m_view.luma_softness->setEnabled(enable);
423 m_view.label_softness->setEnabled(enable);
426 void ClipProperties::slotFillMarkersList()
428 m_view.markers_list->clear();
429 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
430 for (int count = 0; count < marks.count(); ++count) {
431 QString time = m_tc.getTimecode(marks[count].time());
432 QStringList itemtext;
433 itemtext << time << marks[count].comment();
434 (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
438 void ClipProperties::slotAddMarker()
440 CommentedTime marker(GenTime(), i18n("Marker"));
441 MarkerDialog d(m_clip, marker, m_tc, i18n("Add Marker"), this);
442 if (d.exec() == QDialog::Accepted) {
443 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
445 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
448 void ClipProperties::slotEditMarker()
450 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
451 int pos = m_view.markers_list->currentIndex().row();
452 if (pos < 0 || pos > marks.count() - 1) return;
453 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
454 if (d.exec() == QDialog::Accepted) {
455 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
457 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
460 void ClipProperties::slotDeleteMarker()
462 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
463 int pos = m_view.markers_list->currentIndex().row();
464 if (pos < 0 || pos > marks.count() - 1) return;
465 emit addMarker(m_clip->getId(), marks.at(pos).time(), QString());
467 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
470 const QString &ClipProperties::clipId() const
472 return m_clip->getId();
476 QMap <QString, QString> ClipProperties::properties()
478 QMap <QString, QString> props;
479 CLIPTYPE t = UNKNOWN;
480 if (m_clip != NULL) {
481 t = m_clip->clipType();
482 m_old_props = m_clip->properties();
485 double aspect = m_view.clip_ar->value();
486 if (m_view.clip_force_ar->isChecked()) {
487 if (aspect != m_old_props.value("force_aspect_ratio").toDouble()) {
488 props["force_aspect_ratio"] = QString::number(aspect);
489 m_clipNeedsRefresh = true;
491 } else if (m_old_props.contains("force_aspect_ratio")) {
492 props["force_aspect_ratio"].clear();
493 m_clipNeedsRefresh = true;
496 double fps = m_view.clip_framerate->value();
497 if (m_view.clip_force_framerate->isChecked()) {
498 if (fps != m_old_props.value("force_fps").toDouble()) {
499 props["force_fps"] = QString::number(fps);
500 m_clipNeedsRefresh = true;
502 } else if (m_old_props.contains("force_fps")) {
503 props["force_fps"].clear();
504 m_clipNeedsRefresh = true;
507 int progressive = m_view.clip_progressive->value();
508 if (m_view.clip_force_progressive->isChecked()) {
509 if (progressive != m_old_props.value("force_progressive").toInt()) {
510 props["force_progressive"] = QString::number(progressive);
512 } else if (m_old_props.contains("force_progressive")) {
513 props["force_progressive"].clear();
516 int threads = m_view.clip_threads->value();
517 if (m_view.clip_force_threads->isChecked()) {
518 if (threads != m_old_props.value("threads").toInt()) {
519 props["threads"] = QString::number(threads);
521 } else if (m_old_props.contains("threads")) {
522 props["threads"].clear();
525 int vindex = m_view.clip_vindex->value();
526 if (m_view.clip_force_vindex->isChecked()) {
527 if (vindex != m_old_props.value("video_index").toInt()) {
528 props["video_index"] = QString::number(vindex);
530 } else if (m_old_props.contains("video_index")) {
531 props["video_index"].clear();
534 int aindex = m_view.clip_aindex->value();
535 if (m_view.clip_force_aindex->isChecked()) {
536 if (aindex != m_old_props.value("audio_index").toInt()) {
537 props["audio_index"] = QString::number(aindex);
539 } else if (m_old_props.contains("audio_index")) {
540 props["audio_index"].clear();
543 // If we adjust several clips, return now
544 if (m_clip == NULL) {
545 if (m_view.clip_out->isEnabled()) {
546 int duration = m_tc.getFrameCount(m_view.clip_out->text());
547 if (duration != m_old_props.value("out").toInt()) {
548 props["out"] = QString::number(duration - 1);
554 if (m_old_props.value("description") != m_view.clip_description->text())
555 props["description"] = m_view.clip_description->text();
558 QString new_color = m_view.clip_color->color().name();
559 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
560 m_clipNeedsRefresh = true;
561 props["colour"] = "0x" + new_color.right(6) + "ff";
563 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
564 if (duration != m_clip->duration().frames(m_fps)) {
565 props["out"] = QString::number(duration - 1);
567 } else if (t == IMAGE) {
568 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
569 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
570 //m_clipNeedsRefresh = true;
572 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
573 if (duration != m_clip->duration().frames(m_fps)) {
574 props["out"] = QString::number(duration - 1);
576 } else if (t == SLIDESHOW) {
577 QString value = QString::number((int) m_view.slide_loop->isChecked());
578 if (m_old_props.value("loop") != value) props["loop"] = value;
579 value = QString::number((int) m_view.slide_crop->isChecked());
580 if (m_old_props.value("crop") != value) props["crop"] = value;
581 value = QString::number((int) m_view.slide_fade->isChecked());
582 if (m_old_props.value("fade") != value) props["fade"] = value;
583 value = QString::number((int) m_view.luma_softness->value());
584 if (m_old_props.value("softness") != value) props["softness"] = value;
586 bool isMime = !(m_view.clip_path->text().contains('%'));
588 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
589 QString new_path = m_view.clip_path->text() + extension;
590 if (new_path != m_old_props.value("resource")) {
591 m_clipNeedsReLoad = true;
592 props["resource"] = new_path;
593 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
597 if (m_view.slide_duration_format->currentIndex() == 1) {
598 // we are in frames mode
599 duration = m_view.slide_duration_frames->value();
600 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
601 if (duration != m_old_props.value("ttl").toInt()) {
602 m_clipNeedsRefresh = true;
603 props["ttl"] = QString::number(duration);
604 props["out"] = QString::number(duration * m_count);
607 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
608 m_clipNeedsRefresh = true;
609 props["out"] = QString::number(duration * m_count - 1);
611 if (m_view.slide_fade->isChecked()) {
613 if (m_view.slide_duration_format->currentIndex() == 1) {
614 // we are in frames mode
615 luma_duration = m_view.luma_duration_frames->value();
616 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
617 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
618 m_clipNeedsRefresh = true;
619 props["luma_duration"] = QString::number(luma_duration);
622 if (m_view.slide_luma->isChecked())
623 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
624 if (lumaFile != m_old_props.value("luma_file")) {
625 m_clipNeedsRefresh = true;
626 props["luma_file"] = lumaFile;
629 if (!m_old_props.value("luma_file").isEmpty()) {
630 props["luma_file"].clear();
638 bool ClipProperties::needsTimelineRefresh() const
640 return m_clipNeedsRefresh;
643 bool ClipProperties::needsTimelineReload() const
645 return m_clipNeedsReLoad;
649 void ClipProperties::parseFolder()
651 QString path = m_view.clip_path->text();
652 bool isMime = !(path.contains('%'));
653 if (!isMime) path = KUrl(path).directory();
660 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
661 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
662 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
663 dir.setNameFilters(filters);
666 QStringList result = dir.entryList(QDir::Files);
670 QString filter = KUrl(m_view.clip_path->text()).fileName();
671 QString ext = filter.section('.', -1);
672 filter = filter.section('%', 0, -2);
673 QString regexp = "^" + filter + "\\d+\\." + ext + "$";
676 foreach(const QString &path, result) {
677 if (rx.exactMatch(path)) entries << path;
682 m_count = result.count();
684 // no images, do not accept that
685 m_view.slide_info->setText(i18n("No image found"));
686 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
689 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
690 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
691 QDomElement xml = m_clip->toXML();
692 xml.setAttribute("resource", m_view.clip_path->text() + extension);
693 int width = 180.0 * KdenliveSettings::project_display_ratio();
694 if (width % 2 == 1) width++;
695 QString filePath = m_view.clip_path->text();
696 if (isMime) filePath.append(extension);
697 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
698 QMap <QString, QString> props = m_clip->properties();
699 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
700 m_view.clip_thumb->setPixmap(pix);
703 void ClipProperties::slotCheckMaxLength()
705 if (m_clip->maxDuration() == GenTime()) return;
706 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
707 if (duration > m_clip->maxDuration().frames(m_fps)) {
708 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
712 void ClipProperties::slotUpdateDurationFormat(int ix)
714 bool framesFormat = ix == 1;
716 // switching to frames count, update widget
717 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
718 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
719 m_view.slide_duration->setHidden(true);
720 m_view.luma_duration->setHidden(true);
721 m_view.slide_duration_frames->setHidden(false);
722 m_view.luma_duration_frames->setHidden(false);
724 // switching to timecode format
725 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
726 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
727 m_view.slide_duration_frames->setHidden(true);
728 m_view.luma_duration_frames->setHidden(true);
729 m_view.slide_duration->setHidden(false);
730 m_view.luma_duration->setHidden(false);
734 #include "clipproperties.moc"