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"
25 #include "profilesdialog.h"
27 #include <KStandardDirs>
33 static const int VIDEOTAB = 0;
34 static const int AUDIOTAB = 1;
35 static const int COLORTAB = 2;
36 static const int SLIDETAB = 3;
37 static const int IMAGETAB = 4;
38 static const int MARKERTAB = 5;
39 static const int METATAB = 6;
40 static const int ADVANCEDTAB = 7;
42 ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidget * parent) :
48 m_clipNeedsRefresh(false),
49 m_clipNeedsReLoad(false)
51 setFont(KGlobalSettings::toolBarFont());
53 KUrl url = m_clip->fileURL();
54 m_view.clip_path->setText(url.path());
55 m_view.clip_description->setText(m_clip->description());
56 QMap <QString, QString> props = m_clip->properties();
58 m_view.clip_force_out->setHidden(true);
59 m_view.clip_out->setHidden(true);
61 if (props.contains("force_aspect_ratio") && props.value("force_aspect_ratio").toDouble() > 0) {
62 m_view.clip_force_ar->setChecked(true);
63 m_view.clip_ar->setEnabled(true);
64 m_view.clip_ar->setValue(props.value("force_aspect_ratio").toDouble());
67 if (props.contains("force_fps") && props.value("force_fps").toDouble() > 0) {
68 m_view.clip_force_framerate->setChecked(true);
69 m_view.clip_framerate->setEnabled(true);
70 m_view.clip_framerate->setValue(props.value("force_fps").toDouble());
73 if (props.contains("force_progressive")) {
74 m_view.clip_force_progressive->setChecked(true);
75 m_view.clip_progressive->setEnabled(true);
76 m_view.clip_progressive->setValue(props.value("force_progressive").toInt());
79 if (props.contains("threads") && props.value("threads").toInt() != 1) {
80 m_view.clip_force_threads->setChecked(true);
81 m_view.clip_threads->setEnabled(true);
82 m_view.clip_threads->setValue(props.value("threads").toInt());
85 if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
86 m_view.clip_force_vindex->setChecked(true);
87 m_view.clip_vindex->setEnabled(true);
88 m_view.clip_vindex->setValue(props.value("video_index").toInt());
91 if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
92 m_view.clip_force_aindex->setChecked(true);
93 m_view.clip_aindex->setEnabled(true);
94 m_view.clip_aindex->setValue(props.value("audio_index").toInt());
97 if (props.contains("audio_max")) {
98 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
101 if (props.contains("video_max")) {
102 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
105 // Check for Metadata
106 QMap<QString, QString> meta = m_clip->metadata();
107 QMap<QString, QString>::const_iterator i = meta.constBegin();
108 while (i != meta.constEnd()) {
109 QTreeWidgetItem *metaitem = new QTreeWidgetItem(m_view.metadata_list);
110 metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
111 metaitem->setText(1, i.value());
115 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
116 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
117 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
118 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
119 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
120 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
122 if (props.contains("audiocodec"))
123 m_view.clip_acodec->setText(props.value("audiocodec"));
124 if (props.contains("frequency"))
125 m_view.clip_frequency->setText(props.value("frequency"));
126 if (props.contains("channels"))
127 m_view.clip_channels->setText(props.value("channels"));
129 CLIPTYPE t = m_clip->clipType();
130 if (t != AUDIO && t != AV) {
131 m_view.clip_force_aindex->setEnabled(false);
134 if (t != VIDEO && t != AV) {
135 m_view.clip_force_vindex->setEnabled(false);
139 m_view.tabWidget->removeTab(SLIDETAB);
140 m_view.tabWidget->removeTab(COLORTAB);
141 m_view.tabWidget->removeTab(AUDIOTAB);
142 m_view.tabWidget->removeTab(VIDEOTAB);
143 if (props.contains("frame_size"))
144 m_view.image_size->setText(props.value("frame_size"));
145 if (props.contains("transparency"))
146 m_view.image_transparency->setChecked(props.value("transparency").toInt());
147 int width = 180.0 * KdenliveSettings::project_display_ratio();
148 if (width % 2 == 1) width++;
149 m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
150 } else if (t == COLOR) {
151 m_view.clip_path->setEnabled(false);
152 m_view.tabWidget->removeTab(METATAB);
153 m_view.tabWidget->removeTab(IMAGETAB);
154 m_view.tabWidget->removeTab(SLIDETAB);
155 m_view.tabWidget->removeTab(AUDIOTAB);
156 m_view.tabWidget->removeTab(VIDEOTAB);
157 m_view.clip_thumb->setHidden(true);
158 m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
159 } else if (t == SLIDESHOW) {
161 if (url.fileName().startsWith(".all.")) {
162 // the image sequence is defined by mimetype
163 m_view.clip_path->setText(url.directory());
165 // the image sequence is defined by pattern
166 m_view.slide_type_label->setHidden(true);
167 m_view.image_type->setHidden(true);
168 m_view.clip_path->setText(url.path());
172 m_view.tabWidget->removeTab(METATAB);
173 m_view.tabWidget->removeTab(IMAGETAB);
174 m_view.tabWidget->removeTab(COLORTAB);
175 m_view.tabWidget->removeTab(AUDIOTAB);
176 m_view.tabWidget->removeTab(VIDEOTAB);
178 //WARNING: Keep in sync with slideshowclip.cpp
179 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
180 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
181 m_view.image_type->addItem("PNG (*.png)", "png");
182 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
183 m_view.image_type->addItem("GIF (*.gif)", "gif");
184 m_view.image_type->addItem("TGA (*.tga)", "tga");
185 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
186 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
187 m_view.animation->addItem(i18n("None"), QString());
188 m_view.animation->addItem(i18n("Pan"), "Pan");
189 m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass");
190 m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom");
191 m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass");
192 m_view.animation->addItem(i18n("Zoom"), "Zoom");
193 m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass");
195 m_view.slide_loop->setChecked(props.value("loop").toInt());
196 m_view.slide_crop->setChecked(props.value("crop").toInt());
197 m_view.slide_fade->setChecked(props.value("fade").toInt());
198 m_view.luma_softness->setValue(props.value("softness").toInt());
199 if (!props.value("animation").isEmpty())
200 m_view.animation->setCurrentItem(props.value("animation"));
202 m_view.animation->setCurrentIndex(0);
203 QString path = props.value("resource");
204 QString ext = path.section('.', -1);
205 for (int i = 0; i < m_view.image_type->count(); i++) {
206 if (m_view.image_type->itemData(i).toString() == ext) {
207 m_view.image_type->setCurrentIndex(i);
211 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
213 m_view.slide_duration_format->addItem(i18n("hh:mm:ss::ff"));
214 m_view.slide_duration_format->addItem(i18n("Frames"));
215 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
216 m_view.slide_duration_frames->setHidden(true);
217 m_view.luma_duration_frames->setHidden(true);
221 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
222 QString lumaFile = props.value("luma_file");
224 // Check for Kdenlive installed luma files
226 filters << "*.pgm" << "*.png";
228 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
229 foreach(const QString & folder, customLumas) {
230 QStringList filesnames = QDir(folder).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);
237 // Check for MLT lumas
238 QString profilePath = KdenliveSettings::mltpath();
239 QString folder = profilePath.section('/', 0, -3);
240 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
241 QDir lumafolder(folder);
242 QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
243 foreach(const QString & fname, filesnames) {
244 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
245 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
248 if (!lumaFile.isEmpty()) {
249 m_view.slide_luma->setChecked(true);
250 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
251 } else m_view.luma_file->setEnabled(false);
252 slotEnableLuma(m_view.slide_fade->checkState());
253 slotEnableLumaFile(m_view.slide_luma->checkState());
254 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
255 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
257 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
258 } else if (t != AUDIO) {
259 m_view.tabWidget->removeTab(IMAGETAB);
260 m_view.tabWidget->removeTab(SLIDETAB);
261 m_view.tabWidget->removeTab(COLORTAB);
262 if (props.contains("frame_size"))
263 m_view.clip_size->setText(props.value("frame_size"));
264 if (props.contains("videocodec"))
265 m_view.clip_vcodec->setText(props.value("videocodec"));
266 if (props.contains("fps")) {
267 m_view.clip_fps->setText(props.value("fps"));
268 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
270 if (props.contains("pix_fmt")) {
271 m_view.clip_pixfmt->setText(props.value("pix_fmt"));
272 } else m_view.clip_pixfmt->setEnabled(false);
274 if (props.contains("aspect_ratio"))
275 m_view.clip_ratio->setText(props.value("aspect_ratio"));
276 int width = 180.0 * KdenliveSettings::project_display_ratio();
277 if (width % 2 == 1) width++;
278 QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), width, 180);
279 m_view.clip_thumb->setPixmap(pix);
280 if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB);
282 m_view.tabWidget->removeTab(IMAGETAB);
283 m_view.tabWidget->removeTab(SLIDETAB);
284 m_view.tabWidget->removeTab(COLORTAB);
285 m_view.tabWidget->removeTab(VIDEOTAB);
286 m_view.clip_thumb->setHidden(true);
289 if (t != SLIDESHOW && t != COLOR) {
290 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
291 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
293 m_view.clip_filesize->setHidden(true);
294 m_view.label_size->setHidden(true);
296 m_view.clip_duration->setInputMask("");
297 m_view.clip_duration->setValidator(tc.validator());
298 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
299 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
300 else connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
303 m_view.marker_new->setIcon(KIcon("document-new"));
304 m_view.marker_new->setToolTip(i18n("Add marker"));
305 m_view.marker_edit->setIcon(KIcon("document-properties"));
306 m_view.marker_edit->setToolTip(i18n("Edit marker"));
307 m_view.marker_delete->setIcon(KIcon("trash-empty"));
308 m_view.marker_delete->setToolTip(i18n("Delete marker"));
310 slotFillMarkersList();
311 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
312 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
313 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
314 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
320 // Used for multiple clips editing
321 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
327 m_clipNeedsRefresh(false),
328 m_clipNeedsReLoad(false)
330 setFont(KGlobalSettings::toolBarFont());
331 m_view.setupUi(this);
332 QMap <QString, QString> props = cliplist.at(0)->properties();
333 m_old_props = commonproperties;
335 if (commonproperties.contains("force_aspect_ratio") && !commonproperties.value("force_aspect_ratio").isEmpty() && commonproperties.value("force_aspect_ratio").toDouble() > 0) {
336 m_view.clip_force_ar->setChecked(true);
337 m_view.clip_ar->setEnabled(true);
338 m_view.clip_ar->setValue(commonproperties.value("force_aspect_ratio").toDouble());
341 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
342 m_view.clip_force_framerate->setChecked(true);
343 m_view.clip_framerate->setEnabled(true);
344 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
347 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
348 m_view.clip_force_progressive->setChecked(true);
349 m_view.clip_progressive->setEnabled(true);
350 m_view.clip_progressive->setValue(commonproperties.value("force_progressive").toInt());
353 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
354 m_view.clip_force_threads->setChecked(true);
355 m_view.clip_threads->setEnabled(true);
356 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
359 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
360 m_view.clip_force_vindex->setChecked(true);
361 m_view.clip_vindex->setEnabled(true);
362 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
365 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
366 m_view.clip_force_aindex->setChecked(true);
367 m_view.clip_aindex->setEnabled(true);
368 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
371 if (props.contains("audio_max")) {
372 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
375 if (props.contains("video_max")) {
376 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
379 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
380 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
381 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
382 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
383 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
384 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
386 m_view.tabWidget->removeTab(METATAB);
387 m_view.tabWidget->removeTab(MARKERTAB);
388 m_view.tabWidget->removeTab(IMAGETAB);
389 m_view.tabWidget->removeTab(SLIDETAB);
390 m_view.tabWidget->removeTab(COLORTAB);
391 m_view.tabWidget->removeTab(AUDIOTAB);
392 m_view.tabWidget->removeTab(VIDEOTAB);
394 m_view.clip_path->setHidden(true);
395 m_view.label_path->setHidden(true);
396 m_view.label_description->setHidden(true);
397 m_view.label_size->setHidden(true);
398 m_view.clip_filesize->setHidden(true);
399 m_view.clip_filesize->setHidden(true);
400 m_view.clip_path->setHidden(true);
401 m_view.clip_description->setHidden(true);
402 m_view.clip_thumb->setHidden(true);
403 m_view.label_duration->setHidden(true);
404 m_view.clip_duration->setHidden(true);
406 if (commonproperties.contains("out")) {
407 if (commonproperties.value("out").toInt() > 0) {
408 m_view.clip_force_out->setChecked(true);
409 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
410 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
412 m_view.clip_force_out->setHidden(true);
413 m_view.clip_out->setHidden(true);
419 void ClipProperties::slotEnableLuma(int state)
422 if (state == Qt::Checked) enable = true;
423 m_view.luma_duration->setEnabled(enable);
424 m_view.luma_duration_frames->setEnabled(enable);
425 m_view.slide_luma->setEnabled(enable);
427 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
428 } else m_view.luma_file->setEnabled(false);
429 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
430 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
433 void ClipProperties::slotEnableLumaFile(int state)
436 if (state == Qt::Checked) enable = true;
437 m_view.luma_file->setEnabled(enable);
438 m_view.luma_softness->setEnabled(enable);
439 m_view.label_softness->setEnabled(enable);
442 void ClipProperties::slotFillMarkersList()
444 m_view.markers_list->clear();
445 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
446 for (int count = 0; count < marks.count(); ++count) {
447 QString time = m_tc.getTimecode(marks[count].time());
448 QStringList itemtext;
449 itemtext << time << marks[count].comment();
450 (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
454 void ClipProperties::slotAddMarker()
456 CommentedTime marker(GenTime(), i18n("Marker"));
457 MarkerDialog d(m_clip, marker, m_tc, i18n("Add Marker"), this);
458 if (d.exec() == QDialog::Accepted) {
459 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
461 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
464 void ClipProperties::slotEditMarker()
466 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
467 int pos = m_view.markers_list->currentIndex().row();
468 if (pos < 0 || pos > marks.count() - 1) return;
469 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
470 if (d.exec() == QDialog::Accepted) {
471 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
473 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
476 void ClipProperties::slotDeleteMarker()
478 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
479 int pos = m_view.markers_list->currentIndex().row();
480 if (pos < 0 || pos > marks.count() - 1) return;
481 emit addMarker(m_clip->getId(), marks.at(pos).time(), QString());
483 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
486 const QString &ClipProperties::clipId() const
488 return m_clip->getId();
492 QMap <QString, QString> ClipProperties::properties()
494 QMap <QString, QString> props;
495 CLIPTYPE t = UNKNOWN;
496 if (m_clip != NULL) {
497 t = m_clip->clipType();
498 m_old_props = m_clip->properties();
501 double aspect = m_view.clip_ar->value();
502 if (m_view.clip_force_ar->isChecked()) {
503 if (aspect != m_old_props.value("force_aspect_ratio").toDouble()) {
504 props["force_aspect_ratio"] = QString::number(aspect);
505 m_clipNeedsRefresh = true;
507 } else if (m_old_props.contains("force_aspect_ratio")) {
508 props["force_aspect_ratio"].clear();
509 m_clipNeedsRefresh = true;
512 double fps = m_view.clip_framerate->value();
513 if (m_view.clip_force_framerate->isChecked()) {
514 if (fps != m_old_props.value("force_fps").toDouble()) {
515 props["force_fps"] = QString::number(fps);
516 m_clipNeedsRefresh = true;
518 } else if (m_old_props.contains("force_fps")) {
519 props["force_fps"].clear();
520 m_clipNeedsRefresh = true;
523 int progressive = m_view.clip_progressive->value();
524 if (m_view.clip_force_progressive->isChecked()) {
525 if (progressive != m_old_props.value("force_progressive").toInt()) {
526 props["force_progressive"] = QString::number(progressive);
528 } else if (m_old_props.contains("force_progressive")) {
529 props["force_progressive"].clear();
532 int threads = m_view.clip_threads->value();
533 if (m_view.clip_force_threads->isChecked()) {
534 if (threads != m_old_props.value("threads").toInt()) {
535 props["threads"] = QString::number(threads);
537 } else if (m_old_props.contains("threads")) {
538 props["threads"].clear();
541 int vindex = m_view.clip_vindex->value();
542 if (m_view.clip_force_vindex->isChecked()) {
543 if (vindex != m_old_props.value("video_index").toInt()) {
544 props["video_index"] = QString::number(vindex);
546 } else if (m_old_props.contains("video_index")) {
547 props["video_index"].clear();
550 int aindex = m_view.clip_aindex->value();
551 if (m_view.clip_force_aindex->isChecked()) {
552 if (aindex != m_old_props.value("audio_index").toInt()) {
553 props["audio_index"] = QString::number(aindex);
555 } else if (m_old_props.contains("audio_index")) {
556 props["audio_index"].clear();
559 // If we adjust several clips, return now
560 if (m_clip == NULL) {
561 if (m_view.clip_out->isEnabled()) {
562 int duration = m_tc.getFrameCount(m_view.clip_out->text());
563 if (duration != m_old_props.value("out").toInt()) {
564 props["out"] = QString::number(duration - 1);
570 if (m_old_props.value("description") != m_view.clip_description->text())
571 props["description"] = m_view.clip_description->text();
574 QString new_color = m_view.clip_color->color().name();
575 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
576 m_clipNeedsRefresh = true;
577 props["colour"] = "0x" + new_color.right(6) + "ff";
579 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
580 if (duration != m_clip->duration().frames(m_fps)) {
581 props["out"] = QString::number(duration - 1);
583 } else if (t == IMAGE) {
584 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
585 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
586 //m_clipNeedsRefresh = true;
588 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
589 if (duration != m_clip->duration().frames(m_fps)) {
590 props["out"] = QString::number(duration - 1);
592 } else if (t == SLIDESHOW) {
593 QString value = QString::number((int) m_view.slide_loop->isChecked());
594 if (m_old_props.value("loop") != value) props["loop"] = value;
595 value = QString::number((int) m_view.slide_crop->isChecked());
596 if (m_old_props.value("crop") != value) props["crop"] = value;
597 value = QString::number((int) m_view.slide_fade->isChecked());
598 if (m_old_props.value("fade") != value) props["fade"] = value;
599 value = QString::number((int) m_view.luma_softness->value());
600 if (m_old_props.value("softness") != value) props["softness"] = value;
602 bool isMime = !(m_view.clip_path->text().contains('%'));
604 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
605 QString new_path = m_view.clip_path->text() + extension;
606 if (new_path != m_old_props.value("resource")) {
607 m_clipNeedsReLoad = true;
608 props["resource"] = new_path;
609 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
613 if (m_view.slide_duration_format->currentIndex() == 1) {
614 // we are in frames mode
615 duration = m_view.slide_duration_frames->value();
616 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
617 if (duration != m_old_props.value("ttl").toInt()) {
618 m_clipNeedsRefresh = true;
619 props["ttl"] = QString::number(duration);
620 props["out"] = QString::number(duration * m_count - 1);
623 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
624 m_clipNeedsRefresh = true;
625 props["out"] = QString::number(duration * m_count - 1);
627 if (m_view.slide_fade->isChecked()) {
629 if (m_view.slide_duration_format->currentIndex() == 1) {
630 // we are in frames mode
631 luma_duration = m_view.luma_duration_frames->value();
632 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
633 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
634 m_clipNeedsRefresh = true;
635 props["luma_duration"] = QString::number(luma_duration);
638 if (m_view.slide_luma->isChecked())
639 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
640 if (lumaFile != m_old_props.value("luma_file")) {
641 m_clipNeedsRefresh = true;
642 props["luma_file"] = lumaFile;
645 if (!m_old_props.value("luma_file").isEmpty()) {
646 props["luma_file"].clear();
650 QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
651 if (animation != m_old_props.value("animation")) {
652 if (animation.isEmpty()) {
653 props["animation"].clear();
655 props["animation"] = animation;
657 m_clipNeedsRefresh = true;
663 bool ClipProperties::needsTimelineRefresh() const
665 return m_clipNeedsRefresh;
668 bool ClipProperties::needsTimelineReload() const
670 return m_clipNeedsReLoad;
674 void ClipProperties::parseFolder()
676 QString path = m_view.clip_path->text();
677 bool isMime = !(path.contains('%'));
678 if (!isMime) path = KUrl(path).directory();
685 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
686 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
687 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
688 dir.setNameFilters(filters);
691 QStringList result = dir.entryList(QDir::Files);
695 QString filter = KUrl(m_view.clip_path->text()).fileName();
696 QString ext = filter.section('.', -1);
697 filter = filter.section('%', 0, -2);
698 QString regexp = "^" + filter + "\\d+\\." + ext + "$";
701 foreach(const QString & path, result) {
702 if (rx.exactMatch(path)) entries << path;
707 m_count = result.count();
709 // no images, do not accept that
710 m_view.slide_info->setText(i18n("No image found"));
711 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
714 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
715 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
716 QDomElement xml = m_clip->toXML();
717 xml.setAttribute("resource", m_view.clip_path->text() + extension);
718 int width = 180.0 * KdenliveSettings::project_display_ratio();
719 if (width % 2 == 1) width++;
720 QString filePath = m_view.clip_path->text();
721 if (isMime) filePath.append(extension);
722 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
723 QMap <QString, QString> props = m_clip->properties();
724 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
725 m_view.clip_thumb->setPixmap(pix);
728 void ClipProperties::slotCheckMaxLength()
730 if (m_clip->maxDuration() == GenTime()) return;
731 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
732 if (duration > m_clip->maxDuration().frames(m_fps)) {
733 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
737 void ClipProperties::slotUpdateDurationFormat(int ix)
739 bool framesFormat = ix == 1;
741 // switching to frames count, update widget
742 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
743 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
744 m_view.slide_duration->setHidden(true);
745 m_view.luma_duration->setHidden(true);
746 m_view.slide_duration_frames->setHidden(false);
747 m_view.luma_duration_frames->setHidden(false);
749 // switching to timecode format
750 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
751 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
752 m_view.slide_duration_frames->setHidden(true);
753 m_view.luma_duration_frames->setHidden(true);
754 m_view.slide_duration->setHidden(false);
755 m_view.luma_duration->setHidden(false);
759 #include "clipproperties.moc"