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;
43 ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidget * parent) :
49 m_clipNeedsRefresh(false),
50 m_clipNeedsReLoad(false)
52 setFont(KGlobalSettings::toolBarFont());
54 KUrl url = m_clip->fileURL();
55 m_view.clip_path->setText(url.path());
56 m_view.clip_description->setText(m_clip->description());
57 QMap <QString, QString> props = m_clip->properties();
59 m_view.clip_force_out->setHidden(true);
60 m_view.clip_out->setHidden(true);
62 if (props.contains("force_aspect_ratio") && props.value("force_aspect_ratio").toDouble() > 0) {
63 m_view.clip_force_ar->setChecked(true);
64 m_view.clip_ar->setEnabled(true);
65 m_view.clip_ar->setValue(props.value("force_aspect_ratio").toDouble());
68 if (props.contains("force_fps") && props.value("force_fps").toDouble() > 0) {
69 m_view.clip_force_framerate->setChecked(true);
70 m_view.clip_framerate->setEnabled(true);
71 m_view.clip_framerate->setValue(props.value("force_fps").toDouble());
74 if (props.contains("force_progressive")) {
75 m_view.clip_force_progressive->setChecked(true);
76 m_view.clip_progressive->setEnabled(true);
77 m_view.clip_progressive->setValue(props.value("force_progressive").toInt());
80 if (props.contains("threads") && props.value("threads").toInt() != 1) {
81 m_view.clip_force_threads->setChecked(true);
82 m_view.clip_threads->setEnabled(true);
83 m_view.clip_threads->setValue(props.value("threads").toInt());
86 if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
87 m_view.clip_force_vindex->setChecked(true);
88 m_view.clip_vindex->setEnabled(true);
89 m_view.clip_vindex->setValue(props.value("video_index").toInt());
92 if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
93 m_view.clip_force_aindex->setChecked(true);
94 m_view.clip_aindex->setEnabled(true);
95 m_view.clip_aindex->setValue(props.value("audio_index").toInt());
98 if (props.contains("audio_max")) {
99 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
102 if (props.contains("video_max")) {
103 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
106 // Check for Metadata
107 QMap<QString, QString> meta = m_clip->metadata();
108 QMap<QString, QString>::const_iterator i = meta.constBegin();
109 while (i != meta.constEnd()) {
110 QTreeWidgetItem *metaitem = new QTreeWidgetItem(m_view.metadata_list);
111 metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
112 metaitem->setText(1, i.value());
116 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
117 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
118 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
119 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
120 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
121 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
123 if (props.contains("audiocodec"))
124 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Audio codec") << props.value("audiocodec"));
126 if (props.contains("channels"))
127 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Channels") << props.value("channels"));
129 if (props.contains("frequency"))
130 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Frequency") << props.value("frequency"));
132 CLIPTYPE t = m_clip->clipType();
133 if (t != AUDIO && t != AV) {
134 m_view.clip_force_aindex->setEnabled(false);
137 if (t != VIDEO && t != AV) {
138 m_view.clip_force_vindex->setEnabled(false);
142 m_view.tabWidget->removeTab(SLIDETAB);
143 m_view.tabWidget->removeTab(COLORTAB);
144 m_view.tabWidget->removeTab(AUDIOTAB);
145 m_view.tabWidget->removeTab(VIDEOTAB);
146 if (props.contains("frame_size"))
147 m_view.image_size->setText(props.value("frame_size"));
148 if (props.contains("transparency"))
149 m_view.image_transparency->setChecked(props.value("transparency").toInt());
150 int width = 180.0 * KdenliveSettings::project_display_ratio();
151 if (width % 2 == 1) width++;
152 m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
153 } else if (t == COLOR) {
154 m_view.clip_path->setEnabled(false);
155 m_view.tabWidget->removeTab(METATAB);
156 m_view.tabWidget->removeTab(IMAGETAB);
157 m_view.tabWidget->removeTab(SLIDETAB);
158 m_view.tabWidget->removeTab(AUDIOTAB);
159 m_view.tabWidget->removeTab(VIDEOTAB);
160 m_view.clip_thumb->setHidden(true);
161 m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
162 } else if (t == SLIDESHOW) {
164 if (url.fileName().startsWith(".all.")) {
165 // the image sequence is defined by mimetype
166 m_view.clip_path->setText(url.directory());
168 // the image sequence is defined by pattern
169 m_view.slide_type_label->setHidden(true);
170 m_view.image_type->setHidden(true);
171 m_view.clip_path->setText(url.path());
175 m_view.tabWidget->removeTab(METATAB);
176 m_view.tabWidget->removeTab(IMAGETAB);
177 m_view.tabWidget->removeTab(COLORTAB);
178 m_view.tabWidget->removeTab(AUDIOTAB);
179 m_view.tabWidget->removeTab(VIDEOTAB);
181 //WARNING: Keep in sync with slideshowclip.cpp
182 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
183 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
184 m_view.image_type->addItem("PNG (*.png)", "png");
185 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
186 m_view.image_type->addItem("GIF (*.gif)", "gif");
187 m_view.image_type->addItem("TGA (*.tga)", "tga");
188 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
189 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
190 m_view.animation->addItem(i18n("None"), QString());
191 m_view.animation->addItem(i18n("Pan"), "Pan");
192 m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass");
193 m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom");
194 m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass");
195 m_view.animation->addItem(i18n("Zoom"), "Zoom");
196 m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass");
198 m_view.slide_loop->setChecked(props.value("loop").toInt());
199 m_view.slide_crop->setChecked(props.value("crop").toInt());
200 m_view.slide_fade->setChecked(props.value("fade").toInt());
201 m_view.luma_softness->setValue(props.value("softness").toInt());
202 if (!props.value("animation").isEmpty())
203 m_view.animation->setCurrentItem(props.value("animation"));
205 m_view.animation->setCurrentIndex(0);
206 QString path = props.value("resource");
207 QString ext = path.section('.', -1);
208 for (int i = 0; i < m_view.image_type->count(); i++) {
209 if (m_view.image_type->itemData(i).toString() == ext) {
210 m_view.image_type->setCurrentIndex(i);
214 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
216 m_view.slide_duration_format->addItem(i18n("hh:mm:ss::ff"));
217 m_view.slide_duration_format->addItem(i18n("Frames"));
218 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
219 m_view.slide_duration_frames->setHidden(true);
220 m_view.luma_duration_frames->setHidden(true);
224 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
225 QString lumaFile = props.value("luma_file");
227 // Check for Kdenlive installed luma files
229 filters << "*.pgm" << "*.png";
231 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
232 foreach(const QString & folder, customLumas) {
233 QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
234 foreach(const QString & fname, filesnames) {
235 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
236 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
240 // Check for MLT lumas
241 QString profilePath = KdenliveSettings::mltpath();
242 QString folder = profilePath.section('/', 0, -3);
243 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
244 QDir lumafolder(folder);
245 QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
246 foreach(const QString & fname, filesnames) {
247 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
248 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
251 if (!lumaFile.isEmpty()) {
252 m_view.slide_luma->setChecked(true);
253 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
254 } else m_view.luma_file->setEnabled(false);
255 slotEnableLuma(m_view.slide_fade->checkState());
256 slotEnableLumaFile(m_view.slide_luma->checkState());
257 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
258 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
260 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
261 } else if (t != AUDIO) {
262 m_view.tabWidget->removeTab(IMAGETAB);
263 m_view.tabWidget->removeTab(SLIDETAB);
264 m_view.tabWidget->removeTab(COLORTAB);
268 m_propsDelegate = new PropertiesViewDelegate(this);
269 m_view.clip_vproperties->setItemDelegate(m_propsDelegate);
270 m_view.clip_aproperties->setItemDelegate(m_propsDelegate);
271 m_view.clip_aproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
272 m_view.clip_vproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
274 if (props.contains("videocodec"))
275 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodec"));
277 if (props.contains("frame_size"))
278 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
280 if (props.contains("fps")) {
281 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
282 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
284 if (props.contains("aspect_ratio"))
285 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
287 if (props.contains("pix_fmt"))
288 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
290 if (props.contains("colorspace"))
291 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
293 int width = 180.0 * KdenliveSettings::project_display_ratio();
294 if (width % 2 == 1) width++;
295 QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), width, 180);
296 m_view.clip_thumb->setPixmap(pix);
297 if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB);
299 m_view.tabWidget->removeTab(IMAGETAB);
300 m_view.tabWidget->removeTab(SLIDETAB);
301 m_view.tabWidget->removeTab(COLORTAB);
302 m_view.tabWidget->removeTab(VIDEOTAB);
303 m_view.clip_thumb->setHidden(true);
306 if (t != SLIDESHOW && t != COLOR) {
307 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
308 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
310 m_view.clip_filesize->setHidden(true);
311 m_view.label_size->setHidden(true);
313 m_view.clip_duration->setInputMask("");
314 m_view.clip_duration->setValidator(tc.validator());
315 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
316 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
317 else connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
320 m_view.marker_new->setIcon(KIcon("document-new"));
321 m_view.marker_new->setToolTip(i18n("Add marker"));
322 m_view.marker_edit->setIcon(KIcon("document-properties"));
323 m_view.marker_edit->setToolTip(i18n("Edit marker"));
324 m_view.marker_delete->setIcon(KIcon("trash-empty"));
325 m_view.marker_delete->setToolTip(i18n("Delete marker"));
327 slotFillMarkersList();
328 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
329 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
330 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
331 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
337 // Used for multiple clips editing
338 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
344 m_clipNeedsRefresh(false),
345 m_clipNeedsReLoad(false)
347 setFont(KGlobalSettings::toolBarFont());
348 m_view.setupUi(this);
349 QMap <QString, QString> props = cliplist.at(0)->properties();
350 m_old_props = commonproperties;
352 if (commonproperties.contains("force_aspect_ratio") && !commonproperties.value("force_aspect_ratio").isEmpty() && commonproperties.value("force_aspect_ratio").toDouble() > 0) {
353 m_view.clip_force_ar->setChecked(true);
354 m_view.clip_ar->setEnabled(true);
355 m_view.clip_ar->setValue(commonproperties.value("force_aspect_ratio").toDouble());
358 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
359 m_view.clip_force_framerate->setChecked(true);
360 m_view.clip_framerate->setEnabled(true);
361 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
364 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
365 m_view.clip_force_progressive->setChecked(true);
366 m_view.clip_progressive->setEnabled(true);
367 m_view.clip_progressive->setValue(commonproperties.value("force_progressive").toInt());
370 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
371 m_view.clip_force_threads->setChecked(true);
372 m_view.clip_threads->setEnabled(true);
373 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
376 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
377 m_view.clip_force_vindex->setChecked(true);
378 m_view.clip_vindex->setEnabled(true);
379 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
382 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
383 m_view.clip_force_aindex->setChecked(true);
384 m_view.clip_aindex->setEnabled(true);
385 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
388 if (props.contains("audio_max")) {
389 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
392 if (props.contains("video_max")) {
393 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
396 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
397 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
398 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
399 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
400 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
401 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
403 m_view.tabWidget->removeTab(METATAB);
404 m_view.tabWidget->removeTab(MARKERTAB);
405 m_view.tabWidget->removeTab(IMAGETAB);
406 m_view.tabWidget->removeTab(SLIDETAB);
407 m_view.tabWidget->removeTab(COLORTAB);
408 m_view.tabWidget->removeTab(AUDIOTAB);
409 m_view.tabWidget->removeTab(VIDEOTAB);
411 m_view.clip_path->setHidden(true);
412 m_view.label_path->setHidden(true);
413 m_view.label_description->setHidden(true);
414 m_view.label_size->setHidden(true);
415 m_view.clip_filesize->setHidden(true);
416 m_view.clip_filesize->setHidden(true);
417 m_view.clip_path->setHidden(true);
418 m_view.clip_description->setHidden(true);
419 m_view.clip_thumb->setHidden(true);
420 m_view.label_duration->setHidden(true);
421 m_view.clip_duration->setHidden(true);
423 if (commonproperties.contains("out")) {
424 if (commonproperties.value("out").toInt() > 0) {
425 m_view.clip_force_out->setChecked(true);
426 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
427 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
429 m_view.clip_force_out->setHidden(true);
430 m_view.clip_out->setHidden(true);
434 ClipProperties::~ClipProperties()
436 delete m_propsDelegate;
439 void ClipProperties::slotEnableLuma(int state)
442 if (state == Qt::Checked) enable = true;
443 m_view.luma_duration->setEnabled(enable);
444 m_view.luma_duration_frames->setEnabled(enable);
445 m_view.slide_luma->setEnabled(enable);
447 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
448 } else m_view.luma_file->setEnabled(false);
449 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
450 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
453 void ClipProperties::slotEnableLumaFile(int state)
456 if (state == Qt::Checked) enable = true;
457 m_view.luma_file->setEnabled(enable);
458 m_view.luma_softness->setEnabled(enable);
459 m_view.label_softness->setEnabled(enable);
462 void ClipProperties::slotFillMarkersList()
464 m_view.markers_list->clear();
465 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
466 for (int count = 0; count < marks.count(); ++count) {
467 QString time = m_tc.getTimecode(marks[count].time());
468 QStringList itemtext;
469 itemtext << time << marks[count].comment();
470 (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
474 void ClipProperties::slotAddMarker()
476 CommentedTime marker(GenTime(), i18n("Marker"));
477 MarkerDialog d(m_clip, marker, m_tc, i18n("Add Marker"), this);
478 if (d.exec() == QDialog::Accepted) {
479 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
481 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
484 void ClipProperties::slotEditMarker()
486 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
487 int pos = m_view.markers_list->currentIndex().row();
488 if (pos < 0 || pos > marks.count() - 1) return;
489 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
490 if (d.exec() == QDialog::Accepted) {
491 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
493 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
496 void ClipProperties::slotDeleteMarker()
498 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
499 int pos = m_view.markers_list->currentIndex().row();
500 if (pos < 0 || pos > marks.count() - 1) return;
501 emit addMarker(m_clip->getId(), marks.at(pos).time(), QString());
503 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
506 const QString &ClipProperties::clipId() const
508 return m_clip->getId();
512 QMap <QString, QString> ClipProperties::properties()
514 QMap <QString, QString> props;
515 CLIPTYPE t = UNKNOWN;
516 if (m_clip != NULL) {
517 t = m_clip->clipType();
518 m_old_props = m_clip->properties();
521 double aspect = m_view.clip_ar->value();
522 if (m_view.clip_force_ar->isChecked()) {
523 if (aspect != m_old_props.value("force_aspect_ratio").toDouble()) {
524 props["force_aspect_ratio"] = QString::number(aspect);
525 m_clipNeedsRefresh = true;
527 } else if (m_old_props.contains("force_aspect_ratio")) {
528 props["force_aspect_ratio"].clear();
529 m_clipNeedsRefresh = true;
532 double fps = m_view.clip_framerate->value();
533 if (m_view.clip_force_framerate->isChecked()) {
534 if (fps != m_old_props.value("force_fps").toDouble()) {
535 props["force_fps"] = QString::number(fps);
536 m_clipNeedsRefresh = true;
538 } else if (m_old_props.contains("force_fps")) {
539 props["force_fps"].clear();
540 m_clipNeedsRefresh = true;
543 int progressive = m_view.clip_progressive->value();
544 if (m_view.clip_force_progressive->isChecked()) {
545 if (progressive != m_old_props.value("force_progressive").toInt()) {
546 props["force_progressive"] = QString::number(progressive);
548 } else if (m_old_props.contains("force_progressive")) {
549 props["force_progressive"].clear();
552 int threads = m_view.clip_threads->value();
553 if (m_view.clip_force_threads->isChecked()) {
554 if (threads != m_old_props.value("threads").toInt()) {
555 props["threads"] = QString::number(threads);
557 } else if (m_old_props.contains("threads")) {
558 props["threads"].clear();
561 int vindex = m_view.clip_vindex->value();
562 if (m_view.clip_force_vindex->isChecked()) {
563 if (vindex != m_old_props.value("video_index").toInt()) {
564 props["video_index"] = QString::number(vindex);
566 } else if (m_old_props.contains("video_index")) {
567 props["video_index"].clear();
570 int aindex = m_view.clip_aindex->value();
571 if (m_view.clip_force_aindex->isChecked()) {
572 if (aindex != m_old_props.value("audio_index").toInt()) {
573 props["audio_index"] = QString::number(aindex);
575 } else if (m_old_props.contains("audio_index")) {
576 props["audio_index"].clear();
579 // If we adjust several clips, return now
580 if (m_clip == NULL) {
581 if (m_view.clip_out->isEnabled()) {
582 int duration = m_tc.getFrameCount(m_view.clip_out->text());
583 if (duration != m_old_props.value("out").toInt()) {
584 props["out"] = QString::number(duration - 1);
590 if (m_old_props.value("description") != m_view.clip_description->text())
591 props["description"] = m_view.clip_description->text();
594 QString new_color = m_view.clip_color->color().name();
595 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
596 m_clipNeedsRefresh = true;
597 props["colour"] = "0x" + new_color.right(6) + "ff";
599 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
600 if (duration != m_clip->duration().frames(m_fps)) {
601 props["out"] = QString::number(duration - 1);
603 } else if (t == IMAGE) {
604 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
605 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
606 //m_clipNeedsRefresh = true;
608 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
609 if (duration != m_clip->duration().frames(m_fps)) {
610 props["out"] = QString::number(duration - 1);
612 } else if (t == SLIDESHOW) {
613 QString value = QString::number((int) m_view.slide_loop->isChecked());
614 if (m_old_props.value("loop") != value) props["loop"] = value;
615 value = QString::number((int) m_view.slide_crop->isChecked());
616 if (m_old_props.value("crop") != value) props["crop"] = value;
617 value = QString::number((int) m_view.slide_fade->isChecked());
618 if (m_old_props.value("fade") != value) props["fade"] = value;
619 value = QString::number((int) m_view.luma_softness->value());
620 if (m_old_props.value("softness") != value) props["softness"] = value;
622 bool isMime = !(m_view.clip_path->text().contains('%'));
624 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
625 QString new_path = m_view.clip_path->text() + extension;
626 if (new_path != m_old_props.value("resource")) {
627 m_clipNeedsReLoad = true;
628 props["resource"] = new_path;
629 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
633 if (m_view.slide_duration_format->currentIndex() == 1) {
634 // we are in frames mode
635 duration = m_view.slide_duration_frames->value();
636 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
637 if (duration != m_old_props.value("ttl").toInt()) {
638 m_clipNeedsRefresh = true;
639 props["ttl"] = QString::number(duration);
640 props["out"] = QString::number(duration * m_count - 1);
643 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
644 m_clipNeedsRefresh = true;
645 props["out"] = QString::number(duration * m_count - 1);
647 if (m_view.slide_fade->isChecked()) {
649 if (m_view.slide_duration_format->currentIndex() == 1) {
650 // we are in frames mode
651 luma_duration = m_view.luma_duration_frames->value();
652 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
653 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
654 m_clipNeedsRefresh = true;
655 props["luma_duration"] = QString::number(luma_duration);
658 if (m_view.slide_luma->isChecked())
659 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
660 if (lumaFile != m_old_props.value("luma_file")) {
661 m_clipNeedsRefresh = true;
662 props["luma_file"] = lumaFile;
665 if (!m_old_props.value("luma_file").isEmpty()) {
666 props["luma_file"].clear();
670 QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
671 if (animation != m_old_props.value("animation")) {
672 if (animation.isEmpty()) {
673 props["animation"].clear();
675 props["animation"] = animation;
677 m_clipNeedsRefresh = true;
683 bool ClipProperties::needsTimelineRefresh() const
685 return m_clipNeedsRefresh;
688 bool ClipProperties::needsTimelineReload() const
690 return m_clipNeedsReLoad;
694 void ClipProperties::parseFolder()
696 QString path = m_view.clip_path->text();
697 bool isMime = !(path.contains('%'));
698 if (!isMime) path = KUrl(path).directory();
705 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
706 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
707 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
708 dir.setNameFilters(filters);
711 QStringList result = dir.entryList(QDir::Files);
715 QString filter = KUrl(m_view.clip_path->text()).fileName();
716 QString ext = filter.section('.', -1);
717 filter = filter.section('%', 0, -2);
718 QString regexp = "^" + filter + "\\d+\\." + ext + "$";
721 foreach(const QString & path, result) {
722 if (rx.exactMatch(path)) entries << path;
727 m_count = result.count();
729 // no images, do not accept that
730 m_view.slide_info->setText(i18n("No image found"));
731 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
734 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
735 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
736 QDomElement xml = m_clip->toXML();
737 xml.setAttribute("resource", m_view.clip_path->text() + extension);
738 int width = 180.0 * KdenliveSettings::project_display_ratio();
739 if (width % 2 == 1) width++;
740 QString filePath = m_view.clip_path->text();
741 if (isMime) filePath.append(extension);
742 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
743 QMap <QString, QString> props = m_clip->properties();
744 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
745 m_view.clip_thumb->setPixmap(pix);
748 void ClipProperties::slotCheckMaxLength()
750 if (m_clip->maxDuration() == GenTime()) return;
751 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
752 if (duration > m_clip->maxDuration().frames(m_fps)) {
753 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
757 void ClipProperties::slotUpdateDurationFormat(int ix)
759 bool framesFormat = ix == 1;
761 // switching to frames count, update widget
762 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
763 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
764 m_view.slide_duration->setHidden(true);
765 m_view.luma_duration->setHidden(true);
766 m_view.slide_duration_frames->setHidden(false);
767 m_view.luma_duration_frames->setHidden(false);
769 // switching to timecode format
770 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
771 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
772 m_view.slide_duration_frames->setHidden(true);
773 m_view.luma_duration_frames->setHidden(true);
774 m_view.slide_duration->setHidden(false);
775 m_view.luma_duration->setHidden(false);
779 #include "clipproperties.moc"