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>
43 #ifdef USE_NEPOMUKCORE
44 #include <Nepomuk2/Variant>
45 #include <Nepomuk2/Resource>
46 #include <Nepomuk2/ResourceManager>
47 #include <Nepomuk2/Vocabulary/NIE>
55 static const int VIDEOTAB = 0;
56 static const int AUDIOTAB = 1;
57 static const int COLORTAB = 2;
58 static const int SLIDETAB = 3;
59 static const int IMAGETAB = 4;
60 static const int MARKERTAB = 5;
61 static const int METATAB = 6;
62 static const int ADVANCEDTAB = 7;
65 ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps, QWidget * parent) :
71 , m_clipNeedsRefresh(false)
72 , m_clipNeedsReLoad(false)
73 , m_proxyContainer(NULL)
75 setAttribute(Qt::WA_DeleteOnClose, true);
76 setFont(KGlobalSettings::toolBarFont());
79 // force transparency is only for group properties, so hide it
80 m_view.clip_force_transparency->setHidden(true);
81 m_view.clip_transparency->setHidden(true);
83 KUrl url = m_clip->fileURL();
84 m_view.clip_path->setText(url.path());
85 m_view.clip_description->setText(m_clip->description());
86 connect(m_view.clip_description, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
88 QMap <QString, QString> props = m_clip->properties();
89 m_view.clip_force_out->setHidden(true);
90 m_view.clip_out->setHidden(true);
92 // New display aspect ratio support
93 if (props.contains("force_aspect_num") && props.value("force_aspect_num").toInt() > 0 &&
94 props.contains("force_aspect_den") && props.value("force_aspect_den").toInt() > 0) {
95 m_view.clip_force_ar->setChecked(true);
96 m_view.clip_ar_num->setEnabled(true);
97 m_view.clip_ar_den->setEnabled(true);
98 m_view.clip_ar_num->setValue(props.value("force_aspect_num").toInt());
99 m_view.clip_ar_den->setValue(props.value("force_aspect_den").toInt());
101 // Legacy support for pixel aspect ratio
102 else if (props.contains("force_aspect_ratio") && props.value("force_aspect_ratio").toDouble() > 0) {
103 m_view.clip_force_ar->setChecked(true);
104 m_view.clip_ar_num->setEnabled(true);
105 m_view.clip_ar_den->setEnabled(true);
106 if (props.contains("frame_size")) {
107 int width = props.value("force_aspect_ratio").toDouble() * props.value("frame_size").section('x', 0, 0).toInt();
108 int height = props.value("frame_size").section('x', 1, 1).toInt();
109 if (width > 0 && height > 0) {
110 if ((width / height * 100) == 133) {
114 else if (int(width / height * 100) == 177) {
118 m_view.clip_ar_num->setValue(width);
119 m_view.clip_ar_den->setValue(height);
123 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
124 connect(m_view.clip_ar_num, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
125 connect(m_view.clip_ar_den, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
127 if (props.contains("force_fps") && props.value("force_fps").toDouble() > 0) {
128 m_view.clip_force_framerate->setChecked(true);
129 m_view.clip_framerate->setEnabled(true);
130 m_view.clip_framerate->setValue(props.value("force_fps").toDouble());
132 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
133 connect(m_view.clip_framerate, SIGNAL(valueChanged(double)), this, SLOT(slotModified()));
134 m_view.clip_progressive->addItem(i18n("Interlaced"), 0);
135 m_view.clip_progressive->addItem(i18n("Progressive"), 1);
137 if (props.contains("force_progressive")) {
138 m_view.clip_force_progressive->setChecked(true);
139 m_view.clip_progressive->setEnabled(true);
140 m_view.clip_progressive->setCurrentIndex(props.value("force_progressive").toInt());
142 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
143 connect(m_view.clip_progressive, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
145 m_view.clip_fieldorder->addItem(i18n("Bottom first"), 0);
146 m_view.clip_fieldorder->addItem(i18n("Top first"), 1);
147 if (props.contains("force_tff")) {
148 m_view.clip_force_fieldorder->setChecked(true);
149 m_view.clip_fieldorder->setEnabled(true);
150 m_view.clip_fieldorder->setCurrentIndex(props.value("force_tff").toInt());
152 connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
153 connect(m_view.clip_fieldorder, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
155 if (props.contains("threads") && props.value("threads").toInt() != 1) {
156 m_view.clip_force_threads->setChecked(true);
157 m_view.clip_threads->setEnabled(true);
158 m_view.clip_threads->setValue(props.value("threads").toInt());
160 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
161 connect(m_view.clip_threads, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
163 if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
164 m_view.clip_force_vindex->setChecked(true);
165 m_view.clip_vindex->setEnabled(true);
166 m_view.clip_vindex->setValue(props.value("video_index").toInt());
168 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
169 connect(m_view.clip_vindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
171 if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
172 m_view.clip_force_aindex->setChecked(true);
173 m_view.clip_aindex->setEnabled(true);
174 m_view.clip_aindex->setValue(props.value("audio_index").toInt());
176 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
177 connect(m_view.clip_aindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
179 if (props.contains("audio_max")) {
180 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
183 if (props.contains("video_max")) {
184 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
187 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
188 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
189 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
190 if (props.contains("force_colorspace")) {
191 m_view.clip_force_colorspace->setChecked(true);
192 m_view.clip_colorspace->setEnabled(true);
193 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("force_colorspace").toInt()));
194 } else if (props.contains("colorspace")) {
195 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("colorspace").toInt()));
197 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
198 connect(m_view.clip_colorspace, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
200 if (props.contains("full_luma")) {
201 m_view.clip_full_luma->setChecked(true);
203 connect(m_view.clip_full_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
205 // Check for Metadata
206 QMap<QString, QStringList> meta = m_clip->metadata();
207 QMap<QString, QStringList>::const_iterator i = meta.constBegin();
208 while (i != meta.constEnd()) {
209 QStringList values = i.value();
212 if (values.count() > 1 && !values.at(1).isEmpty()) {
213 parentName = values.at(1);
215 if (KdenliveSettings::ffmpegpath().endsWith("avconv")) {
216 parentName = i18n("Libav");
217 iconName = "meta_libav.png";
220 parentName = i18n("FFmpeg");
221 iconName = "meta_ffmpeg.png";
224 QTreeWidgetItem *parent = NULL;
225 QList <QTreeWidgetItem *> matches = m_view.metadata_list->findItems(parentName, Qt::MatchExactly);
226 if (!matches.isEmpty()) {
227 parent = matches.at(0);
229 if (parentName == "Magic Lantern")
230 iconName = "meta_magiclantern.png";
231 parent = new QTreeWidgetItem(m_view.metadata_list, QStringList() << parentName);
232 if (!iconName.isEmpty()) {
233 KIcon icon(KStandardDirs::locate("appdata", iconName));
234 parent->setIcon(0, icon);
237 QTreeWidgetItem *metaitem = NULL;
239 metaitem = new QTreeWidgetItem(parent);
240 parent->setExpanded(true);
242 else metaitem = new QTreeWidgetItem(m_view.metadata_list);
243 metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
244 metaitem->setText(1, values.at(0));
248 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
249 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
250 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
251 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
252 connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), m_view.clip_fieldorder, SLOT(setEnabled(bool)));
253 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
254 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
255 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
256 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
258 if (props.contains("audiocodec"))
259 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Audio codec") << props.value("audiocodec"));
261 if (props.contains("channels"))
262 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Channels") << props.value("channels"));
264 if (props.contains("frequency"))
265 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Frequency") << props.value("frequency"));
268 CLIPTYPE t = m_clip->clipType();
270 if (props.contains("proxy") && props.value("proxy") != "-") {
271 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, KUrl(props.value("proxy")), true);
272 QFrame* line = new QFrame();
273 line->setFrameShape(QFrame::HLine);
274 line->setFrameShadow(QFrame::Sunken);
275 m_proxyContainer = new QFrame();
276 m_proxyContainer->setFrameShape(QFrame::NoFrame);
277 QHBoxLayout *l = new QHBoxLayout;
278 l->addWidget(new QLabel(i18n("Proxy clip: %1", KIO::convertSize(f.size()))));
280 QPushButton *pb = new QPushButton(i18n("Delete proxy"));
282 connect(pb, SIGNAL(clicked()), this, SLOT(slotDeleteProxy()));
283 m_proxyContainer->setLayout(l);
285 m_view.tab_image->layout()->addWidget(line);
286 m_view.tab_image->layout()->addWidget(m_proxyContainer);
288 else if (t == AUDIO) {
289 m_view.tab_audio->layout()->addWidget(line);
290 m_view.tab_audio->layout()->addWidget(m_proxyContainer);
293 m_view.tab_video->layout()->addWidget(line);
294 m_view.tab_video->layout()->addWidget(m_proxyContainer);
298 if (t != AUDIO && t != AV) {
299 m_view.clip_force_aindex->setEnabled(false);
302 if (t != VIDEO && t != AV) {
303 m_view.clip_force_vindex->setEnabled(false);
307 m_view.tabWidget->setTabText(VIDEOTAB, i18n("Playlist"));
310 m_view.tabWidget->removeTab(SLIDETAB);
311 m_view.tabWidget->removeTab(COLORTAB);
312 m_view.tabWidget->removeTab(AUDIOTAB);
313 m_view.tabWidget->removeTab(VIDEOTAB);
314 if (props.contains("frame_size"))
315 m_view.image_size->setText(props.value("frame_size"));
316 if (props.contains("transparency"))
317 m_view.image_transparency->setChecked(props.value("transparency").toInt());
318 connect(m_view.image_transparency, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
319 int width = 180.0 * KdenliveSettings::project_display_ratio();
322 m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
323 } else if (t == COLOR) {
324 m_view.clip_path->setEnabled(false);
325 m_view.tabWidget->removeTab(METATAB);
326 m_view.tabWidget->removeTab(IMAGETAB);
327 m_view.tabWidget->removeTab(SLIDETAB);
328 m_view.tabWidget->removeTab(AUDIOTAB);
329 m_view.tabWidget->removeTab(VIDEOTAB);
330 m_view.clip_thumb->setHidden(true);
331 m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
332 connect(m_view.clip_color, SIGNAL(changed(QColor)), this, SLOT(slotModified()));
333 } else if (t == SLIDESHOW) {
334 if (url.fileName().startsWith(QLatin1String(".all."))) {
335 // the image sequence is defined by mimetype
336 m_view.clip_path->setText(url.directory());
338 // the image sequence is defined by pattern
339 m_view.slide_type_label->setHidden(true);
340 m_view.image_type->setHidden(true);
341 m_view.clip_path->setText(url.path());
344 m_view.tabWidget->removeTab(METATAB);
345 m_view.tabWidget->removeTab(IMAGETAB);
346 m_view.tabWidget->removeTab(COLORTAB);
347 m_view.tabWidget->removeTab(AUDIOTAB);
348 m_view.tabWidget->removeTab(VIDEOTAB);
350 //WARNING: Keep in sync with slideshowclip.cpp
351 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
352 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
353 m_view.image_type->addItem("PNG (*.png)", "png");
354 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
355 m_view.image_type->addItem("GIF (*.gif)", "gif");
356 m_view.image_type->addItem("TGA (*.tga)", "tga");
357 m_view.image_type->addItem("TIF (*.tif)", "tif");
358 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
359 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
360 m_view.animation->addItem(i18n("None"), QString());
361 m_view.animation->addItem(i18n("Pan"), "Pan");
362 m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass");
363 m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom");
364 m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass");
365 m_view.animation->addItem(i18n("Zoom"), "Zoom");
366 m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass");
368 m_view.slide_loop->setChecked(props.value("loop").toInt());
369 m_view.slide_crop->setChecked(props.value("crop").toInt());
370 m_view.slide_fade->setChecked(props.value("fade").toInt());
371 m_view.luma_softness->setValue(props.value("softness").toInt());
372 if (!props.value("animation").isEmpty())
373 m_view.animation->setCurrentItem(props.value("animation"));
375 m_view.animation->setCurrentIndex(0);
376 QString path = props.value("resource");
377 QString ext = path.section('.', -1);
378 for (int i = 0; i < m_view.image_type->count(); ++i) {
379 if (m_view.image_type->itemData(i).toString() == ext) {
380 m_view.image_type->setCurrentIndex(i);
384 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
386 m_view.slide_duration_format->addItem(i18n("hh:mm:ss:ff"));
387 m_view.slide_duration_format->addItem(i18n("Frames"));
388 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
389 m_view.slide_duration_frames->setHidden(true);
390 m_view.luma_duration_frames->setHidden(true);
394 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
395 QString lumaFile = props.value("luma_file");
397 // Check for Kdenlive installed luma files
399 filters << "*.pgm" << "*.png";
401 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
402 foreach(const QString & folder, customLumas) {
403 QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
404 foreach(const QString & fname, filesnames) {
405 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
406 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
410 // Check for MLT lumas
411 QString profilePath = KdenliveSettings::mltpath();
412 QString folder = profilePath.section('/', 0, -3);
413 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
414 QDir lumafolder(folder);
415 QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
416 foreach(const QString & fname, filesnames) {
417 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
418 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
421 if (!lumaFile.isEmpty()) {
422 m_view.slide_luma->setChecked(true);
423 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
424 } else m_view.luma_file->setEnabled(false);
425 slotEnableLuma(m_view.slide_fade->checkState());
426 slotEnableLumaFile(m_view.slide_luma->checkState());
428 connect(m_view.slide_fade, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
429 connect(m_view.slide_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
430 connect(m_view.slide_loop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
431 connect(m_view.slide_crop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
432 connect(m_view.slide_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
433 connect(m_view.slide_duration_frames, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
434 connect(m_view.luma_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
435 connect(m_view.luma_softness, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
436 connect(m_view.luma_file, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
437 connect(m_view.animation, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
440 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
441 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
442 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
444 } else if (t != AUDIO) {
445 m_view.tabWidget->removeTab(IMAGETAB);
446 m_view.tabWidget->removeTab(SLIDETAB);
447 m_view.tabWidget->removeTab(COLORTAB);
449 PropertiesViewDelegate *del1 = new PropertiesViewDelegate(this);
450 PropertiesViewDelegate *del2 = new PropertiesViewDelegate(this);
451 m_view.clip_vproperties->setItemDelegate(del1);
452 m_view.clip_aproperties->setItemDelegate(del2);
453 m_view.clip_aproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
454 m_view.clip_vproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
455 loadVideoProperties(props);
457 m_view.clip_thumb->setMinimumSize(180 * KdenliveSettings::project_display_ratio(), 180);
459 if (t == IMAGE || t == VIDEO || t == PLAYLIST)
460 m_view.tabWidget->removeTab(AUDIOTAB);
462 m_view.tabWidget->removeTab(IMAGETAB);
463 m_view.tabWidget->removeTab(SLIDETAB);
464 m_view.tabWidget->removeTab(COLORTAB);
465 m_view.tabWidget->removeTab(VIDEOTAB);
466 m_view.clip_thumb->setHidden(true);
469 if (t != SLIDESHOW && t != COLOR) {
470 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
471 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
473 m_view.clip_filesize->setHidden(true);
474 m_view.label_size->setHidden(true);
476 m_view.clip_duration->setInputMask(tc.mask());
477 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
478 if (t != IMAGE && t != COLOR && t != TEXT) {
479 m_view.clip_duration->setReadOnly(true);
481 connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
482 connect(m_view.clip_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
486 m_view.marker_new->setIcon(KIcon("document-new"));
487 m_view.marker_new->setToolTip(i18n("Add marker"));
488 m_view.marker_edit->setIcon(KIcon("document-properties"));
489 m_view.marker_edit->setToolTip(i18n("Edit marker"));
490 m_view.marker_delete->setIcon(KIcon("trash-empty"));
491 m_view.marker_delete->setToolTip(i18n("Delete marker"));
492 m_view.marker_save->setIcon(KIcon("document-save-as"));
493 m_view.marker_save->setToolTip(i18n("Save markers"));
494 m_view.marker_load->setIcon(KIcon("document-open"));
495 m_view.marker_load->setToolTip(i18n("Load markers"));
496 m_view.analysis_delete->setIcon(KIcon("trash-empty"));
497 m_view.analysis_delete->setToolTip(i18n("Delete analysis data"));
498 m_view.analysis_load->setIcon(KIcon("document-open"));
499 m_view.analysis_load->setToolTip(i18n("Load analysis data"));
500 m_view.analysis_save->setIcon(KIcon("document-save-as"));
501 m_view.analysis_save->setToolTip(i18n("Save analysis data"));
503 // Check for Nepomuk metadata
506 #if KDE_IS_VERSION(4,6,0)
507 if (!url.isEmpty()) {
508 Nepomuk::ResourceManager::instance()->init();
509 Nepomuk::Resource res( url.path() );
510 // Check if file has a license
511 if (res.hasProperty(Nepomuk::Vocabulary::NIE::license())) {
512 QString ltype = res.property(Nepomuk::Vocabulary::NIE::licenseType()).toString();
513 m_view.clip_license->setText(i18n("License: %1", res.property(Nepomuk::Vocabulary::NIE::license()).toString()));
514 if (ltype.startsWith("http")) {
515 m_view.clip_license->setUrl(ltype);
516 connect(m_view.clip_license, SIGNAL(leftClickedUrl(QString)), this, SLOT(slotOpenUrl(QString)));
519 else m_view.clip_license->setHidden(true);
521 else m_view.clip_license->setHidden(true);
523 m_view.clip_license->setHidden(true);
528 #ifdef USE_NEPOMUKCORE
530 if (!url.isEmpty()) {
531 Nepomuk2::ResourceManager::instance()->init();
532 Nepomuk2::Resource res( url.path() );
533 // Check if file has a license
534 if (res.hasProperty(Nepomuk2::Vocabulary::NIE::license())) {
535 QString ltype = res.property(Nepomuk2::Vocabulary::NIE::licenseType()).toString();
536 m_view.clip_license->setText(i18n("License: %1", res.property(Nepomuk2::Vocabulary::NIE::license()).toString()));
537 if (ltype.startsWith("http")) {
538 m_view.clip_license->setUrl(ltype);
539 connect(m_view.clip_license, SIGNAL(leftClickedUrl(QString)), this, SLOT(slotOpenUrl(QString)));
542 else m_view.clip_license->setHidden(true);
544 else m_view.clip_license->setHidden(true);
546 m_view.clip_license->setHidden(true);
551 slotFillMarkersList(m_clip);
552 slotUpdateAnalysisData(m_clip);
554 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
555 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
556 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
557 connect(m_view.marker_save, SIGNAL(clicked()), this, SLOT(slotSaveMarkers()));
558 connect(m_view.marker_load, SIGNAL(clicked()), this, SLOT(slotLoadMarkers()));
559 connect(m_view.markers_list, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotEditMarker()));
561 connect(m_view.analysis_delete, SIGNAL(clicked()), this, SLOT(slotDeleteAnalysis()));
562 connect(m_view.analysis_save, SIGNAL(clicked()), this, SLOT(slotSaveAnalysis()));
563 connect(m_view.analysis_load, SIGNAL(clicked()), this, SLOT(slotLoadAnalysis()));
565 connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
566 connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
567 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
569 m_view.metadata_list->resizeColumnToContents(0);
570 m_view.clip_vproperties->resizeColumnToContents(0);
571 m_view.clip_aproperties->resizeColumnToContents(0);
576 // Used for multiple clips editing
577 ClipProperties::ClipProperties(const QList <DocClipBase *> &cliplist, const Timecode &tc, const QMap <QString, QString> &commonproperties, QWidget * parent) :
583 m_clipNeedsRefresh(false),
584 m_clipNeedsReLoad(false)
586 setFont(KGlobalSettings::toolBarFont());
587 m_view.setupUi(this);
588 QString title = windowTitle();
589 title.append(' ' + i18np("(%1 clip)", "(%1 clips)", cliplist.count()));
590 setWindowTitle(title);
591 QMap <QString, QString> props = cliplist.at(0)->properties();
592 m_old_props = commonproperties;
594 if (commonproperties.contains("force_aspect_num") && !commonproperties.value("force_aspect_num").isEmpty() && commonproperties.value("force_aspect_den").toInt() > 0) {
595 m_view.clip_force_ar->setChecked(true);
596 m_view.clip_ar_num->setEnabled(true);
597 m_view.clip_ar_den->setEnabled(true);
598 m_view.clip_ar_num->setValue(commonproperties.value("force_aspect_num").toInt());
599 m_view.clip_ar_den->setValue(commonproperties.value("force_aspect_den").toInt());
602 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
603 m_view.clip_force_framerate->setChecked(true);
604 m_view.clip_framerate->setEnabled(true);
605 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
608 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
609 m_view.clip_force_progressive->setChecked(true);
610 m_view.clip_progressive->setEnabled(true);
611 m_view.clip_progressive->setCurrentIndex(commonproperties.value("force_progressive").toInt());
614 if (commonproperties.contains("force_tff") && !commonproperties.value("force_tff").isEmpty()) {
615 m_view.clip_force_fieldorder->setChecked(true);
616 m_view.clip_fieldorder->setEnabled(true);
617 m_view.clip_fieldorder->setCurrentIndex(commonproperties.value("force_tff").toInt());
620 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
621 m_view.clip_force_threads->setChecked(true);
622 m_view.clip_threads->setEnabled(true);
623 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
626 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
627 m_view.clip_force_vindex->setChecked(true);
628 m_view.clip_vindex->setEnabled(true);
629 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
632 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
633 m_view.clip_force_aindex->setChecked(true);
634 m_view.clip_aindex->setEnabled(true);
635 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
638 if (props.contains("audio_max")) {
639 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
642 if (props.contains("video_max")) {
643 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
646 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
647 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
648 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
650 if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
651 m_view.clip_force_colorspace->setChecked(true);
652 m_view.clip_colorspace->setEnabled(true);
653 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
656 if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
657 m_view.clip_full_luma->setChecked(true);
660 if (commonproperties.contains("transparency")) {
661 // image transparency checkbox
662 int transparency = commonproperties.value("transparency").toInt();
663 if (transparency == 0) {
664 m_view.clip_force_transparency->setChecked(true);
666 else if (transparency == 1) {
667 m_view.clip_force_transparency->setChecked(true);
668 m_view.clip_transparency->setCurrentIndex(1);
672 m_view.clip_force_transparency->setHidden(true);
673 m_view.clip_transparency->setHidden(true);
677 connect(m_view.clip_force_transparency, SIGNAL(toggled(bool)), m_view.clip_transparency, SLOT(setEnabled(bool)));
678 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
679 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
680 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
681 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
682 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
683 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
684 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
685 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
687 m_view.tabWidget->removeTab(METATAB);
688 m_view.tabWidget->removeTab(MARKERTAB);
689 m_view.tabWidget->removeTab(IMAGETAB);
690 m_view.tabWidget->removeTab(SLIDETAB);
691 m_view.tabWidget->removeTab(COLORTAB);
692 m_view.tabWidget->removeTab(AUDIOTAB);
693 m_view.tabWidget->removeTab(VIDEOTAB);
695 m_view.clip_path->setHidden(true);
696 m_view.label_path->setHidden(true);
697 m_view.label_description->setHidden(true);
698 m_view.label_size->setHidden(true);
699 m_view.clip_filesize->setHidden(true);
700 m_view.clip_filesize->setHidden(true);
701 m_view.clip_path->setHidden(true);
702 m_view.clip_description->setHidden(true);
703 m_view.clip_thumb->setHidden(true);
704 m_view.label_duration->setHidden(true);
705 m_view.clip_duration->setHidden(true);
707 if (commonproperties.contains("out")) {
708 if (commonproperties.value("out").toInt() > 0) {
709 m_view.clip_force_out->setChecked(true);
710 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
712 m_view.clip_out->setText(KdenliveSettings::image_duration());
715 m_view.clip_force_out->setHidden(true);
716 m_view.clip_out->setHidden(true);
720 ClipProperties::~ClipProperties()
722 QAbstractItemDelegate *del1 = m_view.clip_vproperties->itemDelegate();
724 QAbstractItemDelegate *del2 = m_view.clip_aproperties->itemDelegate();
729 void ClipProperties::loadVideoProperties(const QMap <QString, QString> &props)
731 m_view.clip_vproperties->clear();
732 if (props.contains("videocodec"))
733 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodec"));
734 else if (props.contains("videocodecid"))
735 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodecid"));
737 if (props.contains("frame_size"))
738 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
740 if (props.contains("fps")) {
741 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
742 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
745 if (props.contains("progressive")) {
746 int scanning = props.value("progressive").toInt();
747 QString txt = scanning == 1 ? i18n("Progressive") : i18n("Interlaced");
748 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Scanning") << txt);
751 if (props.contains("aspect_ratio"))
752 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
754 if (props.contains("pix_fmt"))
755 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
757 if (props.contains("colorspace"))
758 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
761 void ClipProperties::slotGotThumbnail(const QString &id, const QImage &img)
763 if (id != m_clip->getId())
765 QPixmap framedPix(img.width(), img.height());
766 framedPix.fill(Qt::transparent);
767 QPainter p(&framedPix);
768 p.setRenderHint(QPainter::Antialiasing, true);
770 path.addRoundedRect(0.5, 0.5, framedPix.width() - 1, framedPix.height() - 1, 4, 4);
772 p.drawImage(0, 0, img);
774 m_view.clip_thumb->setPixmap(framedPix);
777 void ClipProperties::slotApplyProperties()
779 if (m_clip != NULL) {
780 QMap <QString, QString> props = properties();
781 emit applyNewClipProperties(m_clip->getId(), m_clip->currentProperties(props), props, needsTimelineRefresh(), needsTimelineReload());
782 QTimer::singleShot(1000, this, SLOT(slotReloadVideoProperties()));
783 if (props.contains("force_aspect_num"))
784 QTimer::singleShot(1000, this, SLOT(slotReloadVideoThumb()));
786 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
789 void ClipProperties::slotReloadVideoProperties()
793 loadVideoProperties(m_clip->properties());
796 void ClipProperties::slotReloadVideoThumb()
800 emit requestThumb(QString('?' + m_clip->getId()), QList<int>() << m_clip->getClipThumbFrame());
803 void ClipProperties::disableClipId(const QString &id)
805 if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
806 if (m_clip->getId() == id) {
807 // clip was removed from project, close this properties dialog
813 void ClipProperties::slotModified()
815 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
819 void ClipProperties::slotEnableLuma(int state)
822 if (state == Qt::Checked) enable = true;
823 m_view.luma_duration->setEnabled(enable);
824 m_view.luma_duration_frames->setEnabled(enable);
825 m_view.slide_luma->setEnabled(enable);
827 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
828 } else m_view.luma_file->setEnabled(false);
829 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
830 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
833 void ClipProperties::slotEnableLumaFile(int state)
836 if (state == Qt::Checked) enable = true;
837 m_view.luma_file->setEnabled(enable);
838 m_view.luma_softness->setEnabled(enable);
839 m_view.label_softness->setEnabled(enable);
842 void ClipProperties::slotUpdateAnalysisData(DocClipBase *clip)
844 if (m_clip != clip) return;
845 m_view.analysis_list->clear();
846 QMap <QString, QString> analysis = clip->analysisData();
847 m_view.analysis_box->setHidden(analysis.isEmpty());
848 QMap<QString, QString>::const_iterator i = analysis.constBegin();
849 while (i != analysis.constEnd()) {
850 QStringList itemtext;
851 itemtext << i.key() << i.value();
852 (void) new QTreeWidgetItem(m_view.analysis_list, itemtext);
857 void ClipProperties::slotFillMarkersList(DocClipBase *clip)
859 if (m_clip != clip) return;
860 m_view.markers_list->clear();
861 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
862 for (int count = 0; count < marks.count(); ++count) {
863 QString time = m_tc.getTimecode(marks[count].time());
864 QStringList itemtext;
865 itemtext << time << marks.at(count).comment();
866 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.markers_list, itemtext);
867 item->setData(0, Qt::DecorationRole, CommentedTime::markerColor(marks.at(count).markerType()));
871 void ClipProperties::slotAddMarker()
873 CommentedTime marker(GenTime(), i18n("Marker"));
874 QPointer<MarkerDialog> d = new MarkerDialog(m_clip, marker,
875 m_tc, i18n("Add Marker"), this);
876 if (d->exec() == QDialog::Accepted) {
877 QList <CommentedTime> markers;
878 markers << d->newMarker();
879 emit addMarkers(m_clip->getId(), markers);
884 void ClipProperties::slotSaveMarkers()
886 emit saveMarkers(m_clip->getId());
889 void ClipProperties::slotLoadMarkers()
891 emit loadMarkers(m_clip->getId());
894 void ClipProperties::slotEditMarker()
896 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
897 int pos = m_view.markers_list->currentIndex().row();
898 if (pos < 0 || pos > marks.count() - 1) return;
899 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
900 if (d.exec() == QDialog::Accepted) {
901 QList <CommentedTime> markers;
902 markers << d.newMarker();
903 emit addMarkers(m_clip->getId(), markers);
907 void ClipProperties::slotDeleteMarker()
909 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
910 QList < CommentedTime > toDelete;
911 for (int i = 0; i < marks.count(); ++i) {
912 if (m_view.markers_list->topLevelItem(i)->isSelected()) {
913 CommentedTime marker = marks.at(i);
914 marker.setMarkerType(-1);
918 emit addMarkers(m_clip->getId(), toDelete);
921 void ClipProperties::slotDeleteAnalysis()
923 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
924 if (current) emit editAnalysis(m_clip->getId(), current->text(0), QString());
927 void ClipProperties::slotSaveAnalysis()
929 const QString url = KFileDialog::getSaveFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Save Analysis Data"));
932 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
933 KConfigGroup analysisConfig(config, "Analysis");
934 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
935 analysisConfig.writeEntry(current->text(0), current->text(1));
938 void ClipProperties::slotLoadAnalysis()
940 const QString url = KFileDialog::getOpenFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Open Analysis Data"));
943 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
944 KConfigGroup transConfig(config, "Analysis");
946 QMap< QString, QString > profiles = transConfig.entryMap();
947 QMapIterator<QString, QString> i(profiles);
948 while (i.hasNext()) {
950 emit editAnalysis(m_clip->getId(), i.key(), i.value());
954 const QString &ClipProperties::clipId() const
956 return m_clip->getId();
959 QMap <QString, QString> ClipProperties::properties()
961 QMap <QString, QString> props;
963 CLIPTYPE t = UNKNOWN;
964 if (m_clip != NULL) {
965 t = m_clip->clipType();
966 m_old_props = m_clip->properties();
969 int aspectNumerator = m_view.clip_ar_num->value();
970 int aspectDenominator = m_view.clip_ar_den->value();
971 if (m_view.clip_force_ar->isChecked()) {
972 if (aspectNumerator != m_old_props.value("force_aspect_num").toInt() ||
973 aspectDenominator != m_old_props.value("force_aspect_den").toInt()) {
974 props["force_aspect_num"] = QString::number(aspectNumerator);
975 props["force_aspect_den"] = QString::number(aspectDenominator);
976 props["force_aspect_ratio"].clear();
977 m_clipNeedsRefresh = true;
980 if (m_old_props.contains("force_aspect_num") && !m_old_props.value("force_aspect_num").isEmpty()) {
981 props["force_aspect_num"].clear();
982 m_clipNeedsRefresh = true;
984 if (m_old_props.contains("force_aspect_den") && !m_old_props.value("force_aspect_den").isEmpty()) {
985 props["force_aspect_den"].clear();
986 m_clipNeedsRefresh = true;
990 double fps = m_view.clip_framerate->value();
991 if (m_view.clip_force_framerate->isChecked()) {
992 if (fps != m_old_props.value("force_fps").toDouble()) {
993 props["force_fps"] = locale.toString(fps);
994 m_clipNeedsRefresh = true;
996 } else if (m_old_props.contains("force_fps") && !m_old_props.value("force_fps").isEmpty()) {
997 props["force_fps"].clear();
998 m_clipNeedsRefresh = true;
1001 int progressive = m_view.clip_progressive->currentIndex();
1002 if (m_view.clip_force_progressive->isChecked()) {
1003 if (!m_old_props.contains("force_progressive") || progressive != m_old_props.value("force_progressive").toInt()) {
1004 props["force_progressive"] = QString::number(progressive);
1006 } else if (m_old_props.contains("force_progressive") && !m_old_props.value("force_progressive").isEmpty()) {
1007 props["force_progressive"].clear();
1010 int fieldOrder = m_view.clip_fieldorder->currentIndex();
1011 if (m_view.clip_force_fieldorder->isChecked()) {
1012 if (!m_old_props.contains("force_tff") || fieldOrder != m_old_props.value("force_tff").toInt()) {
1013 props["force_tff"] = QString::number(fieldOrder);
1015 } else if (m_old_props.contains("force_tff") && !m_old_props.value("force_tff").isEmpty()) {
1016 props["force_tff"].clear();
1019 int threads = m_view.clip_threads->value();
1020 if (m_view.clip_force_threads->isChecked()) {
1021 if (threads != m_old_props.value("threads").toInt()) {
1022 props["threads"] = QString::number(threads);
1024 } else if (m_old_props.contains("threads") && !m_old_props.value("threads").isEmpty()) {
1025 props["threads"].clear();
1028 int vindex = m_view.clip_vindex->value();
1029 if (m_view.clip_force_vindex->isChecked()) {
1030 if (vindex != m_old_props.value("video_index").toInt()) {
1031 props["video_index"] = QString::number(vindex);
1033 } else if (m_old_props.contains("video_index") && !m_old_props.value("video_index").isEmpty()) {
1034 props["video_index"].clear();
1037 int aindex = m_view.clip_aindex->value();
1038 if (m_view.clip_force_aindex->isChecked()) {
1039 if (aindex != m_old_props.value("audio_index").toInt()) {
1040 props["audio_index"] = QString::number(aindex);
1042 } else if (m_old_props.contains("audio_index") && !m_old_props.value("audio_index").isEmpty()) {
1043 props["audio_index"].clear();
1046 int colorspace = m_view.clip_colorspace->itemData(m_view.clip_colorspace->currentIndex()).toInt();
1047 if (m_view.clip_force_colorspace->isChecked()) {
1048 if (colorspace != m_old_props.value("force_colorspace").toInt()) {
1049 props["force_colorspace"] = QString::number(colorspace);
1050 m_clipNeedsRefresh = true;
1052 } else if (m_old_props.contains("force_colorspace") && !m_old_props.value("force_colorspace").isEmpty()) {
1053 props["force_colorspace"].clear();
1054 m_clipNeedsRefresh = true;
1057 if (m_view.clip_full_luma->isChecked()) {
1058 props["full_luma"] = QString::number(1);
1059 m_clipNeedsRefresh = true;
1060 } else if (m_old_props.contains("full_luma") && !m_old_props.value("full_luma").isEmpty()) {
1061 props["full_luma"].clear();
1062 m_clipNeedsRefresh = true;
1065 if (m_view.clip_force_transparency->isChecked()) {
1066 QString transp = QString::number(m_view.clip_transparency->currentIndex());
1067 if (transp != m_old_props.value("transparency")) props["transparency"] = transp;
1070 // If we adjust several clips, return now
1071 if (m_clip == NULL) {
1072 if (m_view.clip_out->isEnabled()) {
1073 int duration = m_tc.getFrameCount(m_view.clip_out->text());
1074 if (duration != m_old_props.value("out").toInt()) {
1075 props["out"] = QString::number(duration - 1);
1081 if (m_old_props.value("description") != m_view.clip_description->text())
1082 props["description"] = m_view.clip_description->text();
1085 QString new_color = m_view.clip_color->color().name();
1086 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
1087 m_clipNeedsRefresh = true;
1088 props["colour"] = "0x" + new_color.right(6) + "ff";
1090 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1091 if (duration != m_clip->duration().frames(m_fps)) {
1092 props["out"] = QString::number(duration - 1);
1094 } else if (t == IMAGE) {
1095 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
1096 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
1097 //m_clipNeedsRefresh = true;
1099 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1100 if (duration != m_clip->duration().frames(m_fps)) {
1101 props["out"] = QString::number(duration - 1);
1103 } else if (t == SLIDESHOW) {
1104 QString value = QString::number((int) m_view.slide_loop->isChecked());
1105 if (m_old_props.value("loop") != value) props["loop"] = value;
1106 value = QString::number((int) m_view.slide_crop->isChecked());
1107 if (m_old_props.value("crop") != value) props["crop"] = value;
1108 value = QString::number((int) m_view.slide_fade->isChecked());
1109 if (m_old_props.value("fade") != value) props["fade"] = value;
1110 value = QString::number((int) m_view.luma_softness->value());
1111 if (m_old_props.value("softness") != value) props["softness"] = value;
1113 bool isMime = !(m_view.clip_path->text().contains('%'));
1115 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1116 QString new_path = m_view.clip_path->text() + extension;
1117 if (new_path != m_old_props.value("resource")) {
1118 m_clipNeedsReLoad = true;
1119 props["resource"] = new_path;
1120 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
1124 if (m_view.slide_duration_format->currentIndex() == 1) {
1125 // we are in frames mode
1126 duration = m_view.slide_duration_frames->value();
1127 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
1128 if (duration != m_old_props.value("ttl").toInt()) {
1129 m_clipNeedsRefresh = true;
1130 props["ttl"] = QString::number(duration);
1131 props["length"] = QString::number(duration * m_count);
1134 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
1135 m_clipNeedsRefresh = true;
1136 props["out"] = QString::number(duration * m_count - 1);
1138 if (m_view.slide_fade->isChecked()) {
1140 if (m_view.slide_duration_format->currentIndex() == 1) {
1141 // we are in frames mode
1142 luma_duration = m_view.luma_duration_frames->value();
1143 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
1144 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
1145 m_clipNeedsRefresh = true;
1146 props["luma_duration"] = QString::number(luma_duration);
1149 if (m_view.slide_luma->isChecked())
1150 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
1151 if (lumaFile != m_old_props.value("luma_file")) {
1152 m_clipNeedsRefresh = true;
1153 props["luma_file"] = lumaFile;
1156 if (!m_old_props.value("luma_file").isEmpty()) {
1157 props["luma_file"].clear();
1161 QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
1162 if (animation != m_old_props.value("animation")) {
1163 if (animation.isEmpty()) {
1164 props["animation"].clear();
1166 props["animation"] = animation;
1168 m_clipNeedsRefresh = true;
1174 bool ClipProperties::needsTimelineRefresh() const
1176 return m_clipNeedsRefresh;
1179 bool ClipProperties::needsTimelineReload() const
1181 return m_clipNeedsReLoad;
1185 void ClipProperties::parseFolder(bool reloadThumb)
1187 QString path = m_view.clip_path->text();
1188 bool isMime = !(path.contains('%'));
1189 if (!isMime) path = KUrl(path).directory();
1192 QStringList filters;
1196 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
1197 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1198 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1199 dir.setNameFilters(filters);
1202 QStringList result = dir.entryList(QDir::Files);
1206 QString path = m_view.clip_path->text();
1207 if (path.contains('?')) {
1209 offset = m_view.clip_path->text().section(':', -1).toInt();
1210 path = path.section('?', 0, 0);
1212 QString filter = KUrl(path).fileName();
1213 QString ext = filter.section('.', -1);
1214 filter = filter.section('%', 0, -2);
1215 QString regexp = '^' + filter + "\\d+\\." + ext + '$';
1217 QStringList entries;
1219 foreach(const QString & path, result) {
1220 if (rx.exactMatch(path)) {
1222 // make sure our image is in the range we want (> begin)
1223 ix = path.section(filter, 1).section('.', 0, 0).toInt();
1224 if (ix < offset) continue;
1232 m_count = result.count();
1233 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(m_count > 0);
1235 // no images, do not accept that
1236 m_view.slide_info->setText(i18n("No image found"));
1237 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
1240 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
1241 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
1242 QMap <QString, QString> props = m_clip->properties();
1243 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
1245 int width = 180.0 * KdenliveSettings::project_display_ratio();
1246 if (width % 2 == 1) width++;
1247 QString filePath = m_view.clip_path->text();
1248 if (isMime) filePath.append(extension);
1249 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
1250 m_view.clip_thumb->setPixmap(pix);
1254 void ClipProperties::slotCheckMaxLength()
1256 if (m_clip->maxDuration() == GenTime())
1258 const int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1259 if (duration > m_clip->maxDuration().frames(m_fps)) {
1260 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
1264 void ClipProperties::slotUpdateDurationFormat(int ix)
1266 bool framesFormat = (ix == 1);
1268 // switching to frames count, update widget
1269 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
1270 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
1271 m_view.slide_duration->setHidden(true);
1272 m_view.luma_duration->setHidden(true);
1273 m_view.slide_duration_frames->setHidden(false);
1274 m_view.luma_duration_frames->setHidden(false);
1276 // switching to timecode format
1277 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
1278 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
1279 m_view.slide_duration_frames->setHidden(true);
1280 m_view.luma_duration_frames->setHidden(true);
1281 m_view.slide_duration->setHidden(false);
1282 m_view.luma_duration->setHidden(false);
1286 void ClipProperties::slotDeleteProxy()
1288 const QString proxy = m_clip->getProperty("proxy");
1289 if (proxy.isEmpty())
1291 emit deleteProxy(proxy);
1292 delete m_proxyContainer;
1295 void ClipProperties::slotOpenUrl(const QString &url)
1297 new KRun(KUrl(url), this);
1300 #include "clipproperties.moc"