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()));
128 if (props.contains("force_progressive")) {
129 m_view.clip_force_progressive->setChecked(true);
130 m_view.clip_progressive->setEnabled(true);
131 m_view.clip_progressive->setValue(props.value("force_progressive").toInt());
133 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
134 connect(m_view.clip_progressive, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
136 m_view.clip_fieldorder->addItem(i18n("Bottom first"), 0);
137 m_view.clip_fieldorder->addItem(i18n("Top first"), 1);
138 if (props.contains("force_tff")) {
139 m_view.clip_force_fieldorder->setChecked(true);
140 m_view.clip_fieldorder->setEnabled(true);
141 m_view.clip_fieldorder->setCurrentIndex(props.value("force_tff").toInt());
143 connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
144 connect(m_view.clip_fieldorder, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
146 if (props.contains("threads") && props.value("threads").toInt() != 1) {
147 m_view.clip_force_threads->setChecked(true);
148 m_view.clip_threads->setEnabled(true);
149 m_view.clip_threads->setValue(props.value("threads").toInt());
151 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
152 connect(m_view.clip_threads, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
154 if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
155 m_view.clip_force_vindex->setChecked(true);
156 m_view.clip_vindex->setEnabled(true);
157 m_view.clip_vindex->setValue(props.value("video_index").toInt());
159 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
160 connect(m_view.clip_vindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
162 if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
163 m_view.clip_force_aindex->setChecked(true);
164 m_view.clip_aindex->setEnabled(true);
165 m_view.clip_aindex->setValue(props.value("audio_index").toInt());
167 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
168 connect(m_view.clip_aindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
170 if (props.contains("audio_max")) {
171 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
174 if (props.contains("video_max")) {
175 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
178 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
179 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
180 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
181 if (props.contains("force_colorspace")) {
182 m_view.clip_force_colorspace->setChecked(true);
183 m_view.clip_colorspace->setEnabled(true);
184 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("force_colorspace").toInt()));
185 } else if (props.contains("colorspace")) {
186 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("colorspace").toInt()));
188 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
189 connect(m_view.clip_colorspace, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
191 if (props.contains("full_luma")) {
192 m_view.clip_full_luma->setChecked(true);
194 connect(m_view.clip_full_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
196 // Check for Metadata
197 QMap<QString, QString> meta = m_clip->metadata();
198 QMap<QString, QString>::const_iterator i = meta.constBegin();
199 while (i != meta.constEnd()) {
200 QTreeWidgetItem *metaitem = new QTreeWidgetItem(m_view.metadata_list);
201 metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
202 metaitem->setText(1, i.value());
206 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
207 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
208 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
209 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
210 connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), m_view.clip_fieldorder, SLOT(setEnabled(bool)));
211 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
212 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
213 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
214 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
216 if (props.contains("audiocodec"))
217 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Audio codec") << props.value("audiocodec"));
219 if (props.contains("channels"))
220 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Channels") << props.value("channels"));
222 if (props.contains("frequency"))
223 new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Frequency") << props.value("frequency"));
226 CLIPTYPE t = m_clip->clipType();
228 if (props.contains("proxy") && props.value("proxy") != "-") {
229 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, KUrl(props.value("proxy")), true);
230 QFrame* line = new QFrame();
231 line->setFrameShape(QFrame::HLine);
232 line->setFrameShadow(QFrame::Sunken);
233 m_proxyContainer = new QFrame();
234 m_proxyContainer->setFrameShape(QFrame::NoFrame);
235 QHBoxLayout *l = new QHBoxLayout;
236 l->addWidget(new QLabel(i18n("Proxy clip: %1", KIO::convertSize(f.size()))));
238 QPushButton *pb = new QPushButton(i18n("Delete proxy"));
240 connect(pb, SIGNAL(clicked()), this, SLOT(slotDeleteProxy()));
241 m_proxyContainer->setLayout(l);
243 m_view.tab_image->layout()->addWidget(line);
244 m_view.tab_image->layout()->addWidget(m_proxyContainer);
246 else if (t == AUDIO) {
247 m_view.tab_audio->layout()->addWidget(line);
248 m_view.tab_audio->layout()->addWidget(m_proxyContainer);
251 m_view.tab_video->layout()->addWidget(line);
252 m_view.tab_video->layout()->addWidget(m_proxyContainer);
256 if (t != AUDIO && t != AV) {
257 m_view.clip_force_aindex->setEnabled(false);
260 if (t != VIDEO && t != AV) {
261 m_view.clip_force_vindex->setEnabled(false);
265 m_view.tabWidget->setTabText(VIDEOTAB, i18n("Playlist"));
268 m_view.tabWidget->removeTab(SLIDETAB);
269 m_view.tabWidget->removeTab(COLORTAB);
270 m_view.tabWidget->removeTab(AUDIOTAB);
271 m_view.tabWidget->removeTab(VIDEOTAB);
272 if (props.contains("frame_size"))
273 m_view.image_size->setText(props.value("frame_size"));
274 if (props.contains("transparency"))
275 m_view.image_transparency->setChecked(props.value("transparency").toInt());
276 connect(m_view.image_transparency, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
277 int width = 180.0 * KdenliveSettings::project_display_ratio();
278 if (width % 2 == 1) width++;
279 m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
280 } else if (t == COLOR) {
281 m_view.clip_path->setEnabled(false);
282 m_view.tabWidget->removeTab(METATAB);
283 m_view.tabWidget->removeTab(IMAGETAB);
284 m_view.tabWidget->removeTab(SLIDETAB);
285 m_view.tabWidget->removeTab(AUDIOTAB);
286 m_view.tabWidget->removeTab(VIDEOTAB);
287 m_view.clip_thumb->setHidden(true);
288 m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
289 connect(m_view.clip_color, SIGNAL(changed(QColor)), this, SLOT(slotModified()));
290 } else if (t == SLIDESHOW) {
291 if (url.fileName().startsWith(".all.")) {
292 // the image sequence is defined by mimetype
293 m_view.clip_path->setText(url.directory());
295 // the image sequence is defined by pattern
296 m_view.slide_type_label->setHidden(true);
297 m_view.image_type->setHidden(true);
298 m_view.clip_path->setText(url.path());
301 m_view.tabWidget->removeTab(METATAB);
302 m_view.tabWidget->removeTab(IMAGETAB);
303 m_view.tabWidget->removeTab(COLORTAB);
304 m_view.tabWidget->removeTab(AUDIOTAB);
305 m_view.tabWidget->removeTab(VIDEOTAB);
307 //WARNING: Keep in sync with slideshowclip.cpp
308 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
309 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
310 m_view.image_type->addItem("PNG (*.png)", "png");
311 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
312 m_view.image_type->addItem("GIF (*.gif)", "gif");
313 m_view.image_type->addItem("TGA (*.tga)", "tga");
314 m_view.image_type->addItem("TIF (*.tif)", "tif");
315 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
316 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
317 m_view.animation->addItem(i18n("None"), QString());
318 m_view.animation->addItem(i18n("Pan"), "Pan");
319 m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass");
320 m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom");
321 m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass");
322 m_view.animation->addItem(i18n("Zoom"), "Zoom");
323 m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass");
325 m_view.slide_loop->setChecked(props.value("loop").toInt());
326 m_view.slide_crop->setChecked(props.value("crop").toInt());
327 m_view.slide_fade->setChecked(props.value("fade").toInt());
328 m_view.luma_softness->setValue(props.value("softness").toInt());
329 if (!props.value("animation").isEmpty())
330 m_view.animation->setCurrentItem(props.value("animation"));
332 m_view.animation->setCurrentIndex(0);
333 QString path = props.value("resource");
334 QString ext = path.section('.', -1);
335 for (int i = 0; i < m_view.image_type->count(); i++) {
336 if (m_view.image_type->itemData(i).toString() == ext) {
337 m_view.image_type->setCurrentIndex(i);
341 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
343 m_view.slide_duration_format->addItem(i18n("hh:mm:ss:ff"));
344 m_view.slide_duration_format->addItem(i18n("Frames"));
345 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
346 m_view.slide_duration_frames->setHidden(true);
347 m_view.luma_duration_frames->setHidden(true);
351 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
352 QString lumaFile = props.value("luma_file");
354 // Check for Kdenlive installed luma files
356 filters << "*.pgm" << "*.png";
358 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
359 foreach(const QString & folder, customLumas) {
360 QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
361 foreach(const QString & fname, filesnames) {
362 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
363 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
367 // Check for MLT lumas
368 QString profilePath = KdenliveSettings::mltpath();
369 QString folder = profilePath.section('/', 0, -3);
370 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
371 QDir lumafolder(folder);
372 QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
373 foreach(const QString & fname, filesnames) {
374 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
375 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
378 if (!lumaFile.isEmpty()) {
379 m_view.slide_luma->setChecked(true);
380 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
381 } else m_view.luma_file->setEnabled(false);
382 slotEnableLuma(m_view.slide_fade->checkState());
383 slotEnableLumaFile(m_view.slide_luma->checkState());
385 connect(m_view.slide_fade, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
386 connect(m_view.slide_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
387 connect(m_view.slide_loop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
388 connect(m_view.slide_crop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
389 connect(m_view.slide_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
390 connect(m_view.slide_duration_frames, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
391 connect(m_view.luma_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
392 connect(m_view.luma_softness, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
393 connect(m_view.luma_file, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
394 connect(m_view.animation, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
397 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
398 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
399 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
401 } else if (t != AUDIO) {
402 m_view.tabWidget->removeTab(IMAGETAB);
403 m_view.tabWidget->removeTab(SLIDETAB);
404 m_view.tabWidget->removeTab(COLORTAB);
406 PropertiesViewDelegate *del1 = new PropertiesViewDelegate(this);
407 PropertiesViewDelegate *del2 = new PropertiesViewDelegate(this);
408 m_view.clip_vproperties->setItemDelegate(del1);
409 m_view.clip_aproperties->setItemDelegate(del2);
410 m_view.clip_aproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
411 m_view.clip_vproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
413 if (props.contains("videocodec"))
414 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodec"));
415 else if (props.contains("videocodecid"))
416 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodecid"));
418 if (props.contains("frame_size"))
419 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
421 if (props.contains("fps")) {
422 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
423 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
426 if (props.contains("progressive")) {
427 int scanning = props.value("progressive").toInt();
428 QString txt = scanning == 1 ? i18n("Progressive") : i18n("Interlaced");
429 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Scanning") << txt);
432 if (props.contains("aspect_ratio"))
433 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
435 if (props.contains("pix_fmt"))
436 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
438 if (props.contains("colorspace"))
439 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
441 m_view.clip_thumb->setMinimumSize(180 * KdenliveSettings::project_display_ratio(), 180);
443 if (t == IMAGE || t == VIDEO || t == PLAYLIST) m_view.tabWidget->removeTab(AUDIOTAB);
445 m_view.tabWidget->removeTab(IMAGETAB);
446 m_view.tabWidget->removeTab(SLIDETAB);
447 m_view.tabWidget->removeTab(COLORTAB);
448 m_view.tabWidget->removeTab(VIDEOTAB);
449 m_view.clip_thumb->setHidden(true);
452 if (t != SLIDESHOW && t != COLOR) {
453 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
454 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
456 m_view.clip_filesize->setHidden(true);
457 m_view.label_size->setHidden(true);
459 m_view.clip_duration->setInputMask(tc.mask());
460 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
461 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
463 connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
464 connect(m_view.clip_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
468 m_view.marker_new->setIcon(KIcon("document-new"));
469 m_view.marker_new->setToolTip(i18n("Add marker"));
470 m_view.marker_edit->setIcon(KIcon("document-properties"));
471 m_view.marker_edit->setToolTip(i18n("Edit marker"));
472 m_view.marker_delete->setIcon(KIcon("trash-empty"));
473 m_view.marker_delete->setToolTip(i18n("Delete marker"));
474 m_view.marker_save->setIcon(KIcon("document-save-as"));
475 m_view.marker_save->setToolTip(i18n("Save markers"));
476 m_view.marker_load->setIcon(KIcon("document-open"));
477 m_view.marker_load->setToolTip(i18n("Load markers"));
478 m_view.analysis_delete->setIcon(KIcon("trash-empty"));
479 m_view.analysis_delete->setToolTip(i18n("Delete analysis data"));
480 m_view.analysis_load->setIcon(KIcon("document-open"));
481 m_view.analysis_load->setToolTip(i18n("Load analysis data"));
482 m_view.analysis_save->setIcon(KIcon("document-save-as"));
483 m_view.analysis_save->setToolTip(i18n("Save analysis data"));
485 // Check for Nepomuk metadata
487 #if KDE_IS_VERSION(4,6,0)
488 if (!url.isEmpty()) {
489 Nepomuk::ResourceManager::instance()->init();
490 Nepomuk::Resource res( url.path() );
491 // Check if file has a license
492 if (res.hasProperty(Nepomuk::Vocabulary::NIE::license())) {
493 QString ltype = res.property(Nepomuk::Vocabulary::NIE::licenseType()).toString();
494 m_view.clip_license->setText(i18n("License: %1", res.property(Nepomuk::Vocabulary::NIE::license()).toString()));
495 if (ltype.startsWith("http")) {
496 m_view.clip_license->setUrl(ltype);
497 connect(m_view.clip_license, SIGNAL(leftClickedUrl(const QString &)), this, SLOT(slotOpenUrl(const QString &)));
500 else m_view.clip_license->setHidden(true);
502 else m_view.clip_license->setHidden(true);
504 m_view.clip_license->setHidden(true);
507 m_view.clip_license->setHidden(true);
510 slotFillMarkersList(m_clip);
511 slotUpdateAnalysisData(m_clip);
513 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
514 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
515 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
516 connect(m_view.marker_save, SIGNAL(clicked()), this, SLOT(slotSaveMarkers()));
517 connect(m_view.marker_load, SIGNAL(clicked()), this, SLOT(slotLoadMarkers()));
518 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
520 connect(m_view.analysis_delete, SIGNAL(clicked()), this, SLOT(slotDeleteAnalysis()));
521 connect(m_view.analysis_save, SIGNAL(clicked()), this, SLOT(slotSaveAnalysis()));
522 connect(m_view.analysis_load, SIGNAL(clicked()), this, SLOT(slotLoadAnalysis()));
524 connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
525 connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
526 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
531 // Used for multiple clips editing
532 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
538 m_clipNeedsRefresh(false),
539 m_clipNeedsReLoad(false)
541 setFont(KGlobalSettings::toolBarFont());
542 m_view.setupUi(this);
543 QString title = windowTitle();
544 title.append(' ' + i18np("(%1 clip)", "(%1 clips)", cliplist.count()));
545 setWindowTitle(title);
546 QMap <QString, QString> props = cliplist.at(0)->properties();
547 m_old_props = commonproperties;
549 if (commonproperties.contains("force_aspect_num") && !commonproperties.value("force_aspect_num").isEmpty() && commonproperties.value("force_aspect_den").toInt() > 0) {
550 m_view.clip_force_ar->setChecked(true);
551 m_view.clip_ar_num->setEnabled(true);
552 m_view.clip_ar_den->setEnabled(true);
553 m_view.clip_ar_num->setValue(commonproperties.value("force_aspect_num").toInt());
554 m_view.clip_ar_den->setValue(commonproperties.value("force_aspect_den").toInt());
557 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
558 m_view.clip_force_framerate->setChecked(true);
559 m_view.clip_framerate->setEnabled(true);
560 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
563 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
564 m_view.clip_force_progressive->setChecked(true);
565 m_view.clip_progressive->setEnabled(true);
566 m_view.clip_progressive->setValue(commonproperties.value("force_progressive").toInt());
569 if (commonproperties.contains("force_tff") && !commonproperties.value("force_tff").isEmpty()) {
570 m_view.clip_force_fieldorder->setChecked(true);
571 m_view.clip_fieldorder->setEnabled(true);
572 m_view.clip_fieldorder->setCurrentIndex(commonproperties.value("force_tff").toInt());
575 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
576 m_view.clip_force_threads->setChecked(true);
577 m_view.clip_threads->setEnabled(true);
578 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
581 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
582 m_view.clip_force_vindex->setChecked(true);
583 m_view.clip_vindex->setEnabled(true);
584 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
587 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
588 m_view.clip_force_aindex->setChecked(true);
589 m_view.clip_aindex->setEnabled(true);
590 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
593 if (props.contains("audio_max")) {
594 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
597 if (props.contains("video_max")) {
598 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
601 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
602 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
603 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
605 if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
606 m_view.clip_force_colorspace->setChecked(true);
607 m_view.clip_colorspace->setEnabled(true);
608 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
611 if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
612 m_view.clip_full_luma->setChecked(true);
615 if (commonproperties.contains("transparency")) {
616 // image transparency checkbox
617 int transparency = commonproperties.value("transparency").toInt();
618 if (transparency == 0) {
619 m_view.clip_force_transparency->setChecked(true);
621 else if (transparency == 1) {
622 m_view.clip_force_transparency->setChecked(true);
623 m_view.clip_transparency->setCurrentIndex(1);
627 m_view.clip_force_transparency->setHidden(true);
628 m_view.clip_transparency->setHidden(true);
632 connect(m_view.clip_force_transparency, SIGNAL(toggled(bool)), m_view.clip_transparency, SLOT(setEnabled(bool)));
633 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
634 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
635 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
636 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
637 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
638 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
639 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
640 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
642 m_view.tabWidget->removeTab(METATAB);
643 m_view.tabWidget->removeTab(MARKERTAB);
644 m_view.tabWidget->removeTab(IMAGETAB);
645 m_view.tabWidget->removeTab(SLIDETAB);
646 m_view.tabWidget->removeTab(COLORTAB);
647 m_view.tabWidget->removeTab(AUDIOTAB);
648 m_view.tabWidget->removeTab(VIDEOTAB);
650 m_view.clip_path->setHidden(true);
651 m_view.label_path->setHidden(true);
652 m_view.label_description->setHidden(true);
653 m_view.label_size->setHidden(true);
654 m_view.clip_filesize->setHidden(true);
655 m_view.clip_filesize->setHidden(true);
656 m_view.clip_path->setHidden(true);
657 m_view.clip_description->setHidden(true);
658 m_view.clip_thumb->setHidden(true);
659 m_view.label_duration->setHidden(true);
660 m_view.clip_duration->setHidden(true);
662 if (commonproperties.contains("out")) {
663 if (commonproperties.value("out").toInt() > 0) {
664 m_view.clip_force_out->setChecked(true);
665 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
666 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
668 m_view.clip_force_out->setHidden(true);
669 m_view.clip_out->setHidden(true);
673 ClipProperties::~ClipProperties()
675 QAbstractItemDelegate *del1 = m_view.clip_vproperties->itemDelegate();
676 if (del1) delete del1;
677 QAbstractItemDelegate *del2 = m_view.clip_aproperties->itemDelegate();
678 if (del2) delete del2;
681 void ClipProperties::slotGotThumbnail(const QString &id, QImage img)
683 if (id != m_clip->getId()) return;
684 QPixmap framedPix(img.width(), img.height());
685 framedPix.fill(Qt::transparent);
686 QPainter p(&framedPix);
687 p.setRenderHint(QPainter::Antialiasing, true);
689 path.addRoundedRect(0.5, 0.5, framedPix.width() - 1, framedPix.height() - 1, 4, 4);
691 p.drawImage(0, 0, img);
693 m_view.clip_thumb->setPixmap(framedPix);
696 void ClipProperties::slotApplyProperties()
698 if (m_clip != NULL) {
699 QMap <QString, QString> props = properties();
700 emit applyNewClipProperties(m_clip->getId(), m_clip->currentProperties(props), props, needsTimelineRefresh(), needsTimelineReload());
702 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
705 void ClipProperties::disableClipId(const QString &id)
707 if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
708 if (m_clip->getId() == id) {
709 // clip was removed from project, close this properties dialog
715 void ClipProperties::slotModified()
717 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
721 void ClipProperties::slotEnableLuma(int state)
724 if (state == Qt::Checked) enable = true;
725 m_view.luma_duration->setEnabled(enable);
726 m_view.luma_duration_frames->setEnabled(enable);
727 m_view.slide_luma->setEnabled(enable);
729 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
730 } else m_view.luma_file->setEnabled(false);
731 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
732 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
735 void ClipProperties::slotEnableLumaFile(int state)
738 if (state == Qt::Checked) enable = true;
739 m_view.luma_file->setEnabled(enable);
740 m_view.luma_softness->setEnabled(enable);
741 m_view.label_softness->setEnabled(enable);
744 void ClipProperties::slotUpdateAnalysisData(DocClipBase *clip)
746 if (m_clip != clip) return;
747 m_view.analysis_list->clear();
748 QMap <QString, QString> analysis = clip->analysisData();
749 m_view.analysis_box->setHidden(analysis.isEmpty());
750 QMap<QString, QString>::const_iterator i = analysis.constBegin();
751 while (i != analysis.constEnd()) {
752 QStringList itemtext;
753 itemtext << i.key() << i.value();
754 (void) new QTreeWidgetItem(m_view.analysis_list, itemtext);
759 void ClipProperties::slotFillMarkersList(DocClipBase *clip)
761 if (m_clip != clip) return;
762 m_view.markers_list->clear();
763 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
764 for (int count = 0; count < marks.count(); ++count) {
765 QString time = m_tc.getTimecode(marks[count].time());
766 QStringList itemtext;
767 itemtext << time << marks.at(count).comment();
768 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.markers_list, itemtext);
769 item->setData(0, Qt::DecorationRole, CommentedTime::markerColor(marks.at(count).markerType()));
773 void ClipProperties::slotAddMarker()
775 CommentedTime marker(GenTime(), i18n("Marker"));
776 QPointer<MarkerDialog> d = new MarkerDialog(m_clip, marker,
777 m_tc, i18n("Add Marker"), this);
778 if (d->exec() == QDialog::Accepted) {
779 QList <CommentedTime> markers;
780 markers << d->newMarker();
781 emit addMarkers(m_clip->getId(), markers);
786 void ClipProperties::slotSaveMarkers()
788 emit saveMarkers(m_clip->getId());
791 void ClipProperties::slotLoadMarkers()
793 emit loadMarkers(m_clip->getId());
796 void ClipProperties::slotEditMarker()
798 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
799 int pos = m_view.markers_list->currentIndex().row();
800 if (pos < 0 || pos > marks.count() - 1) return;
801 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
802 if (d.exec() == QDialog::Accepted) {
803 QList <CommentedTime> markers;
804 markers << d.newMarker();
805 emit addMarkers(m_clip->getId(), markers);
809 void ClipProperties::slotDeleteMarker()
811 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
812 QList < CommentedTime > toDelete;
813 for (int i = 0; i < marks.count(); i++) {
814 if (m_view.markers_list->topLevelItem(i)->isSelected()) {
815 CommentedTime marker = marks.at(i);
816 marker.setMarkerType(-1);
820 emit addMarkers(m_clip->getId(), toDelete);
823 void ClipProperties::slotDeleteAnalysis()
825 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
826 if (current) emit editAnalysis(m_clip->getId(), current->text(0), QString());
829 void ClipProperties::slotSaveAnalysis()
831 QString url = KFileDialog::getSaveFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Save Analysis Data"));
832 if (url.isEmpty()) return;
833 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
834 KConfigGroup analysisConfig(config, "Analysis");
835 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
836 analysisConfig.writeEntry(current->text(0), current->text(1));
839 void ClipProperties::slotLoadAnalysis()
841 QString url = KFileDialog::getOpenFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Open Analysis Data"));
842 if (url.isEmpty()) return;
843 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
844 KConfigGroup transConfig(config, "Analysis");
846 QMap< QString, QString > profiles = transConfig.entryMap();
847 QMapIterator<QString, QString> i(profiles);
848 while (i.hasNext()) {
850 emit editAnalysis(m_clip->getId(), i.key(), i.value());
854 const QString &ClipProperties::clipId() const
856 return m_clip->getId();
860 QMap <QString, QString> ClipProperties::properties()
862 QMap <QString, QString> props;
864 CLIPTYPE t = UNKNOWN;
865 if (m_clip != NULL) {
866 t = m_clip->clipType();
867 m_old_props = m_clip->properties();
870 int aspectNumerator = m_view.clip_ar_num->value();
871 int aspectDenominator = m_view.clip_ar_den->value();
872 if (m_view.clip_force_ar->isChecked()) {
873 if (aspectNumerator != m_old_props.value("force_aspect_num").toInt() ||
874 aspectDenominator != m_old_props.value("force_aspect_den").toInt()) {
875 props["force_aspect_num"] = QString::number(aspectNumerator);
876 props["force_aspect_den"] = QString::number(aspectDenominator);
877 props["force_aspect_ratio"].clear();
878 m_clipNeedsRefresh = true;
881 if (m_old_props.contains("force_aspect_num") && !m_old_props.value("force_aspect_num").isEmpty()) {
882 props["force_aspect_num"].clear();
883 m_clipNeedsRefresh = true;
885 if (m_old_props.contains("force_aspect_den") && !m_old_props.value("force_aspect_den").isEmpty()) {
886 props["force_aspect_den"].clear();
887 m_clipNeedsRefresh = true;
891 double fps = m_view.clip_framerate->value();
892 if (m_view.clip_force_framerate->isChecked()) {
893 if (fps != m_old_props.value("force_fps").toDouble()) {
894 props["force_fps"] = locale.toString(fps);
895 m_clipNeedsRefresh = true;
897 } else if (m_old_props.contains("force_fps") && !m_old_props.value("force_fps").isEmpty()) {
898 props["force_fps"].clear();
899 m_clipNeedsRefresh = true;
902 int progressive = m_view.clip_progressive->value();
903 if (m_view.clip_force_progressive->isChecked()) {
904 if (progressive != m_old_props.value("force_progressive").toInt()) {
905 props["force_progressive"] = QString::number(progressive);
907 } else if (m_old_props.contains("force_progressive") && !m_old_props.value("force_progressive").isEmpty()) {
908 props["force_progressive"].clear();
911 int fieldOrder = m_view.clip_fieldorder->currentIndex();
912 if (m_view.clip_force_fieldorder->isChecked()) {
913 if (fieldOrder != m_old_props.value("force_tff").toInt()) {
914 props["force_tff"] = QString::number(fieldOrder);
916 } else if (m_old_props.contains("force_tff") && !m_old_props.value("force_tff").isEmpty()) {
917 props["force_tff"].clear();
920 int threads = m_view.clip_threads->value();
921 if (m_view.clip_force_threads->isChecked()) {
922 if (threads != m_old_props.value("threads").toInt()) {
923 props["threads"] = QString::number(threads);
925 } else if (m_old_props.contains("threads") && !m_old_props.value("threads").isEmpty()) {
926 props["threads"].clear();
929 int vindex = m_view.clip_vindex->value();
930 if (m_view.clip_force_vindex->isChecked()) {
931 if (vindex != m_old_props.value("video_index").toInt()) {
932 props["video_index"] = QString::number(vindex);
934 } else if (m_old_props.contains("video_index") && !m_old_props.value("video_index").isEmpty()) {
935 props["video_index"].clear();
938 int aindex = m_view.clip_aindex->value();
939 if (m_view.clip_force_aindex->isChecked()) {
940 if (aindex != m_old_props.value("audio_index").toInt()) {
941 props["audio_index"] = QString::number(aindex);
943 } else if (m_old_props.contains("audio_index") && !m_old_props.value("audio_index").isEmpty()) {
944 props["audio_index"].clear();
947 int colorspace = m_view.clip_colorspace->itemData(m_view.clip_colorspace->currentIndex()).toInt();
948 if (m_view.clip_force_colorspace->isChecked()) {
949 if (colorspace != m_old_props.value("force_colorspace").toInt()) {
950 props["force_colorspace"] = QString::number(colorspace);
951 m_clipNeedsRefresh = true;
953 } else if (m_old_props.contains("force_colorspace") && !m_old_props.value("force_colorspace").isEmpty()) {
954 props["force_colorspace"].clear();
955 m_clipNeedsRefresh = true;
958 if (m_view.clip_full_luma->isChecked()) {
959 props["full_luma"] = QString::number(1);
960 m_clipNeedsRefresh = true;
961 } else if (m_old_props.contains("full_luma") && !m_old_props.value("full_luma").isEmpty()) {
962 props["full_luma"].clear();
963 m_clipNeedsRefresh = true;
966 if (m_view.clip_force_transparency->isChecked()) {
967 QString transp = QString::number(m_view.clip_transparency->currentIndex());
968 if (transp != m_old_props.value("transparency")) props["transparency"] = transp;
971 // If we adjust several clips, return now
972 if (m_clip == NULL) {
973 if (m_view.clip_out->isEnabled()) {
974 int duration = m_tc.getFrameCount(m_view.clip_out->text());
975 if (duration != m_old_props.value("out").toInt()) {
976 props["out"] = QString::number(duration - 1);
982 if (m_old_props.value("description") != m_view.clip_description->text())
983 props["description"] = m_view.clip_description->text();
986 QString new_color = m_view.clip_color->color().name();
987 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
988 m_clipNeedsRefresh = true;
989 props["colour"] = "0x" + new_color.right(6) + "ff";
991 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
992 if (duration != m_clip->duration().frames(m_fps)) {
993 props["out"] = QString::number(duration - 1);
995 } else if (t == IMAGE) {
996 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
997 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
998 //m_clipNeedsRefresh = true;
1000 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1001 if (duration != m_clip->duration().frames(m_fps)) {
1002 props["out"] = QString::number(duration - 1);
1004 } else if (t == SLIDESHOW) {
1005 QString value = QString::number((int) m_view.slide_loop->isChecked());
1006 if (m_old_props.value("loop") != value) props["loop"] = value;
1007 value = QString::number((int) m_view.slide_crop->isChecked());
1008 if (m_old_props.value("crop") != value) props["crop"] = value;
1009 value = QString::number((int) m_view.slide_fade->isChecked());
1010 if (m_old_props.value("fade") != value) props["fade"] = value;
1011 value = QString::number((int) m_view.luma_softness->value());
1012 if (m_old_props.value("softness") != value) props["softness"] = value;
1014 bool isMime = !(m_view.clip_path->text().contains('%'));
1016 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1017 QString new_path = m_view.clip_path->text() + extension;
1018 if (new_path != m_old_props.value("resource")) {
1019 m_clipNeedsReLoad = true;
1020 props["resource"] = new_path;
1021 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
1025 if (m_view.slide_duration_format->currentIndex() == 1) {
1026 // we are in frames mode
1027 duration = m_view.slide_duration_frames->value();
1028 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
1029 if (duration != m_old_props.value("ttl").toInt()) {
1030 m_clipNeedsRefresh = true;
1031 props["ttl"] = QString::number(duration);
1032 props["length"] = QString::number(duration * m_count);
1035 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
1036 m_clipNeedsRefresh = true;
1037 props["out"] = QString::number(duration * m_count - 1);
1039 if (m_view.slide_fade->isChecked()) {
1041 if (m_view.slide_duration_format->currentIndex() == 1) {
1042 // we are in frames mode
1043 luma_duration = m_view.luma_duration_frames->value();
1044 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
1045 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
1046 m_clipNeedsRefresh = true;
1047 props["luma_duration"] = QString::number(luma_duration);
1050 if (m_view.slide_luma->isChecked())
1051 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
1052 if (lumaFile != m_old_props.value("luma_file")) {
1053 m_clipNeedsRefresh = true;
1054 props["luma_file"] = lumaFile;
1057 if (!m_old_props.value("luma_file").isEmpty()) {
1058 props["luma_file"].clear();
1062 QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
1063 if (animation != m_old_props.value("animation")) {
1064 if (animation.isEmpty()) {
1065 props["animation"].clear();
1067 props["animation"] = animation;
1069 m_clipNeedsRefresh = true;
1075 bool ClipProperties::needsTimelineRefresh() const
1077 return m_clipNeedsRefresh;
1080 bool ClipProperties::needsTimelineReload() const
1082 return m_clipNeedsReLoad;
1086 void ClipProperties::parseFolder(bool reloadThumb)
1088 QString path = m_view.clip_path->text();
1089 bool isMime = !(path.contains('%'));
1090 if (!isMime) path = KUrl(path).directory();
1093 QStringList filters;
1097 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
1098 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1099 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1100 dir.setNameFilters(filters);
1103 QStringList result = dir.entryList(QDir::Files);
1107 QString path = m_view.clip_path->text();
1108 if (path.contains('?')) {
1110 offset = m_view.clip_path->text().section(':', -1).toInt();
1111 path = path.section('?', 0, 0);
1113 QString filter = KUrl(path).fileName();
1114 QString ext = filter.section('.', -1);
1115 filter = filter.section('%', 0, -2);
1116 QString regexp = '^' + filter + "\\d+\\." + ext + '$';
1118 QStringList entries;
1120 foreach(const QString & path, result) {
1121 if (rx.exactMatch(path)) {
1123 // make sure our image is in the range we want (> begin)
1124 ix = path.section(filter, 1).section('.', 0, 0).toInt();
1125 if (ix < offset) continue;
1133 m_count = result.count();
1134 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(m_count > 0);
1136 // no images, do not accept that
1137 m_view.slide_info->setText(i18n("No image found"));
1138 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
1141 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
1142 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
1143 QMap <QString, QString> props = m_clip->properties();
1144 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
1146 int width = 180.0 * KdenliveSettings::project_display_ratio();
1147 if (width % 2 == 1) width++;
1148 QString filePath = m_view.clip_path->text();
1149 if (isMime) filePath.append(extension);
1150 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
1151 m_view.clip_thumb->setPixmap(pix);
1155 void ClipProperties::slotCheckMaxLength()
1157 if (m_clip->maxDuration() == GenTime()) return;
1158 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1159 if (duration > m_clip->maxDuration().frames(m_fps)) {
1160 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
1164 void ClipProperties::slotUpdateDurationFormat(int ix)
1166 bool framesFormat = ix == 1;
1168 // switching to frames count, update widget
1169 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
1170 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
1171 m_view.slide_duration->setHidden(true);
1172 m_view.luma_duration->setHidden(true);
1173 m_view.slide_duration_frames->setHidden(false);
1174 m_view.luma_duration_frames->setHidden(false);
1176 // switching to timecode format
1177 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
1178 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
1179 m_view.slide_duration_frames->setHidden(true);
1180 m_view.luma_duration_frames->setHidden(true);
1181 m_view.slide_duration->setHidden(false);
1182 m_view.luma_duration->setHidden(false);
1186 void ClipProperties::slotDeleteProxy()
1188 QString proxy = m_clip->getProperty("proxy");
1189 if (proxy.isEmpty()) return;
1190 emit deleteProxy(proxy);
1191 if (m_proxyContainer) delete m_proxyContainer;
1194 void ClipProperties::slotOpenUrl(const QString &url)
1196 new KRun(KUrl(url), this);
1199 #include "clipproperties.moc"