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) {
159 m_view.clip_path->setText(url.directory());
160 m_view.tabWidget->removeTab(METATAB);
161 m_view.tabWidget->removeTab(IMAGETAB);
162 m_view.tabWidget->removeTab(COLORTAB);
163 m_view.tabWidget->removeTab(AUDIOTAB);
164 m_view.tabWidget->removeTab(VIDEOTAB);
166 //WARNING: Keep in sync with slideshowclip.cpp
167 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
168 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
169 m_view.image_type->addItem("PNG (*.png)", "png");
170 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
171 m_view.image_type->addItem("GIF (*.gif)", "gif");
172 m_view.image_type->addItem("TGA (*.tga)", "tga");
173 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
174 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
176 m_view.slide_loop->setChecked(props.value("loop").toInt());
177 m_view.slide_fade->setChecked(props.value("fade").toInt());
178 m_view.luma_softness->setValue(props.value("softness").toInt());
179 QString path = props.value("resource");
180 QString ext = path.section('.', -1);
181 for (int i = 0; i < m_view.image_type->count(); i++) {
182 if (m_view.image_type->itemData(i).toString() == ext) {
183 m_view.image_type->setCurrentIndex(i);
187 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
189 m_view.slide_duration_format->addItem(i18n("hh:mm:ss::ff"));
190 m_view.slide_duration_format->addItem(i18n("Frames"));
191 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
192 m_view.slide_duration_frames->setHidden(true);
193 m_view.luma_duration_frames->setHidden(true);
197 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
198 QString lumaFile = props.value("luma_file");
200 // Check for Kdenlive installed luma files
202 filters << "*.pgm" << "*.png";
204 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
205 foreach(const QString &folder, customLumas) {
206 QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
207 foreach(const QString &fname, filesnames) {
208 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
209 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
213 // Check for MLT lumas
214 QString profilePath = KdenliveSettings::mltpath();
215 QString folder = profilePath.section('/', 0, -3);
216 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
217 QDir lumafolder(folder);
218 QStringList filesnames = lumafolder.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);
224 if (!lumaFile.isEmpty()) {
225 m_view.slide_luma->setChecked(true);
226 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
227 } else m_view.luma_file->setEnabled(false);
228 slotEnableLuma(m_view.slide_fade->checkState());
229 slotEnableLumaFile(m_view.slide_luma->checkState());
230 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
231 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
233 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
234 } else if (t != AUDIO) {
235 m_view.tabWidget->removeTab(IMAGETAB);
236 m_view.tabWidget->removeTab(SLIDETAB);
237 m_view.tabWidget->removeTab(COLORTAB);
238 if (props.contains("frame_size"))
239 m_view.clip_size->setText(props.value("frame_size"));
240 if (props.contains("videocodec"))
241 m_view.clip_vcodec->setText(props.value("videocodec"));
242 if (props.contains("fps")) {
243 m_view.clip_fps->setText(props.value("fps"));
244 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
246 if (props.contains("aspect_ratio"))
247 m_view.clip_ratio->setText(props.value("aspect_ratio"));
248 int width = 180.0 * KdenliveSettings::project_display_ratio();
249 if (width % 2 == 1) width++;
250 QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), width, 180);
251 m_view.clip_thumb->setPixmap(pix);
252 if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB);
254 m_view.tabWidget->removeTab(IMAGETAB);
255 m_view.tabWidget->removeTab(SLIDETAB);
256 m_view.tabWidget->removeTab(COLORTAB);
257 m_view.tabWidget->removeTab(VIDEOTAB);
258 m_view.clip_thumb->setHidden(true);
261 if (t != SLIDESHOW && t != COLOR) {
262 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
263 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
265 m_view.clip_filesize->setHidden(true);
266 m_view.label_size->setHidden(true);
268 m_view.clip_duration->setInputMask("");
269 m_view.clip_duration->setValidator(tc.validator());
270 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
271 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
272 else connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
275 m_view.marker_new->setIcon(KIcon("document-new"));
276 m_view.marker_new->setToolTip(i18n("Add marker"));
277 m_view.marker_edit->setIcon(KIcon("document-properties"));
278 m_view.marker_edit->setToolTip(i18n("Edit marker"));
279 m_view.marker_delete->setIcon(KIcon("trash-empty"));
280 m_view.marker_delete->setToolTip(i18n("Delete marker"));
282 slotFillMarkersList();
283 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
284 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
285 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
286 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
292 // Used for multiple clips editing
293 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
299 m_clipNeedsRefresh(false),
300 m_clipNeedsReLoad(false)
302 setFont(KGlobalSettings::toolBarFont());
303 m_view.setupUi(this);
304 QMap <QString, QString> props = cliplist.at(0)->properties();
305 m_old_props = commonproperties;
307 if (commonproperties.contains("force_aspect_ratio") && !commonproperties.value("force_aspect_ratio").isEmpty() && commonproperties.value("force_aspect_ratio").toDouble() > 0) {
308 m_view.clip_force_ar->setChecked(true);
309 m_view.clip_ar->setEnabled(true);
310 m_view.clip_ar->setValue(commonproperties.value("force_aspect_ratio").toDouble());
313 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
314 m_view.clip_force_framerate->setChecked(true);
315 m_view.clip_framerate->setEnabled(true);
316 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
319 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
320 m_view.clip_force_progressive->setChecked(true);
321 m_view.clip_progressive->setEnabled(true);
322 m_view.clip_progressive->setValue(commonproperties.value("force_progressive").toInt());
325 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
326 m_view.clip_force_threads->setChecked(true);
327 m_view.clip_threads->setEnabled(true);
328 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
331 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
332 m_view.clip_force_vindex->setChecked(true);
333 m_view.clip_vindex->setEnabled(true);
334 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
337 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
338 m_view.clip_force_aindex->setChecked(true);
339 m_view.clip_aindex->setEnabled(true);
340 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
343 if (props.contains("audio_max")) {
344 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
347 if (props.contains("video_max")) {
348 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
351 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
352 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
353 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
354 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
355 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
356 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
358 m_view.tabWidget->removeTab(METATAB);
359 m_view.tabWidget->removeTab(MARKERTAB);
360 m_view.tabWidget->removeTab(IMAGETAB);
361 m_view.tabWidget->removeTab(SLIDETAB);
362 m_view.tabWidget->removeTab(COLORTAB);
363 m_view.tabWidget->removeTab(AUDIOTAB);
364 m_view.tabWidget->removeTab(VIDEOTAB);
366 m_view.clip_path->setHidden(true);
367 m_view.label_path->setHidden(true);
368 m_view.label_description->setHidden(true);
369 m_view.label_size->setHidden(true);
370 m_view.clip_filesize->setHidden(true);
371 m_view.clip_filesize->setHidden(true);
372 m_view.clip_path->setHidden(true);
373 m_view.clip_description->setHidden(true);
374 m_view.clip_thumb->setHidden(true);
375 m_view.label_duration->setHidden(true);
376 m_view.clip_duration->setHidden(true);
378 if (commonproperties.contains("out")) {
379 if (commonproperties.value("out").toInt() > 0) {
380 m_view.clip_force_out->setChecked(true);
381 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
382 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
384 m_view.clip_force_out->setHidden(true);
385 m_view.clip_out->setHidden(true);
391 void ClipProperties::slotEnableLuma(int state)
394 if (state == Qt::Checked) enable = true;
395 m_view.luma_duration->setEnabled(enable);
396 m_view.luma_duration_frames->setEnabled(enable);
397 m_view.slide_luma->setEnabled(enable);
399 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
400 } else m_view.luma_file->setEnabled(false);
401 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
402 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
405 void ClipProperties::slotEnableLumaFile(int state)
408 if (state == Qt::Checked) enable = true;
409 m_view.luma_file->setEnabled(enable);
410 m_view.luma_softness->setEnabled(enable);
411 m_view.label_softness->setEnabled(enable);
414 void ClipProperties::slotFillMarkersList()
416 m_view.markers_list->clear();
417 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
418 for (int count = 0; count < marks.count(); ++count) {
419 QString time = m_tc.getTimecode(marks[count].time());
420 QStringList itemtext;
421 itemtext << time << marks[count].comment();
422 (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
426 void ClipProperties::slotAddMarker()
428 CommentedTime marker(GenTime(), i18n("Marker"));
429 MarkerDialog d(m_clip, marker, m_tc, i18n("Add Marker"), this);
430 if (d.exec() == QDialog::Accepted) {
431 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
433 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
436 void ClipProperties::slotEditMarker()
438 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
439 int pos = m_view.markers_list->currentIndex().row();
440 if (pos < 0 || pos > marks.count() - 1) return;
441 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit 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::slotDeleteMarker()
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 emit addMarker(m_clip->getId(), marks.at(pos).time(), QString());
455 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
458 const QString &ClipProperties::clipId() const
460 return m_clip->getId();
464 QMap <QString, QString> ClipProperties::properties()
466 QMap <QString, QString> props;
467 CLIPTYPE t = UNKNOWN;
468 if (m_clip != NULL) {
469 t = m_clip->clipType();
470 m_old_props = m_clip->properties();
473 double aspect = m_view.clip_ar->value();
474 if (m_view.clip_force_ar->isChecked()) {
475 if (aspect != m_old_props.value("force_aspect_ratio").toDouble()) {
476 props["force_aspect_ratio"] = QString::number(aspect);
477 m_clipNeedsRefresh = true;
479 } else if (m_old_props.contains("force_aspect_ratio")) {
480 props["force_aspect_ratio"].clear();
481 m_clipNeedsRefresh = true;
484 double fps = m_view.clip_framerate->value();
485 if (m_view.clip_force_framerate->isChecked()) {
486 if (fps != m_old_props.value("force_fps").toDouble()) {
487 props["force_fps"] = QString::number(fps);
488 m_clipNeedsRefresh = true;
490 } else if (m_old_props.contains("force_fps")) {
491 props["force_fps"].clear();
492 m_clipNeedsRefresh = true;
495 int progressive = m_view.clip_progressive->value();
496 if (m_view.clip_force_progressive->isChecked()) {
497 if (progressive != m_old_props.value("force_progressive").toInt()) {
498 props["force_progressive"] = QString::number(progressive);
500 } else if (m_old_props.contains("force_progressive")) {
501 props["force_progressive"].clear();
504 int threads = m_view.clip_threads->value();
505 if (m_view.clip_force_threads->isChecked()) {
506 if (threads != m_old_props.value("threads").toInt()) {
507 props["threads"] = QString::number(threads);
509 } else if (m_old_props.contains("threads")) {
510 props["threads"].clear();
513 int vindex = m_view.clip_vindex->value();
514 if (m_view.clip_force_vindex->isChecked()) {
515 if (vindex != m_old_props.value("video_index").toInt()) {
516 props["video_index"] = QString::number(vindex);
518 } else if (m_old_props.contains("video_index")) {
519 props["video_index"].clear();
522 int aindex = m_view.clip_aindex->value();
523 if (m_view.clip_force_aindex->isChecked()) {
524 if (aindex != m_old_props.value("audio_index").toInt()) {
525 props["audio_index"] = QString::number(aindex);
527 } else if (m_old_props.contains("audio_index")) {
528 props["audio_index"].clear();
531 // If we adjust several clips, return now
532 if (m_clip == NULL) {
533 if (m_view.clip_out->isEnabled()) {
534 int duration = m_tc.getFrameCount(m_view.clip_out->text());
535 if (duration != m_old_props.value("out").toInt()) {
536 props["out"] = QString::number(duration - 1);
542 if (m_old_props.value("description") != m_view.clip_description->text())
543 props["description"] = m_view.clip_description->text();
546 QString new_color = m_view.clip_color->color().name();
547 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
548 m_clipNeedsRefresh = true;
549 props["colour"] = "0x" + new_color.right(6) + "ff";
551 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
552 if (duration != m_clip->duration().frames(m_fps)) {
553 props["out"] = QString::number(duration - 1);
555 } else if (t == IMAGE) {
556 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
557 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
558 //m_clipNeedsRefresh = true;
560 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
561 if (duration != m_clip->duration().frames(m_fps)) {
562 props["out"] = QString::number(duration - 1);
564 } else if (t == SLIDESHOW) {
565 QString value = QString::number((int) m_view.slide_loop->isChecked());
566 if (m_old_props.value("loop") != value) props["loop"] = value;
567 value = QString::number((int) m_view.slide_fade->isChecked());
568 if (m_old_props.value("fade") != value) props["fade"] = value;
569 value = QString::number((int) m_view.luma_softness->value());
570 if (m_old_props.value("softness") != value) props["softness"] = value;
572 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
573 QString new_path = m_view.clip_path->text() + extension;
574 if (new_path != m_old_props.value("resource")) {
575 m_clipNeedsReLoad = true;
576 props["resource"] = new_path;
577 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
580 if (m_view.slide_duration_format->currentIndex() == 1) {
581 // we are in frames mode
582 duration = m_view.slide_duration_frames->value();
583 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
584 if (duration != m_old_props.value("ttl").toInt()) {
585 m_clipNeedsRefresh = true;
586 props["ttl"] = QString::number(duration);
587 props["out"] = QString::number(duration * m_count);
590 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
591 m_clipNeedsRefresh = true;
592 props["out"] = QString::number(duration * m_count - 1);
594 if (m_view.slide_fade->isChecked()) {
596 if (m_view.slide_duration_format->currentIndex() == 1) {
597 // we are in frames mode
598 luma_duration = m_view.luma_duration_frames->value();
599 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
600 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
601 m_clipNeedsRefresh = true;
602 props["luma_duration"] = QString::number(luma_duration);
605 if (m_view.slide_luma->isChecked())
606 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
607 if (lumaFile != m_old_props.value("luma_file")) {
608 m_clipNeedsRefresh = true;
609 props["luma_file"] = lumaFile;
612 if (!m_old_props.value("luma_file").isEmpty()) {
613 props["luma_file"].clear();
621 bool ClipProperties::needsTimelineRefresh() const
623 return m_clipNeedsRefresh;
626 bool ClipProperties::needsTimelineReload() const
628 return m_clipNeedsReLoad;
631 void ClipProperties::parseFolder()
634 QDir dir(m_view.clip_path->text());
636 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
637 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
639 dir.setNameFilters(filters);
640 QStringList result = dir.entryList(QDir::Files);
641 m_count = result.count();
643 // no images, do not accept that
644 m_view.slide_info->setText(i18n("No image found"));
645 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
648 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
649 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
650 QDomElement xml = m_clip->toXML();
651 xml.setAttribute("resource", m_view.clip_path->text() + extension);
652 int width = 180.0 * KdenliveSettings::project_display_ratio();
653 if (width % 2 == 1) width++;
654 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(m_view.clip_path->text() + extension), 1, width, 180);
655 QMap <QString, QString> props = m_clip->properties();
656 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
657 m_view.clip_thumb->setPixmap(pix);
660 void ClipProperties::slotCheckMaxLength()
662 if (m_clip->maxDuration() == GenTime()) return;
663 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
664 if (duration > m_clip->maxDuration().frames(m_fps)) {
665 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
669 void ClipProperties::slotUpdateDurationFormat(int ix)
671 bool framesFormat = ix == 1;
673 // switching to frames count, update widget
674 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
675 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
676 m_view.slide_duration->setHidden(true);
677 m_view.luma_duration->setHidden(true);
678 m_view.slide_duration_frames->setHidden(false);
679 m_view.luma_duration_frames->setHidden(false);
681 // switching to timecode format
682 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
683 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
684 m_view.slide_duration_frames->setHidden(true);
685 m_view.luma_duration_frames->setHidden(true);
686 m_view.slide_duration->setHidden(false);
687 m_view.luma_duration->setHidden(false);
691 #include "clipproperties.moc"