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>
30 #include <KFileDialog>
31 #include <kdeversion.h>
36 #if KDE_IS_VERSION(4,6,0)
37 #include <Nepomuk/Variant>
38 #include <Nepomuk/Resource>
39 #include <Nepomuk/ResourceManager>
40 #include <Nepomuk/Vocabulary/NIE>
49 static const int VIDEOTAB = 0;
50 static const int AUDIOTAB = 1;
51 static const int COLORTAB = 2;
52 static const int SLIDETAB = 3;
53 static const int IMAGETAB = 4;
54 static const int MARKERTAB = 5;
55 static const int METATAB = 6;
56 static const int ADVANCEDTAB = 7;
59 ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidget * parent) :
65 m_clipNeedsRefresh(false),
66 m_clipNeedsReLoad(false)
68 setAttribute(Qt::WA_DeleteOnClose, true);
69 setFont(KGlobalSettings::toolBarFont());
72 // force transparency is only for group properties, so hide it
73 m_view.clip_force_transparency->setHidden(true);
74 m_view.clip_transparency->setHidden(true);
76 KUrl url = m_clip->fileURL();
77 m_view.clip_path->setText(url.path());
78 m_view.clip_description->setText(m_clip->description());
79 connect(m_view.clip_description, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
81 QMap <QString, QString> props = m_clip->properties();
82 m_view.clip_force_out->setHidden(true);
83 m_view.clip_out->setHidden(true);
85 // New display aspect ratio support
86 if (props.contains("force_aspect_num") && props.value("force_aspect_num").toInt() > 0 &&
87 props.contains("force_aspect_den") && props.value("force_aspect_den").toInt() > 0) {
88 m_view.clip_force_ar->setChecked(true);
89 m_view.clip_ar_num->setEnabled(true);
90 m_view.clip_ar_den->setEnabled(true);
91 m_view.clip_ar_num->setValue(props.value("force_aspect_num").toInt());
92 m_view.clip_ar_den->setValue(props.value("force_aspect_den").toInt());
94 // Legacy support for pixel aspect ratio
95 else if (props.contains("force_aspect_ratio") && props.value("force_aspect_ratio").toDouble() > 0) {
96 m_view.clip_force_ar->setChecked(true);
97 m_view.clip_ar_num->setEnabled(true);
98 m_view.clip_ar_den->setEnabled(true);
99 if (props.contains("frame_size")) {
100 int width = props.value("force_aspect_ratio").toDouble() * props.value("frame_size").section('x', 0, 0).toInt();
101 int height = props.value("frame_size").section('x', 1, 1).toInt();
102 if (width > 0 && height > 0) {
103 if ((width / height * 100) == 133) {
107 else if (int(width / height * 100) == 177) {
111 m_view.clip_ar_num->setValue(width);
112 m_view.clip_ar_den->setValue(height);
116 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
117 connect(m_view.clip_ar_num, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
118 connect(m_view.clip_ar_den, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
120 if (props.contains("force_fps") && props.value("force_fps").toDouble() > 0) {
121 m_view.clip_force_framerate->setChecked(true);
122 m_view.clip_framerate->setEnabled(true);
123 m_view.clip_framerate->setValue(props.value("force_fps").toDouble());
125 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
126 connect(m_view.clip_framerate, SIGNAL(valueChanged(double)), this, SLOT(slotModified()));
127 m_view.clip_progressive->addItem(i18n("Interlaced"), 0);
128 m_view.clip_progressive->addItem(i18n("Progressive"), 1);
130 if (props.contains("force_progressive")) {
131 m_view.clip_force_progressive->setChecked(true);
132 m_view.clip_progressive->setEnabled(true);
133 m_view.clip_progressive->setCurrentIndex(props.value("force_progressive").toInt());
135 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
136 connect(m_view.clip_progressive, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
138 m_view.clip_fieldorder->addItem(i18n("Bottom first"), 0);
139 m_view.clip_fieldorder->addItem(i18n("Top first"), 1);
140 if (props.contains("force_tff")) {
141 m_view.clip_force_fieldorder->setChecked(true);
142 m_view.clip_fieldorder->setEnabled(true);
143 m_view.clip_fieldorder->setCurrentIndex(props.value("force_tff").toInt());
145 connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
146 connect(m_view.clip_fieldorder, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
148 if (props.contains("threads") && props.value("threads").toInt() != 1) {
149 m_view.clip_force_threads->setChecked(true);
150 m_view.clip_threads->setEnabled(true);
151 m_view.clip_threads->setValue(props.value("threads").toInt());
153 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
154 connect(m_view.clip_threads, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
156 if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
157 m_view.clip_force_vindex->setChecked(true);
158 m_view.clip_vindex->setEnabled(true);
159 m_view.clip_vindex->setValue(props.value("video_index").toInt());
161 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
162 connect(m_view.clip_vindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
164 if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
165 m_view.clip_force_aindex->setChecked(true);
166 m_view.clip_aindex->setEnabled(true);
167 m_view.clip_aindex->setValue(props.value("audio_index").toInt());
169 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
170 connect(m_view.clip_aindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
172 if (props.contains("audio_max")) {
173 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
176 if (props.contains("video_max")) {
177 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
180 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
181 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
182 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
183 if (props.contains("force_colorspace")) {
184 m_view.clip_force_colorspace->setChecked(true);
185 m_view.clip_colorspace->setEnabled(true);
186 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("force_colorspace").toInt()));
187 } else if (props.contains("colorspace")) {
188 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("colorspace").toInt()));
190 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
191 connect(m_view.clip_colorspace, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
193 if (props.contains("full_luma")) {
194 m_view.clip_full_luma->setChecked(true);
196 connect(m_view.clip_full_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
198 // Check for Metadata
199 QMap<QString, QStringList> meta = m_clip->metadata();
200 QMap<QString, QStringList>::const_iterator i = meta.constBegin();
201 while (i != meta.constEnd()) {
202 QStringList values = i.value();
205 if (values.count() > 1 && !values.at(1).isEmpty()) parentName = values.at(1);
207 if (KdenliveSettings::ffmpegpath().endsWith("avconv")) {
208 parentName = i18n("Libav");
209 iconName = "meta_libav.png";
212 parentName = i18n("FFmpeg");
213 iconName = "meta_ffmpeg.png";
216 QTreeWidgetItem *parent = NULL;
217 QList <QTreeWidgetItem *> matches = m_view.metadata_list->findItems(parentName, Qt::MatchExactly);
218 if (!matches.isEmpty()) parent = matches.at(0);
220 if (parentName == "Magic Lantern") iconName = "meta_magiclantern.png";
221 parent = new QTreeWidgetItem(m_view.metadata_list, QStringList() << parentName);
222 if (!iconName.isEmpty()) {
223 KIcon icon(KStandardDirs::locate("appdata", iconName));
224 parent->setIcon(0, icon);
227 QTreeWidgetItem *metaitem = NULL;
229 metaitem = new QTreeWidgetItem(parent);
230 parent->setExpanded(true);
232 else metaitem = new QTreeWidgetItem(m_view.metadata_list);
233 metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
234 metaitem->setText(1, values.at(0));
238 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
239 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
240 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
241 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
242 connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), m_view.clip_fieldorder, SLOT(setEnabled(bool)));
243 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
244 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
245 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
246 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
248 if (props.contains("audiocodec"))
249 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Audio codec") << props.value("audiocodec"));
251 if (props.contains("channels"))
252 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Channels") << props.value("channels"));
254 if (props.contains("frequency"))
255 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Frequency") << props.value("frequency"));
258 CLIPTYPE t = m_clip->clipType();
260 if (props.contains("proxy") && props.value("proxy") != "-") {
261 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, KUrl(props.value("proxy")), true);
262 QFrame* line = new QFrame();
263 line->setFrameShape(QFrame::HLine);
264 line->setFrameShadow(QFrame::Sunken);
265 m_proxyContainer = new QFrame();
266 m_proxyContainer->setFrameShape(QFrame::NoFrame);
267 QHBoxLayout *l = new QHBoxLayout;
268 l->addWidget(new QLabel(i18n("Proxy clip: %1", KIO::convertSize(f.size()))));
270 QPushButton *pb = new QPushButton(i18n("Delete proxy"));
272 connect(pb, SIGNAL(clicked()), this, SLOT(slotDeleteProxy()));
273 m_proxyContainer->setLayout(l);
275 m_view.tab_image->layout()->addWidget(line);
276 m_view.tab_image->layout()->addWidget(m_proxyContainer);
278 else if (t == AUDIO) {
279 m_view.tab_audio->layout()->addWidget(line);
280 m_view.tab_audio->layout()->addWidget(m_proxyContainer);
283 m_view.tab_video->layout()->addWidget(line);
284 m_view.tab_video->layout()->addWidget(m_proxyContainer);
288 if (t != AUDIO && t != AV) {
289 m_view.clip_force_aindex->setEnabled(false);
292 if (t != VIDEO && t != AV) {
293 m_view.clip_force_vindex->setEnabled(false);
297 m_view.tabWidget->setTabText(VIDEOTAB, i18n("Playlist"));
300 m_view.tabWidget->removeTab(SLIDETAB);
301 m_view.tabWidget->removeTab(COLORTAB);
302 m_view.tabWidget->removeTab(AUDIOTAB);
303 m_view.tabWidget->removeTab(VIDEOTAB);
304 if (props.contains("frame_size"))
305 m_view.image_size->setText(props.value("frame_size"));
306 if (props.contains("transparency"))
307 m_view.image_transparency->setChecked(props.value("transparency").toInt());
308 connect(m_view.image_transparency, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
309 int width = 180.0 * KdenliveSettings::project_display_ratio();
310 if (width % 2 == 1) width++;
311 m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
312 } else if (t == COLOR) {
313 m_view.clip_path->setEnabled(false);
314 m_view.tabWidget->removeTab(METATAB);
315 m_view.tabWidget->removeTab(IMAGETAB);
316 m_view.tabWidget->removeTab(SLIDETAB);
317 m_view.tabWidget->removeTab(AUDIOTAB);
318 m_view.tabWidget->removeTab(VIDEOTAB);
319 m_view.clip_thumb->setHidden(true);
320 m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
321 connect(m_view.clip_color, SIGNAL(changed(QColor)), this, SLOT(slotModified()));
322 } else if (t == SLIDESHOW) {
323 if (url.fileName().startsWith(".all.")) {
324 // the image sequence is defined by mimetype
325 m_view.clip_path->setText(url.directory());
327 // the image sequence is defined by pattern
328 m_view.slide_type_label->setHidden(true);
329 m_view.image_type->setHidden(true);
330 m_view.clip_path->setText(url.path());
333 m_view.tabWidget->removeTab(METATAB);
334 m_view.tabWidget->removeTab(IMAGETAB);
335 m_view.tabWidget->removeTab(COLORTAB);
336 m_view.tabWidget->removeTab(AUDIOTAB);
337 m_view.tabWidget->removeTab(VIDEOTAB);
339 //WARNING: Keep in sync with slideshowclip.cpp
340 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
341 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
342 m_view.image_type->addItem("PNG (*.png)", "png");
343 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
344 m_view.image_type->addItem("GIF (*.gif)", "gif");
345 m_view.image_type->addItem("TGA (*.tga)", "tga");
346 m_view.image_type->addItem("TIF (*.tif)", "tif");
347 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
348 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
349 m_view.animation->addItem(i18n("None"), QString());
350 m_view.animation->addItem(i18n("Pan"), "Pan");
351 m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass");
352 m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom");
353 m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass");
354 m_view.animation->addItem(i18n("Zoom"), "Zoom");
355 m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass");
357 m_view.slide_loop->setChecked(props.value("loop").toInt());
358 m_view.slide_crop->setChecked(props.value("crop").toInt());
359 m_view.slide_fade->setChecked(props.value("fade").toInt());
360 m_view.luma_softness->setValue(props.value("softness").toInt());
361 if (!props.value("animation").isEmpty())
362 m_view.animation->setCurrentItem(props.value("animation"));
364 m_view.animation->setCurrentIndex(0);
365 QString path = props.value("resource");
366 QString ext = path.section('.', -1);
367 for (int i = 0; i < m_view.image_type->count(); i++) {
368 if (m_view.image_type->itemData(i).toString() == ext) {
369 m_view.image_type->setCurrentIndex(i);
373 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
375 m_view.slide_duration_format->addItem(i18n("hh:mm:ss:ff"));
376 m_view.slide_duration_format->addItem(i18n("Frames"));
377 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
378 m_view.slide_duration_frames->setHidden(true);
379 m_view.luma_duration_frames->setHidden(true);
383 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
384 QString lumaFile = props.value("luma_file");
386 // Check for Kdenlive installed luma files
388 filters << "*.pgm" << "*.png";
390 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
391 foreach(const QString & folder, customLumas) {
392 QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
393 foreach(const QString & fname, filesnames) {
394 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
395 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
399 // Check for MLT lumas
400 QString profilePath = KdenliveSettings::mltpath();
401 QString folder = profilePath.section('/', 0, -3);
402 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
403 QDir lumafolder(folder);
404 QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
405 foreach(const QString & fname, filesnames) {
406 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
407 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
410 if (!lumaFile.isEmpty()) {
411 m_view.slide_luma->setChecked(true);
412 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
413 } else m_view.luma_file->setEnabled(false);
414 slotEnableLuma(m_view.slide_fade->checkState());
415 slotEnableLumaFile(m_view.slide_luma->checkState());
417 connect(m_view.slide_fade, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
418 connect(m_view.slide_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
419 connect(m_view.slide_loop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
420 connect(m_view.slide_crop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
421 connect(m_view.slide_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
422 connect(m_view.slide_duration_frames, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
423 connect(m_view.luma_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
424 connect(m_view.luma_softness, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
425 connect(m_view.luma_file, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
426 connect(m_view.animation, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
429 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
430 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
431 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
433 } else if (t != AUDIO) {
434 m_view.tabWidget->removeTab(IMAGETAB);
435 m_view.tabWidget->removeTab(SLIDETAB);
436 m_view.tabWidget->removeTab(COLORTAB);
438 PropertiesViewDelegate *del1 = new PropertiesViewDelegate(this);
439 PropertiesViewDelegate *del2 = new PropertiesViewDelegate(this);
440 m_view.clip_vproperties->setItemDelegate(del1);
441 m_view.clip_aproperties->setItemDelegate(del2);
442 m_view.clip_aproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
443 m_view.clip_vproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
444 loadVideoProperties(props);
446 m_view.clip_thumb->setMinimumSize(180 * KdenliveSettings::project_display_ratio(), 180);
448 if (t == IMAGE || t == VIDEO || t == PLAYLIST) m_view.tabWidget->removeTab(AUDIOTAB);
450 m_view.tabWidget->removeTab(IMAGETAB);
451 m_view.tabWidget->removeTab(SLIDETAB);
452 m_view.tabWidget->removeTab(COLORTAB);
453 m_view.tabWidget->removeTab(VIDEOTAB);
454 m_view.clip_thumb->setHidden(true);
457 if (t != SLIDESHOW && t != COLOR) {
458 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
459 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
461 m_view.clip_filesize->setHidden(true);
462 m_view.label_size->setHidden(true);
464 m_view.clip_duration->setInputMask(tc.mask());
465 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
466 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
468 connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
469 connect(m_view.clip_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
473 m_view.marker_new->setIcon(KIcon("document-new"));
474 m_view.marker_new->setToolTip(i18n("Add marker"));
475 m_view.marker_edit->setIcon(KIcon("document-properties"));
476 m_view.marker_edit->setToolTip(i18n("Edit marker"));
477 m_view.marker_delete->setIcon(KIcon("trash-empty"));
478 m_view.marker_delete->setToolTip(i18n("Delete marker"));
479 m_view.marker_save->setIcon(KIcon("document-save-as"));
480 m_view.marker_save->setToolTip(i18n("Save markers"));
481 m_view.marker_load->setIcon(KIcon("document-open"));
482 m_view.marker_load->setToolTip(i18n("Load markers"));
483 m_view.analysis_delete->setIcon(KIcon("trash-empty"));
484 m_view.analysis_delete->setToolTip(i18n("Delete analysis data"));
485 m_view.analysis_load->setIcon(KIcon("document-open"));
486 m_view.analysis_load->setToolTip(i18n("Load analysis data"));
487 m_view.analysis_save->setIcon(KIcon("document-save-as"));
488 m_view.analysis_save->setToolTip(i18n("Save analysis data"));
490 // Check for Nepomuk metadata
492 #if KDE_IS_VERSION(4,6,0)
493 if (!url.isEmpty()) {
494 Nepomuk::ResourceManager::instance()->init();
495 Nepomuk::Resource res( url.path() );
496 // Check if file has a license
497 if (res.hasProperty(Nepomuk::Vocabulary::NIE::license())) {
498 QString ltype = res.property(Nepomuk::Vocabulary::NIE::licenseType()).toString();
499 m_view.clip_license->setText(i18n("License: %1", res.property(Nepomuk::Vocabulary::NIE::license()).toString()));
500 if (ltype.startsWith("http")) {
501 m_view.clip_license->setUrl(ltype);
502 connect(m_view.clip_license, SIGNAL(leftClickedUrl(const QString &)), this, SLOT(slotOpenUrl(const QString &)));
505 else m_view.clip_license->setHidden(true);
507 else m_view.clip_license->setHidden(true);
509 m_view.clip_license->setHidden(true);
512 m_view.clip_license->setHidden(true);
515 slotFillMarkersList(m_clip);
516 slotUpdateAnalysisData(m_clip);
518 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
519 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
520 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
521 connect(m_view.marker_save, SIGNAL(clicked()), this, SLOT(slotSaveMarkers()));
522 connect(m_view.marker_load, SIGNAL(clicked()), this, SLOT(slotLoadMarkers()));
523 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
525 connect(m_view.analysis_delete, SIGNAL(clicked()), this, SLOT(slotDeleteAnalysis()));
526 connect(m_view.analysis_save, SIGNAL(clicked()), this, SLOT(slotSaveAnalysis()));
527 connect(m_view.analysis_load, SIGNAL(clicked()), this, SLOT(slotLoadAnalysis()));
529 connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
530 connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
531 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
533 m_view.metadata_list->resizeColumnToContents(0);
534 m_view.clip_vproperties->resizeColumnToContents(0);
535 m_view.clip_aproperties->resizeColumnToContents(0);
540 // Used for multiple clips editing
541 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
547 m_clipNeedsRefresh(false),
548 m_clipNeedsReLoad(false)
550 setFont(KGlobalSettings::toolBarFont());
551 m_view.setupUi(this);
552 QString title = windowTitle();
553 title.append(' ' + i18np("(%1 clip)", "(%1 clips)", cliplist.count()));
554 setWindowTitle(title);
555 QMap <QString, QString> props = cliplist.at(0)->properties();
556 m_old_props = commonproperties;
558 if (commonproperties.contains("force_aspect_num") && !commonproperties.value("force_aspect_num").isEmpty() && commonproperties.value("force_aspect_den").toInt() > 0) {
559 m_view.clip_force_ar->setChecked(true);
560 m_view.clip_ar_num->setEnabled(true);
561 m_view.clip_ar_den->setEnabled(true);
562 m_view.clip_ar_num->setValue(commonproperties.value("force_aspect_num").toInt());
563 m_view.clip_ar_den->setValue(commonproperties.value("force_aspect_den").toInt());
566 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
567 m_view.clip_force_framerate->setChecked(true);
568 m_view.clip_framerate->setEnabled(true);
569 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
572 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
573 m_view.clip_force_progressive->setChecked(true);
574 m_view.clip_progressive->setEnabled(true);
575 m_view.clip_progressive->setCurrentIndex(commonproperties.value("force_progressive").toInt());
578 if (commonproperties.contains("force_tff") && !commonproperties.value("force_tff").isEmpty()) {
579 m_view.clip_force_fieldorder->setChecked(true);
580 m_view.clip_fieldorder->setEnabled(true);
581 m_view.clip_fieldorder->setCurrentIndex(commonproperties.value("force_tff").toInt());
584 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
585 m_view.clip_force_threads->setChecked(true);
586 m_view.clip_threads->setEnabled(true);
587 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
590 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
591 m_view.clip_force_vindex->setChecked(true);
592 m_view.clip_vindex->setEnabled(true);
593 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
596 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
597 m_view.clip_force_aindex->setChecked(true);
598 m_view.clip_aindex->setEnabled(true);
599 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
602 if (props.contains("audio_max")) {
603 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
606 if (props.contains("video_max")) {
607 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
610 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
611 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
612 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
614 if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
615 m_view.clip_force_colorspace->setChecked(true);
616 m_view.clip_colorspace->setEnabled(true);
617 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
620 if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
621 m_view.clip_full_luma->setChecked(true);
624 if (commonproperties.contains("transparency")) {
625 // image transparency checkbox
626 int transparency = commonproperties.value("transparency").toInt();
627 if (transparency == 0) {
628 m_view.clip_force_transparency->setChecked(true);
630 else if (transparency == 1) {
631 m_view.clip_force_transparency->setChecked(true);
632 m_view.clip_transparency->setCurrentIndex(1);
636 m_view.clip_force_transparency->setHidden(true);
637 m_view.clip_transparency->setHidden(true);
641 connect(m_view.clip_force_transparency, SIGNAL(toggled(bool)), m_view.clip_transparency, SLOT(setEnabled(bool)));
642 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
643 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
644 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
645 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
646 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
647 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
648 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
649 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
651 m_view.tabWidget->removeTab(METATAB);
652 m_view.tabWidget->removeTab(MARKERTAB);
653 m_view.tabWidget->removeTab(IMAGETAB);
654 m_view.tabWidget->removeTab(SLIDETAB);
655 m_view.tabWidget->removeTab(COLORTAB);
656 m_view.tabWidget->removeTab(AUDIOTAB);
657 m_view.tabWidget->removeTab(VIDEOTAB);
659 m_view.clip_path->setHidden(true);
660 m_view.label_path->setHidden(true);
661 m_view.label_description->setHidden(true);
662 m_view.label_size->setHidden(true);
663 m_view.clip_filesize->setHidden(true);
664 m_view.clip_filesize->setHidden(true);
665 m_view.clip_path->setHidden(true);
666 m_view.clip_description->setHidden(true);
667 m_view.clip_thumb->setHidden(true);
668 m_view.label_duration->setHidden(true);
669 m_view.clip_duration->setHidden(true);
671 if (commonproperties.contains("out")) {
672 if (commonproperties.value("out").toInt() > 0) {
673 m_view.clip_force_out->setChecked(true);
674 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
675 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
677 m_view.clip_force_out->setHidden(true);
678 m_view.clip_out->setHidden(true);
682 ClipProperties::~ClipProperties()
684 QAbstractItemDelegate *del1 = m_view.clip_vproperties->itemDelegate();
685 if (del1) delete del1;
686 QAbstractItemDelegate *del2 = m_view.clip_aproperties->itemDelegate();
687 if (del2) delete del2;
691 void ClipProperties::loadVideoProperties(QMap <QString, QString> props)
693 m_view.clip_vproperties->clear();
694 if (props.contains("videocodec"))
695 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodec"));
696 else if (props.contains("videocodecid"))
697 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodecid"));
699 if (props.contains("frame_size"))
700 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
702 if (props.contains("fps")) {
703 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
704 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
707 if (props.contains("progressive")) {
708 int scanning = props.value("progressive").toInt();
709 QString txt = scanning == 1 ? i18n("Progressive") : i18n("Interlaced");
710 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Scanning") << txt);
713 if (props.contains("aspect_ratio"))
714 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
716 if (props.contains("pix_fmt"))
717 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
719 if (props.contains("colorspace"))
720 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
723 void ClipProperties::slotGotThumbnail(const QString &id, QImage img)
725 if (id != m_clip->getId()) return;
726 QPixmap framedPix(img.width(), img.height());
727 framedPix.fill(Qt::transparent);
728 QPainter p(&framedPix);
729 p.setRenderHint(QPainter::Antialiasing, true);
731 path.addRoundedRect(0.5, 0.5, framedPix.width() - 1, framedPix.height() - 1, 4, 4);
733 p.drawImage(0, 0, img);
735 m_view.clip_thumb->setPixmap(framedPix);
738 void ClipProperties::slotApplyProperties()
740 if (m_clip != NULL) {
741 QMap <QString, QString> props = properties();
742 emit applyNewClipProperties(m_clip->getId(), m_clip->currentProperties(props), props, needsTimelineRefresh(), needsTimelineReload());
743 QTimer::singleShot(1000, this, SLOT(slotReloadVideoProperties()));
744 if (props.contains("force_aspect_num")) QTimer::singleShot(1000, this, SLOT(slotReloadVideoThumb()));
746 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
749 void ClipProperties::slotReloadVideoProperties()
751 if (m_clip == NULL) return;
752 loadVideoProperties(m_clip->properties());
755 void ClipProperties::slotReloadVideoThumb()
757 if (m_clip == NULL) return;
758 emit requestThumb(QString('?' + m_clip->getId()), QList<int>() << m_clip->getClipThumbFrame());
761 void ClipProperties::disableClipId(const QString &id)
763 if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
764 if (m_clip->getId() == id) {
765 // clip was removed from project, close this properties dialog
771 void ClipProperties::slotModified()
773 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
777 void ClipProperties::slotEnableLuma(int state)
780 if (state == Qt::Checked) enable = true;
781 m_view.luma_duration->setEnabled(enable);
782 m_view.luma_duration_frames->setEnabled(enable);
783 m_view.slide_luma->setEnabled(enable);
785 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
786 } else m_view.luma_file->setEnabled(false);
787 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
788 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
791 void ClipProperties::slotEnableLumaFile(int state)
794 if (state == Qt::Checked) enable = true;
795 m_view.luma_file->setEnabled(enable);
796 m_view.luma_softness->setEnabled(enable);
797 m_view.label_softness->setEnabled(enable);
800 void ClipProperties::slotUpdateAnalysisData(DocClipBase *clip)
802 if (m_clip != clip) return;
803 m_view.analysis_list->clear();
804 QMap <QString, QString> analysis = clip->analysisData();
805 m_view.analysis_box->setHidden(analysis.isEmpty());
806 QMap<QString, QString>::const_iterator i = analysis.constBegin();
807 while (i != analysis.constEnd()) {
808 QStringList itemtext;
809 itemtext << i.key() << i.value();
810 (void) new QTreeWidgetItem(m_view.analysis_list, itemtext);
815 void ClipProperties::slotFillMarkersList(DocClipBase *clip)
817 if (m_clip != clip) return;
818 m_view.markers_list->clear();
819 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
820 for (int count = 0; count < marks.count(); ++count) {
821 QString time = m_tc.getTimecode(marks[count].time());
822 QStringList itemtext;
823 itemtext << time << marks.at(count).comment();
824 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.markers_list, itemtext);
825 item->setData(0, Qt::DecorationRole, CommentedTime::markerColor(marks.at(count).markerType()));
829 void ClipProperties::slotAddMarker()
831 CommentedTime marker(GenTime(), i18n("Marker"));
832 QPointer<MarkerDialog> d = new MarkerDialog(m_clip, marker,
833 m_tc, i18n("Add Marker"), this);
834 if (d->exec() == QDialog::Accepted) {
835 QList <CommentedTime> markers;
836 markers << d->newMarker();
837 emit addMarkers(m_clip->getId(), markers);
842 void ClipProperties::slotSaveMarkers()
844 emit saveMarkers(m_clip->getId());
847 void ClipProperties::slotLoadMarkers()
849 emit loadMarkers(m_clip->getId());
852 void ClipProperties::slotEditMarker()
854 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
855 int pos = m_view.markers_list->currentIndex().row();
856 if (pos < 0 || pos > marks.count() - 1) return;
857 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
858 if (d.exec() == QDialog::Accepted) {
859 QList <CommentedTime> markers;
860 markers << d.newMarker();
861 emit addMarkers(m_clip->getId(), markers);
865 void ClipProperties::slotDeleteMarker()
867 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
868 QList < CommentedTime > toDelete;
869 for (int i = 0; i < marks.count(); i++) {
870 if (m_view.markers_list->topLevelItem(i)->isSelected()) {
871 CommentedTime marker = marks.at(i);
872 marker.setMarkerType(-1);
876 emit addMarkers(m_clip->getId(), toDelete);
879 void ClipProperties::slotDeleteAnalysis()
881 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
882 if (current) emit editAnalysis(m_clip->getId(), current->text(0), QString());
885 void ClipProperties::slotSaveAnalysis()
887 QString url = KFileDialog::getSaveFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Save Analysis Data"));
888 if (url.isEmpty()) return;
889 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
890 KConfigGroup analysisConfig(config, "Analysis");
891 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
892 analysisConfig.writeEntry(current->text(0), current->text(1));
895 void ClipProperties::slotLoadAnalysis()
897 QString url = KFileDialog::getOpenFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Open Analysis Data"));
898 if (url.isEmpty()) return;
899 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
900 KConfigGroup transConfig(config, "Analysis");
902 QMap< QString, QString > profiles = transConfig.entryMap();
903 QMapIterator<QString, QString> i(profiles);
904 while (i.hasNext()) {
906 emit editAnalysis(m_clip->getId(), i.key(), i.value());
910 const QString &ClipProperties::clipId() const
912 return m_clip->getId();
916 QMap <QString, QString> ClipProperties::properties()
918 QMap <QString, QString> props;
920 CLIPTYPE t = UNKNOWN;
921 if (m_clip != NULL) {
922 t = m_clip->clipType();
923 m_old_props = m_clip->properties();
926 int aspectNumerator = m_view.clip_ar_num->value();
927 int aspectDenominator = m_view.clip_ar_den->value();
928 if (m_view.clip_force_ar->isChecked()) {
929 if (aspectNumerator != m_old_props.value("force_aspect_num").toInt() ||
930 aspectDenominator != m_old_props.value("force_aspect_den").toInt()) {
931 props["force_aspect_num"] = QString::number(aspectNumerator);
932 props["force_aspect_den"] = QString::number(aspectDenominator);
933 props["force_aspect_ratio"].clear();
934 m_clipNeedsRefresh = true;
937 if (m_old_props.contains("force_aspect_num") && !m_old_props.value("force_aspect_num").isEmpty()) {
938 props["force_aspect_num"].clear();
939 m_clipNeedsRefresh = true;
941 if (m_old_props.contains("force_aspect_den") && !m_old_props.value("force_aspect_den").isEmpty()) {
942 props["force_aspect_den"].clear();
943 m_clipNeedsRefresh = true;
947 double fps = m_view.clip_framerate->value();
948 if (m_view.clip_force_framerate->isChecked()) {
949 if (fps != m_old_props.value("force_fps").toDouble()) {
950 props["force_fps"] = locale.toString(fps);
951 m_clipNeedsRefresh = true;
953 } else if (m_old_props.contains("force_fps") && !m_old_props.value("force_fps").isEmpty()) {
954 props["force_fps"].clear();
955 m_clipNeedsRefresh = true;
958 int progressive = m_view.clip_progressive->currentIndex();
959 if (m_view.clip_force_progressive->isChecked()) {
960 if (!m_old_props.contains("force_progressive") || progressive != m_old_props.value("force_progressive").toInt()) {
961 props["force_progressive"] = QString::number(progressive);
963 } else if (m_old_props.contains("force_progressive") && !m_old_props.value("force_progressive").isEmpty()) {
964 props["force_progressive"].clear();
967 int fieldOrder = m_view.clip_fieldorder->currentIndex();
968 if (m_view.clip_force_fieldorder->isChecked()) {
969 if (!m_old_props.contains("force_tff") || fieldOrder != m_old_props.value("force_tff").toInt()) {
970 props["force_tff"] = QString::number(fieldOrder);
972 } else if (m_old_props.contains("force_tff") && !m_old_props.value("force_tff").isEmpty()) {
973 props["force_tff"].clear();
976 int threads = m_view.clip_threads->value();
977 if (m_view.clip_force_threads->isChecked()) {
978 if (threads != m_old_props.value("threads").toInt()) {
979 props["threads"] = QString::number(threads);
981 } else if (m_old_props.contains("threads") && !m_old_props.value("threads").isEmpty()) {
982 props["threads"].clear();
985 int vindex = m_view.clip_vindex->value();
986 if (m_view.clip_force_vindex->isChecked()) {
987 if (vindex != m_old_props.value("video_index").toInt()) {
988 props["video_index"] = QString::number(vindex);
990 } else if (m_old_props.contains("video_index") && !m_old_props.value("video_index").isEmpty()) {
991 props["video_index"].clear();
994 int aindex = m_view.clip_aindex->value();
995 if (m_view.clip_force_aindex->isChecked()) {
996 if (aindex != m_old_props.value("audio_index").toInt()) {
997 props["audio_index"] = QString::number(aindex);
999 } else if (m_old_props.contains("audio_index") && !m_old_props.value("audio_index").isEmpty()) {
1000 props["audio_index"].clear();
1003 int colorspace = m_view.clip_colorspace->itemData(m_view.clip_colorspace->currentIndex()).toInt();
1004 if (m_view.clip_force_colorspace->isChecked()) {
1005 if (colorspace != m_old_props.value("force_colorspace").toInt()) {
1006 props["force_colorspace"] = QString::number(colorspace);
1007 m_clipNeedsRefresh = true;
1009 } else if (m_old_props.contains("force_colorspace") && !m_old_props.value("force_colorspace").isEmpty()) {
1010 props["force_colorspace"].clear();
1011 m_clipNeedsRefresh = true;
1014 if (m_view.clip_full_luma->isChecked()) {
1015 props["full_luma"] = QString::number(1);
1016 m_clipNeedsRefresh = true;
1017 } else if (m_old_props.contains("full_luma") && !m_old_props.value("full_luma").isEmpty()) {
1018 props["full_luma"].clear();
1019 m_clipNeedsRefresh = true;
1022 if (m_view.clip_force_transparency->isChecked()) {
1023 QString transp = QString::number(m_view.clip_transparency->currentIndex());
1024 if (transp != m_old_props.value("transparency")) props["transparency"] = transp;
1027 // If we adjust several clips, return now
1028 if (m_clip == NULL) {
1029 if (m_view.clip_out->isEnabled()) {
1030 int duration = m_tc.getFrameCount(m_view.clip_out->text());
1031 if (duration != m_old_props.value("out").toInt()) {
1032 props["out"] = QString::number(duration - 1);
1038 if (m_old_props.value("description") != m_view.clip_description->text())
1039 props["description"] = m_view.clip_description->text();
1042 QString new_color = m_view.clip_color->color().name();
1043 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
1044 m_clipNeedsRefresh = true;
1045 props["colour"] = "0x" + new_color.right(6) + "ff";
1047 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1048 if (duration != m_clip->duration().frames(m_fps)) {
1049 props["out"] = QString::number(duration - 1);
1051 } else if (t == IMAGE) {
1052 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
1053 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
1054 //m_clipNeedsRefresh = true;
1056 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1057 if (duration != m_clip->duration().frames(m_fps)) {
1058 props["out"] = QString::number(duration - 1);
1060 } else if (t == SLIDESHOW) {
1061 QString value = QString::number((int) m_view.slide_loop->isChecked());
1062 if (m_old_props.value("loop") != value) props["loop"] = value;
1063 value = QString::number((int) m_view.slide_crop->isChecked());
1064 if (m_old_props.value("crop") != value) props["crop"] = value;
1065 value = QString::number((int) m_view.slide_fade->isChecked());
1066 if (m_old_props.value("fade") != value) props["fade"] = value;
1067 value = QString::number((int) m_view.luma_softness->value());
1068 if (m_old_props.value("softness") != value) props["softness"] = value;
1070 bool isMime = !(m_view.clip_path->text().contains('%'));
1072 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1073 QString new_path = m_view.clip_path->text() + extension;
1074 if (new_path != m_old_props.value("resource")) {
1075 m_clipNeedsReLoad = true;
1076 props["resource"] = new_path;
1077 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
1081 if (m_view.slide_duration_format->currentIndex() == 1) {
1082 // we are in frames mode
1083 duration = m_view.slide_duration_frames->value();
1084 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
1085 if (duration != m_old_props.value("ttl").toInt()) {
1086 m_clipNeedsRefresh = true;
1087 props["ttl"] = QString::number(duration);
1088 props["length"] = QString::number(duration * m_count);
1091 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
1092 m_clipNeedsRefresh = true;
1093 props["out"] = QString::number(duration * m_count - 1);
1095 if (m_view.slide_fade->isChecked()) {
1097 if (m_view.slide_duration_format->currentIndex() == 1) {
1098 // we are in frames mode
1099 luma_duration = m_view.luma_duration_frames->value();
1100 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
1101 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
1102 m_clipNeedsRefresh = true;
1103 props["luma_duration"] = QString::number(luma_duration);
1106 if (m_view.slide_luma->isChecked())
1107 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
1108 if (lumaFile != m_old_props.value("luma_file")) {
1109 m_clipNeedsRefresh = true;
1110 props["luma_file"] = lumaFile;
1113 if (!m_old_props.value("luma_file").isEmpty()) {
1114 props["luma_file"].clear();
1118 QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
1119 if (animation != m_old_props.value("animation")) {
1120 if (animation.isEmpty()) {
1121 props["animation"].clear();
1123 props["animation"] = animation;
1125 m_clipNeedsRefresh = true;
1131 bool ClipProperties::needsTimelineRefresh() const
1133 return m_clipNeedsRefresh;
1136 bool ClipProperties::needsTimelineReload() const
1138 return m_clipNeedsReLoad;
1142 void ClipProperties::parseFolder(bool reloadThumb)
1144 QString path = m_view.clip_path->text();
1145 bool isMime = !(path.contains('%'));
1146 if (!isMime) path = KUrl(path).directory();
1149 QStringList filters;
1153 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
1154 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1155 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1156 dir.setNameFilters(filters);
1159 QStringList result = dir.entryList(QDir::Files);
1163 QString path = m_view.clip_path->text();
1164 if (path.contains('?')) {
1166 offset = m_view.clip_path->text().section(':', -1).toInt();
1167 path = path.section('?', 0, 0);
1169 QString filter = KUrl(path).fileName();
1170 QString ext = filter.section('.', -1);
1171 filter = filter.section('%', 0, -2);
1172 QString regexp = '^' + filter + "\\d+\\." + ext + '$';
1174 QStringList entries;
1176 foreach(const QString & path, result) {
1177 if (rx.exactMatch(path)) {
1179 // make sure our image is in the range we want (> begin)
1180 ix = path.section(filter, 1).section('.', 0, 0).toInt();
1181 if (ix < offset) continue;
1189 m_count = result.count();
1190 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(m_count > 0);
1192 // no images, do not accept that
1193 m_view.slide_info->setText(i18n("No image found"));
1194 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
1197 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
1198 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
1199 QMap <QString, QString> props = m_clip->properties();
1200 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
1202 int width = 180.0 * KdenliveSettings::project_display_ratio();
1203 if (width % 2 == 1) width++;
1204 QString filePath = m_view.clip_path->text();
1205 if (isMime) filePath.append(extension);
1206 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
1207 m_view.clip_thumb->setPixmap(pix);
1211 void ClipProperties::slotCheckMaxLength()
1213 if (m_clip->maxDuration() == GenTime()) return;
1214 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1215 if (duration > m_clip->maxDuration().frames(m_fps)) {
1216 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
1220 void ClipProperties::slotUpdateDurationFormat(int ix)
1222 bool framesFormat = ix == 1;
1224 // switching to frames count, update widget
1225 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
1226 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
1227 m_view.slide_duration->setHidden(true);
1228 m_view.luma_duration->setHidden(true);
1229 m_view.slide_duration_frames->setHidden(false);
1230 m_view.luma_duration_frames->setHidden(false);
1232 // switching to timecode format
1233 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
1234 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
1235 m_view.slide_duration_frames->setHidden(true);
1236 m_view.luma_duration_frames->setHidden(true);
1237 m_view.slide_duration->setHidden(false);
1238 m_view.luma_duration->setHidden(false);
1242 void ClipProperties::slotDeleteProxy()
1244 QString proxy = m_clip->getProperty("proxy");
1245 if (proxy.isEmpty()) return;
1246 emit deleteProxy(proxy);
1247 if (m_proxyContainer) delete m_proxyContainer;
1250 void ClipProperties::slotOpenUrl(const QString &url)
1252 new KRun(KUrl(url), this);
1255 #include "clipproperties.moc"