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, QString> meta = m_clip->metadata();
200 QMap<QString, QString>::const_iterator i = meta.constBegin();
201 while (i != meta.constEnd()) {
202 QTreeWidgetItem *metaitem = new QTreeWidgetItem(m_view.metadata_list);
203 metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
204 metaitem->setText(1, i.value());
208 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
209 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
210 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
211 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
212 connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), m_view.clip_fieldorder, SLOT(setEnabled(bool)));
213 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
214 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
215 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
216 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
218 if (props.contains("audiocodec"))
219 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Audio codec") << props.value("audiocodec"));
221 if (props.contains("channels"))
222 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Channels") << props.value("channels"));
224 if (props.contains("frequency"))
225 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Frequency") << props.value("frequency"));
228 CLIPTYPE t = m_clip->clipType();
230 if (props.contains("proxy") && props.value("proxy") != "-") {
231 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, KUrl(props.value("proxy")), true);
232 QFrame* line = new QFrame();
233 line->setFrameShape(QFrame::HLine);
234 line->setFrameShadow(QFrame::Sunken);
235 m_proxyContainer = new QFrame();
236 m_proxyContainer->setFrameShape(QFrame::NoFrame);
237 QHBoxLayout *l = new QHBoxLayout;
238 l->addWidget(new QLabel(i18n("Proxy clip: %1", KIO::convertSize(f.size()))));
240 QPushButton *pb = new QPushButton(i18n("Delete proxy"));
242 connect(pb, SIGNAL(clicked()), this, SLOT(slotDeleteProxy()));
243 m_proxyContainer->setLayout(l);
245 m_view.tab_image->layout()->addWidget(line);
246 m_view.tab_image->layout()->addWidget(m_proxyContainer);
248 else if (t == AUDIO) {
249 m_view.tab_audio->layout()->addWidget(line);
250 m_view.tab_audio->layout()->addWidget(m_proxyContainer);
253 m_view.tab_video->layout()->addWidget(line);
254 m_view.tab_video->layout()->addWidget(m_proxyContainer);
258 if (t != AUDIO && t != AV) {
259 m_view.clip_force_aindex->setEnabled(false);
262 if (t != VIDEO && t != AV) {
263 m_view.clip_force_vindex->setEnabled(false);
267 m_view.tabWidget->setTabText(VIDEOTAB, i18n("Playlist"));
270 m_view.tabWidget->removeTab(SLIDETAB);
271 m_view.tabWidget->removeTab(COLORTAB);
272 m_view.tabWidget->removeTab(AUDIOTAB);
273 m_view.tabWidget->removeTab(VIDEOTAB);
274 if (props.contains("frame_size"))
275 m_view.image_size->setText(props.value("frame_size"));
276 if (props.contains("transparency"))
277 m_view.image_transparency->setChecked(props.value("transparency").toInt());
278 connect(m_view.image_transparency, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
279 int width = 180.0 * KdenliveSettings::project_display_ratio();
280 if (width % 2 == 1) width++;
281 m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
282 } else if (t == COLOR) {
283 m_view.clip_path->setEnabled(false);
284 m_view.tabWidget->removeTab(METATAB);
285 m_view.tabWidget->removeTab(IMAGETAB);
286 m_view.tabWidget->removeTab(SLIDETAB);
287 m_view.tabWidget->removeTab(AUDIOTAB);
288 m_view.tabWidget->removeTab(VIDEOTAB);
289 m_view.clip_thumb->setHidden(true);
290 m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
291 connect(m_view.clip_color, SIGNAL(changed(QColor)), this, SLOT(slotModified()));
292 } else if (t == SLIDESHOW) {
293 if (url.fileName().startsWith(".all.")) {
294 // the image sequence is defined by mimetype
295 m_view.clip_path->setText(url.directory());
297 // the image sequence is defined by pattern
298 m_view.slide_type_label->setHidden(true);
299 m_view.image_type->setHidden(true);
300 m_view.clip_path->setText(url.path());
303 m_view.tabWidget->removeTab(METATAB);
304 m_view.tabWidget->removeTab(IMAGETAB);
305 m_view.tabWidget->removeTab(COLORTAB);
306 m_view.tabWidget->removeTab(AUDIOTAB);
307 m_view.tabWidget->removeTab(VIDEOTAB);
309 //WARNING: Keep in sync with slideshowclip.cpp
310 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
311 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
312 m_view.image_type->addItem("PNG (*.png)", "png");
313 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
314 m_view.image_type->addItem("GIF (*.gif)", "gif");
315 m_view.image_type->addItem("TGA (*.tga)", "tga");
316 m_view.image_type->addItem("TIF (*.tif)", "tif");
317 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
318 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
319 m_view.animation->addItem(i18n("None"), QString());
320 m_view.animation->addItem(i18n("Pan"), "Pan");
321 m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass");
322 m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom");
323 m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass");
324 m_view.animation->addItem(i18n("Zoom"), "Zoom");
325 m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass");
327 m_view.slide_loop->setChecked(props.value("loop").toInt());
328 m_view.slide_crop->setChecked(props.value("crop").toInt());
329 m_view.slide_fade->setChecked(props.value("fade").toInt());
330 m_view.luma_softness->setValue(props.value("softness").toInt());
331 if (!props.value("animation").isEmpty())
332 m_view.animation->setCurrentItem(props.value("animation"));
334 m_view.animation->setCurrentIndex(0);
335 QString path = props.value("resource");
336 QString ext = path.section('.', -1);
337 for (int i = 0; i < m_view.image_type->count(); i++) {
338 if (m_view.image_type->itemData(i).toString() == ext) {
339 m_view.image_type->setCurrentIndex(i);
343 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
345 m_view.slide_duration_format->addItem(i18n("hh:mm:ss:ff"));
346 m_view.slide_duration_format->addItem(i18n("Frames"));
347 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
348 m_view.slide_duration_frames->setHidden(true);
349 m_view.luma_duration_frames->setHidden(true);
353 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
354 QString lumaFile = props.value("luma_file");
356 // Check for Kdenlive installed luma files
358 filters << "*.pgm" << "*.png";
360 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
361 foreach(const QString & folder, customLumas) {
362 QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
363 foreach(const QString & fname, filesnames) {
364 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
365 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
369 // Check for MLT lumas
370 QString profilePath = KdenliveSettings::mltpath();
371 QString folder = profilePath.section('/', 0, -3);
372 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
373 QDir lumafolder(folder);
374 QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
375 foreach(const QString & fname, filesnames) {
376 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
377 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
380 if (!lumaFile.isEmpty()) {
381 m_view.slide_luma->setChecked(true);
382 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
383 } else m_view.luma_file->setEnabled(false);
384 slotEnableLuma(m_view.slide_fade->checkState());
385 slotEnableLumaFile(m_view.slide_luma->checkState());
387 connect(m_view.slide_fade, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
388 connect(m_view.slide_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
389 connect(m_view.slide_loop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
390 connect(m_view.slide_crop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
391 connect(m_view.slide_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
392 connect(m_view.slide_duration_frames, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
393 connect(m_view.luma_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
394 connect(m_view.luma_softness, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
395 connect(m_view.luma_file, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
396 connect(m_view.animation, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
399 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
400 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
401 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
403 } else if (t != AUDIO) {
404 m_view.tabWidget->removeTab(IMAGETAB);
405 m_view.tabWidget->removeTab(SLIDETAB);
406 m_view.tabWidget->removeTab(COLORTAB);
408 PropertiesViewDelegate *del1 = new PropertiesViewDelegate(this);
409 PropertiesViewDelegate *del2 = new PropertiesViewDelegate(this);
410 m_view.clip_vproperties->setItemDelegate(del1);
411 m_view.clip_aproperties->setItemDelegate(del2);
412 m_view.clip_aproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
413 m_view.clip_vproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
414 loadVideoProperties(props);
416 m_view.clip_thumb->setMinimumSize(180 * KdenliveSettings::project_display_ratio(), 180);
418 if (t == IMAGE || t == VIDEO || t == PLAYLIST) m_view.tabWidget->removeTab(AUDIOTAB);
420 m_view.tabWidget->removeTab(IMAGETAB);
421 m_view.tabWidget->removeTab(SLIDETAB);
422 m_view.tabWidget->removeTab(COLORTAB);
423 m_view.tabWidget->removeTab(VIDEOTAB);
424 m_view.clip_thumb->setHidden(true);
427 if (t != SLIDESHOW && t != COLOR) {
428 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
429 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
431 m_view.clip_filesize->setHidden(true);
432 m_view.label_size->setHidden(true);
434 m_view.clip_duration->setInputMask(tc.mask());
435 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
436 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
438 connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
439 connect(m_view.clip_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
443 m_view.marker_new->setIcon(KIcon("document-new"));
444 m_view.marker_new->setToolTip(i18n("Add marker"));
445 m_view.marker_edit->setIcon(KIcon("document-properties"));
446 m_view.marker_edit->setToolTip(i18n("Edit marker"));
447 m_view.marker_delete->setIcon(KIcon("trash-empty"));
448 m_view.marker_delete->setToolTip(i18n("Delete marker"));
449 m_view.marker_save->setIcon(KIcon("document-save-as"));
450 m_view.marker_save->setToolTip(i18n("Save markers"));
451 m_view.marker_load->setIcon(KIcon("document-open"));
452 m_view.marker_load->setToolTip(i18n("Load markers"));
453 m_view.analysis_delete->setIcon(KIcon("trash-empty"));
454 m_view.analysis_delete->setToolTip(i18n("Delete analysis data"));
455 m_view.analysis_load->setIcon(KIcon("document-open"));
456 m_view.analysis_load->setToolTip(i18n("Load analysis data"));
457 m_view.analysis_save->setIcon(KIcon("document-save-as"));
458 m_view.analysis_save->setToolTip(i18n("Save analysis data"));
460 // Check for Nepomuk metadata
462 #if KDE_IS_VERSION(4,6,0)
463 if (!url.isEmpty()) {
464 Nepomuk::ResourceManager::instance()->init();
465 Nepomuk::Resource res( url.path() );
466 // Check if file has a license
467 if (res.hasProperty(Nepomuk::Vocabulary::NIE::license())) {
468 QString ltype = res.property(Nepomuk::Vocabulary::NIE::licenseType()).toString();
469 m_view.clip_license->setText(i18n("License: %1", res.property(Nepomuk::Vocabulary::NIE::license()).toString()));
470 if (ltype.startsWith("http")) {
471 m_view.clip_license->setUrl(ltype);
472 connect(m_view.clip_license, SIGNAL(leftClickedUrl(const QString &)), this, SLOT(slotOpenUrl(const QString &)));
475 else m_view.clip_license->setHidden(true);
477 else m_view.clip_license->setHidden(true);
479 m_view.clip_license->setHidden(true);
482 m_view.clip_license->setHidden(true);
485 slotFillMarkersList(m_clip);
486 slotUpdateAnalysisData(m_clip);
488 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
489 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
490 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
491 connect(m_view.marker_save, SIGNAL(clicked()), this, SLOT(slotSaveMarkers()));
492 connect(m_view.marker_load, SIGNAL(clicked()), this, SLOT(slotLoadMarkers()));
493 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
495 connect(m_view.analysis_delete, SIGNAL(clicked()), this, SLOT(slotDeleteAnalysis()));
496 connect(m_view.analysis_save, SIGNAL(clicked()), this, SLOT(slotSaveAnalysis()));
497 connect(m_view.analysis_load, SIGNAL(clicked()), this, SLOT(slotLoadAnalysis()));
499 connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
500 connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
501 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
503 m_view.metadata_list->resizeColumnToContents(0);
504 m_view.clip_vproperties->resizeColumnToContents(0);
505 m_view.clip_aproperties->resizeColumnToContents(0);
510 // Used for multiple clips editing
511 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
517 m_clipNeedsRefresh(false),
518 m_clipNeedsReLoad(false)
520 setFont(KGlobalSettings::toolBarFont());
521 m_view.setupUi(this);
522 QString title = windowTitle();
523 title.append(' ' + i18np("(%1 clip)", "(%1 clips)", cliplist.count()));
524 setWindowTitle(title);
525 QMap <QString, QString> props = cliplist.at(0)->properties();
526 m_old_props = commonproperties;
528 if (commonproperties.contains("force_aspect_num") && !commonproperties.value("force_aspect_num").isEmpty() && commonproperties.value("force_aspect_den").toInt() > 0) {
529 m_view.clip_force_ar->setChecked(true);
530 m_view.clip_ar_num->setEnabled(true);
531 m_view.clip_ar_den->setEnabled(true);
532 m_view.clip_ar_num->setValue(commonproperties.value("force_aspect_num").toInt());
533 m_view.clip_ar_den->setValue(commonproperties.value("force_aspect_den").toInt());
536 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
537 m_view.clip_force_framerate->setChecked(true);
538 m_view.clip_framerate->setEnabled(true);
539 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
542 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
543 m_view.clip_force_progressive->setChecked(true);
544 m_view.clip_progressive->setEnabled(true);
545 m_view.clip_progressive->setCurrentIndex(commonproperties.value("force_progressive").toInt());
548 if (commonproperties.contains("force_tff") && !commonproperties.value("force_tff").isEmpty()) {
549 m_view.clip_force_fieldorder->setChecked(true);
550 m_view.clip_fieldorder->setEnabled(true);
551 m_view.clip_fieldorder->setCurrentIndex(commonproperties.value("force_tff").toInt());
554 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
555 m_view.clip_force_threads->setChecked(true);
556 m_view.clip_threads->setEnabled(true);
557 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
560 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
561 m_view.clip_force_vindex->setChecked(true);
562 m_view.clip_vindex->setEnabled(true);
563 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
566 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
567 m_view.clip_force_aindex->setChecked(true);
568 m_view.clip_aindex->setEnabled(true);
569 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
572 if (props.contains("audio_max")) {
573 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
576 if (props.contains("video_max")) {
577 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
580 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
581 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
582 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
584 if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
585 m_view.clip_force_colorspace->setChecked(true);
586 m_view.clip_colorspace->setEnabled(true);
587 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
590 if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
591 m_view.clip_full_luma->setChecked(true);
594 if (commonproperties.contains("transparency")) {
595 // image transparency checkbox
596 int transparency = commonproperties.value("transparency").toInt();
597 if (transparency == 0) {
598 m_view.clip_force_transparency->setChecked(true);
600 else if (transparency == 1) {
601 m_view.clip_force_transparency->setChecked(true);
602 m_view.clip_transparency->setCurrentIndex(1);
606 m_view.clip_force_transparency->setHidden(true);
607 m_view.clip_transparency->setHidden(true);
611 connect(m_view.clip_force_transparency, SIGNAL(toggled(bool)), m_view.clip_transparency, SLOT(setEnabled(bool)));
612 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
613 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
614 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
615 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
616 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
617 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
618 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
619 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
621 m_view.tabWidget->removeTab(METATAB);
622 m_view.tabWidget->removeTab(MARKERTAB);
623 m_view.tabWidget->removeTab(IMAGETAB);
624 m_view.tabWidget->removeTab(SLIDETAB);
625 m_view.tabWidget->removeTab(COLORTAB);
626 m_view.tabWidget->removeTab(AUDIOTAB);
627 m_view.tabWidget->removeTab(VIDEOTAB);
629 m_view.clip_path->setHidden(true);
630 m_view.label_path->setHidden(true);
631 m_view.label_description->setHidden(true);
632 m_view.label_size->setHidden(true);
633 m_view.clip_filesize->setHidden(true);
634 m_view.clip_filesize->setHidden(true);
635 m_view.clip_path->setHidden(true);
636 m_view.clip_description->setHidden(true);
637 m_view.clip_thumb->setHidden(true);
638 m_view.label_duration->setHidden(true);
639 m_view.clip_duration->setHidden(true);
641 if (commonproperties.contains("out")) {
642 if (commonproperties.value("out").toInt() > 0) {
643 m_view.clip_force_out->setChecked(true);
644 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
645 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
647 m_view.clip_force_out->setHidden(true);
648 m_view.clip_out->setHidden(true);
652 ClipProperties::~ClipProperties()
654 QAbstractItemDelegate *del1 = m_view.clip_vproperties->itemDelegate();
655 if (del1) delete del1;
656 QAbstractItemDelegate *del2 = m_view.clip_aproperties->itemDelegate();
657 if (del2) delete del2;
661 void ClipProperties::loadVideoProperties(QMap <QString, QString> props)
663 m_view.clip_vproperties->clear();
664 if (props.contains("videocodec"))
665 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodec"));
666 else if (props.contains("videocodecid"))
667 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodecid"));
669 if (props.contains("frame_size"))
670 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
672 if (props.contains("fps")) {
673 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
674 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
677 if (props.contains("progressive")) {
678 int scanning = props.value("progressive").toInt();
679 QString txt = scanning == 1 ? i18n("Progressive") : i18n("Interlaced");
680 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Scanning") << txt);
683 if (props.contains("aspect_ratio"))
684 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
686 if (props.contains("pix_fmt"))
687 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
689 if (props.contains("colorspace"))
690 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
693 void ClipProperties::slotGotThumbnail(const QString &id, QImage img)
695 if (id != m_clip->getId()) return;
696 QPixmap framedPix(img.width(), img.height());
697 framedPix.fill(Qt::transparent);
698 QPainter p(&framedPix);
699 p.setRenderHint(QPainter::Antialiasing, true);
701 path.addRoundedRect(0.5, 0.5, framedPix.width() - 1, framedPix.height() - 1, 4, 4);
703 p.drawImage(0, 0, img);
705 m_view.clip_thumb->setPixmap(framedPix);
708 void ClipProperties::slotApplyProperties()
710 if (m_clip != NULL) {
711 QMap <QString, QString> props = properties();
712 emit applyNewClipProperties(m_clip->getId(), m_clip->currentProperties(props), props, needsTimelineRefresh(), needsTimelineReload());
713 QTimer::singleShot(1000, this, SLOT(slotReloadVideoProperties()));
714 if (props.contains("force_aspect_num")) QTimer::singleShot(1000, this, SLOT(slotReloadVideoThumb()));
716 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
719 void ClipProperties::slotReloadVideoProperties()
721 if (m_clip == NULL) return;
722 loadVideoProperties(m_clip->properties());
725 void ClipProperties::slotReloadVideoThumb()
727 if (m_clip == NULL) return;
728 emit requestThumb(QString('?' + m_clip->getId()), QList<int>() << m_clip->getClipThumbFrame());
731 void ClipProperties::disableClipId(const QString &id)
733 if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
734 if (m_clip->getId() == id) {
735 // clip was removed from project, close this properties dialog
741 void ClipProperties::slotModified()
743 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
747 void ClipProperties::slotEnableLuma(int state)
750 if (state == Qt::Checked) enable = true;
751 m_view.luma_duration->setEnabled(enable);
752 m_view.luma_duration_frames->setEnabled(enable);
753 m_view.slide_luma->setEnabled(enable);
755 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
756 } else m_view.luma_file->setEnabled(false);
757 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
758 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
761 void ClipProperties::slotEnableLumaFile(int state)
764 if (state == Qt::Checked) enable = true;
765 m_view.luma_file->setEnabled(enable);
766 m_view.luma_softness->setEnabled(enable);
767 m_view.label_softness->setEnabled(enable);
770 void ClipProperties::slotUpdateAnalysisData(DocClipBase *clip)
772 if (m_clip != clip) return;
773 m_view.analysis_list->clear();
774 QMap <QString, QString> analysis = clip->analysisData();
775 m_view.analysis_box->setHidden(analysis.isEmpty());
776 QMap<QString, QString>::const_iterator i = analysis.constBegin();
777 while (i != analysis.constEnd()) {
778 QStringList itemtext;
779 itemtext << i.key() << i.value();
780 (void) new QTreeWidgetItem(m_view.analysis_list, itemtext);
785 void ClipProperties::slotFillMarkersList(DocClipBase *clip)
787 if (m_clip != clip) return;
788 m_view.markers_list->clear();
789 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
790 for (int count = 0; count < marks.count(); ++count) {
791 QString time = m_tc.getTimecode(marks[count].time());
792 QStringList itemtext;
793 itemtext << time << marks.at(count).comment();
794 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.markers_list, itemtext);
795 item->setData(0, Qt::DecorationRole, CommentedTime::markerColor(marks.at(count).markerType()));
799 void ClipProperties::slotAddMarker()
801 CommentedTime marker(GenTime(), i18n("Marker"));
802 QPointer<MarkerDialog> d = new MarkerDialog(m_clip, marker,
803 m_tc, i18n("Add Marker"), this);
804 if (d->exec() == QDialog::Accepted) {
805 QList <CommentedTime> markers;
806 markers << d->newMarker();
807 emit addMarkers(m_clip->getId(), markers);
812 void ClipProperties::slotSaveMarkers()
814 emit saveMarkers(m_clip->getId());
817 void ClipProperties::slotLoadMarkers()
819 emit loadMarkers(m_clip->getId());
822 void ClipProperties::slotEditMarker()
824 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
825 int pos = m_view.markers_list->currentIndex().row();
826 if (pos < 0 || pos > marks.count() - 1) return;
827 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
828 if (d.exec() == QDialog::Accepted) {
829 QList <CommentedTime> markers;
830 markers << d.newMarker();
831 emit addMarkers(m_clip->getId(), markers);
835 void ClipProperties::slotDeleteMarker()
837 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
838 QList < CommentedTime > toDelete;
839 for (int i = 0; i < marks.count(); i++) {
840 if (m_view.markers_list->topLevelItem(i)->isSelected()) {
841 CommentedTime marker = marks.at(i);
842 marker.setMarkerType(-1);
846 emit addMarkers(m_clip->getId(), toDelete);
849 void ClipProperties::slotDeleteAnalysis()
851 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
852 if (current) emit editAnalysis(m_clip->getId(), current->text(0), QString());
855 void ClipProperties::slotSaveAnalysis()
857 QString url = KFileDialog::getSaveFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Save Analysis Data"));
858 if (url.isEmpty()) return;
859 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
860 KConfigGroup analysisConfig(config, "Analysis");
861 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
862 analysisConfig.writeEntry(current->text(0), current->text(1));
865 void ClipProperties::slotLoadAnalysis()
867 QString url = KFileDialog::getOpenFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Open Analysis Data"));
868 if (url.isEmpty()) return;
869 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
870 KConfigGroup transConfig(config, "Analysis");
872 QMap< QString, QString > profiles = transConfig.entryMap();
873 QMapIterator<QString, QString> i(profiles);
874 while (i.hasNext()) {
876 emit editAnalysis(m_clip->getId(), i.key(), i.value());
880 const QString &ClipProperties::clipId() const
882 return m_clip->getId();
886 QMap <QString, QString> ClipProperties::properties()
888 QMap <QString, QString> props;
890 CLIPTYPE t = UNKNOWN;
891 if (m_clip != NULL) {
892 t = m_clip->clipType();
893 m_old_props = m_clip->properties();
896 int aspectNumerator = m_view.clip_ar_num->value();
897 int aspectDenominator = m_view.clip_ar_den->value();
898 if (m_view.clip_force_ar->isChecked()) {
899 if (aspectNumerator != m_old_props.value("force_aspect_num").toInt() ||
900 aspectDenominator != m_old_props.value("force_aspect_den").toInt()) {
901 props["force_aspect_num"] = QString::number(aspectNumerator);
902 props["force_aspect_den"] = QString::number(aspectDenominator);
903 props["force_aspect_ratio"].clear();
904 m_clipNeedsRefresh = true;
907 if (m_old_props.contains("force_aspect_num") && !m_old_props.value("force_aspect_num").isEmpty()) {
908 props["force_aspect_num"].clear();
909 m_clipNeedsRefresh = true;
911 if (m_old_props.contains("force_aspect_den") && !m_old_props.value("force_aspect_den").isEmpty()) {
912 props["force_aspect_den"].clear();
913 m_clipNeedsRefresh = true;
917 double fps = m_view.clip_framerate->value();
918 if (m_view.clip_force_framerate->isChecked()) {
919 if (fps != m_old_props.value("force_fps").toDouble()) {
920 props["force_fps"] = locale.toString(fps);
921 m_clipNeedsRefresh = true;
923 } else if (m_old_props.contains("force_fps") && !m_old_props.value("force_fps").isEmpty()) {
924 props["force_fps"].clear();
925 m_clipNeedsRefresh = true;
928 int progressive = m_view.clip_progressive->currentIndex();
929 if (m_view.clip_force_progressive->isChecked()) {
930 if (!m_old_props.contains("force_progressive") || progressive != m_old_props.value("force_progressive").toInt()) {
931 props["force_progressive"] = QString::number(progressive);
933 } else if (m_old_props.contains("force_progressive") && !m_old_props.value("force_progressive").isEmpty()) {
934 props["force_progressive"].clear();
937 int fieldOrder = m_view.clip_fieldorder->currentIndex();
938 if (m_view.clip_force_fieldorder->isChecked()) {
939 if (!m_old_props.contains("force_tff") || fieldOrder != m_old_props.value("force_tff").toInt()) {
940 props["force_tff"] = QString::number(fieldOrder);
942 } else if (m_old_props.contains("force_tff") && !m_old_props.value("force_tff").isEmpty()) {
943 props["force_tff"].clear();
946 int threads = m_view.clip_threads->value();
947 if (m_view.clip_force_threads->isChecked()) {
948 if (threads != m_old_props.value("threads").toInt()) {
949 props["threads"] = QString::number(threads);
951 } else if (m_old_props.contains("threads") && !m_old_props.value("threads").isEmpty()) {
952 props["threads"].clear();
955 int vindex = m_view.clip_vindex->value();
956 if (m_view.clip_force_vindex->isChecked()) {
957 if (vindex != m_old_props.value("video_index").toInt()) {
958 props["video_index"] = QString::number(vindex);
960 } else if (m_old_props.contains("video_index") && !m_old_props.value("video_index").isEmpty()) {
961 props["video_index"].clear();
964 int aindex = m_view.clip_aindex->value();
965 if (m_view.clip_force_aindex->isChecked()) {
966 if (aindex != m_old_props.value("audio_index").toInt()) {
967 props["audio_index"] = QString::number(aindex);
969 } else if (m_old_props.contains("audio_index") && !m_old_props.value("audio_index").isEmpty()) {
970 props["audio_index"].clear();
973 int colorspace = m_view.clip_colorspace->itemData(m_view.clip_colorspace->currentIndex()).toInt();
974 if (m_view.clip_force_colorspace->isChecked()) {
975 if (colorspace != m_old_props.value("force_colorspace").toInt()) {
976 props["force_colorspace"] = QString::number(colorspace);
977 m_clipNeedsRefresh = true;
979 } else if (m_old_props.contains("force_colorspace") && !m_old_props.value("force_colorspace").isEmpty()) {
980 props["force_colorspace"].clear();
981 m_clipNeedsRefresh = true;
984 if (m_view.clip_full_luma->isChecked()) {
985 props["full_luma"] = QString::number(1);
986 m_clipNeedsRefresh = true;
987 } else if (m_old_props.contains("full_luma") && !m_old_props.value("full_luma").isEmpty()) {
988 props["full_luma"].clear();
989 m_clipNeedsRefresh = true;
992 if (m_view.clip_force_transparency->isChecked()) {
993 QString transp = QString::number(m_view.clip_transparency->currentIndex());
994 if (transp != m_old_props.value("transparency")) props["transparency"] = transp;
997 // If we adjust several clips, return now
998 if (m_clip == NULL) {
999 if (m_view.clip_out->isEnabled()) {
1000 int duration = m_tc.getFrameCount(m_view.clip_out->text());
1001 if (duration != m_old_props.value("out").toInt()) {
1002 props["out"] = QString::number(duration - 1);
1008 if (m_old_props.value("description") != m_view.clip_description->text())
1009 props["description"] = m_view.clip_description->text();
1012 QString new_color = m_view.clip_color->color().name();
1013 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
1014 m_clipNeedsRefresh = true;
1015 props["colour"] = "0x" + new_color.right(6) + "ff";
1017 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1018 if (duration != m_clip->duration().frames(m_fps)) {
1019 props["out"] = QString::number(duration - 1);
1021 } else if (t == IMAGE) {
1022 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
1023 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
1024 //m_clipNeedsRefresh = true;
1026 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1027 if (duration != m_clip->duration().frames(m_fps)) {
1028 props["out"] = QString::number(duration - 1);
1030 } else if (t == SLIDESHOW) {
1031 QString value = QString::number((int) m_view.slide_loop->isChecked());
1032 if (m_old_props.value("loop") != value) props["loop"] = value;
1033 value = QString::number((int) m_view.slide_crop->isChecked());
1034 if (m_old_props.value("crop") != value) props["crop"] = value;
1035 value = QString::number((int) m_view.slide_fade->isChecked());
1036 if (m_old_props.value("fade") != value) props["fade"] = value;
1037 value = QString::number((int) m_view.luma_softness->value());
1038 if (m_old_props.value("softness") != value) props["softness"] = value;
1040 bool isMime = !(m_view.clip_path->text().contains('%'));
1042 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1043 QString new_path = m_view.clip_path->text() + extension;
1044 if (new_path != m_old_props.value("resource")) {
1045 m_clipNeedsReLoad = true;
1046 props["resource"] = new_path;
1047 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
1051 if (m_view.slide_duration_format->currentIndex() == 1) {
1052 // we are in frames mode
1053 duration = m_view.slide_duration_frames->value();
1054 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
1055 if (duration != m_old_props.value("ttl").toInt()) {
1056 m_clipNeedsRefresh = true;
1057 props["ttl"] = QString::number(duration);
1058 props["length"] = QString::number(duration * m_count);
1061 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
1062 m_clipNeedsRefresh = true;
1063 props["out"] = QString::number(duration * m_count - 1);
1065 if (m_view.slide_fade->isChecked()) {
1067 if (m_view.slide_duration_format->currentIndex() == 1) {
1068 // we are in frames mode
1069 luma_duration = m_view.luma_duration_frames->value();
1070 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
1071 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
1072 m_clipNeedsRefresh = true;
1073 props["luma_duration"] = QString::number(luma_duration);
1076 if (m_view.slide_luma->isChecked())
1077 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
1078 if (lumaFile != m_old_props.value("luma_file")) {
1079 m_clipNeedsRefresh = true;
1080 props["luma_file"] = lumaFile;
1083 if (!m_old_props.value("luma_file").isEmpty()) {
1084 props["luma_file"].clear();
1088 QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
1089 if (animation != m_old_props.value("animation")) {
1090 if (animation.isEmpty()) {
1091 props["animation"].clear();
1093 props["animation"] = animation;
1095 m_clipNeedsRefresh = true;
1101 bool ClipProperties::needsTimelineRefresh() const
1103 return m_clipNeedsRefresh;
1106 bool ClipProperties::needsTimelineReload() const
1108 return m_clipNeedsReLoad;
1112 void ClipProperties::parseFolder(bool reloadThumb)
1114 QString path = m_view.clip_path->text();
1115 bool isMime = !(path.contains('%'));
1116 if (!isMime) path = KUrl(path).directory();
1119 QStringList filters;
1123 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
1124 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1125 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1126 dir.setNameFilters(filters);
1129 QStringList result = dir.entryList(QDir::Files);
1133 QString path = m_view.clip_path->text();
1134 if (path.contains('?')) {
1136 offset = m_view.clip_path->text().section(':', -1).toInt();
1137 path = path.section('?', 0, 0);
1139 QString filter = KUrl(path).fileName();
1140 QString ext = filter.section('.', -1);
1141 filter = filter.section('%', 0, -2);
1142 QString regexp = '^' + filter + "\\d+\\." + ext + '$';
1144 QStringList entries;
1146 foreach(const QString & path, result) {
1147 if (rx.exactMatch(path)) {
1149 // make sure our image is in the range we want (> begin)
1150 ix = path.section(filter, 1).section('.', 0, 0).toInt();
1151 if (ix < offset) continue;
1159 m_count = result.count();
1160 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(m_count > 0);
1162 // no images, do not accept that
1163 m_view.slide_info->setText(i18n("No image found"));
1164 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
1167 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
1168 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
1169 QMap <QString, QString> props = m_clip->properties();
1170 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
1172 int width = 180.0 * KdenliveSettings::project_display_ratio();
1173 if (width % 2 == 1) width++;
1174 QString filePath = m_view.clip_path->text();
1175 if (isMime) filePath.append(extension);
1176 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
1177 m_view.clip_thumb->setPixmap(pix);
1181 void ClipProperties::slotCheckMaxLength()
1183 if (m_clip->maxDuration() == GenTime()) return;
1184 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1185 if (duration > m_clip->maxDuration().frames(m_fps)) {
1186 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
1190 void ClipProperties::slotUpdateDurationFormat(int ix)
1192 bool framesFormat = ix == 1;
1194 // switching to frames count, update widget
1195 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
1196 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
1197 m_view.slide_duration->setHidden(true);
1198 m_view.luma_duration->setHidden(true);
1199 m_view.slide_duration_frames->setHidden(false);
1200 m_view.luma_duration_frames->setHidden(false);
1202 // switching to timecode format
1203 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
1204 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
1205 m_view.slide_duration_frames->setHidden(true);
1206 m_view.luma_duration_frames->setHidden(true);
1207 m_view.slide_duration->setHidden(false);
1208 m_view.luma_duration->setHidden(false);
1212 void ClipProperties::slotDeleteProxy()
1214 QString proxy = m_clip->getProperty("proxy");
1215 if (proxy.isEmpty()) return;
1216 emit deleteProxy(proxy);
1217 if (m_proxyContainer) delete m_proxyContainer;
1220 void ClipProperties::slotOpenUrl(const QString &url)
1222 new KRun(KUrl(url), this);
1225 #include "clipproperties.moc"