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"));
416 if (props.contains("frame_size"))
417 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
419 if (props.contains("fps")) {
420 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
421 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
424 if (props.contains("progressive")) {
425 int scanning = props.value("progressive").toInt();
426 QString txt = scanning == 1 ? i18n("Progressive") : i18n("Interlaced");
427 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Scanning") << txt);
430 if (props.contains("aspect_ratio"))
431 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
433 if (props.contains("pix_fmt"))
434 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
436 if (props.contains("colorspace"))
437 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
439 m_view.clip_thumb->setMinimumSize(180 * KdenliveSettings::project_display_ratio(), 180);
441 if (t == IMAGE || t == VIDEO || t == PLAYLIST) m_view.tabWidget->removeTab(AUDIOTAB);
443 m_view.tabWidget->removeTab(IMAGETAB);
444 m_view.tabWidget->removeTab(SLIDETAB);
445 m_view.tabWidget->removeTab(COLORTAB);
446 m_view.tabWidget->removeTab(VIDEOTAB);
447 m_view.clip_thumb->setHidden(true);
450 if (t != SLIDESHOW && t != COLOR) {
451 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
452 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
454 m_view.clip_filesize->setHidden(true);
455 m_view.label_size->setHidden(true);
457 m_view.clip_duration->setInputMask(tc.mask());
458 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
459 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
461 connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
462 connect(m_view.clip_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
466 m_view.marker_new->setIcon(KIcon("document-new"));
467 m_view.marker_new->setToolTip(i18n("Add marker"));
468 m_view.marker_edit->setIcon(KIcon("document-properties"));
469 m_view.marker_edit->setToolTip(i18n("Edit marker"));
470 m_view.marker_delete->setIcon(KIcon("trash-empty"));
471 m_view.marker_delete->setToolTip(i18n("Delete marker"));
472 m_view.marker_save->setIcon(KIcon("document-save-as"));
473 m_view.marker_save->setToolTip(i18n("Save markers"));
474 m_view.marker_load->setIcon(KIcon("document-open"));
475 m_view.marker_load->setToolTip(i18n("Load markers"));
476 m_view.analysis_delete->setIcon(KIcon("trash-empty"));
477 m_view.analysis_delete->setToolTip(i18n("Delete analysis data"));
478 m_view.analysis_load->setIcon(KIcon("document-open"));
479 m_view.analysis_load->setToolTip(i18n("Load analysis data"));
480 m_view.analysis_save->setIcon(KIcon("document-save-as"));
481 m_view.analysis_save->setToolTip(i18n("Save analysis data"));
483 // Check for Nepomuk metadata
485 #if KDE_IS_VERSION(4,6,0)
486 if (!url.isEmpty()) {
487 Nepomuk::ResourceManager::instance()->init();
488 Nepomuk::Resource res( url.path() );
489 // Check if file has a license
490 if (res.hasProperty(Nepomuk::Vocabulary::NIE::license())) {
491 QString ltype = res.property(Nepomuk::Vocabulary::NIE::licenseType()).toString();
492 m_view.clip_license->setText(i18n("License: %1", res.property(Nepomuk::Vocabulary::NIE::license()).toString()));
493 if (ltype.startsWith("http")) {
494 m_view.clip_license->setUrl(ltype);
495 connect(m_view.clip_license, SIGNAL(leftClickedUrl(const QString &)), this, SLOT(slotOpenUrl(const QString &)));
498 else m_view.clip_license->setHidden(true);
500 else m_view.clip_license->setHidden(true);
502 m_view.clip_license->setHidden(true);
505 m_view.clip_license->setHidden(true);
508 slotFillMarkersList(m_clip);
509 slotUpdateAnalysisData(m_clip);
511 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
512 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
513 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
514 connect(m_view.marker_save, SIGNAL(clicked()), this, SLOT(slotSaveMarkers()));
515 connect(m_view.marker_load, SIGNAL(clicked()), this, SLOT(slotLoadMarkers()));
516 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
518 connect(m_view.analysis_delete, SIGNAL(clicked()), this, SLOT(slotDeleteAnalysis()));
519 connect(m_view.analysis_save, SIGNAL(clicked()), this, SLOT(slotSaveAnalysis()));
520 connect(m_view.analysis_load, SIGNAL(clicked()), this, SLOT(slotLoadAnalysis()));
522 connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
523 connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
524 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
529 // Used for multiple clips editing
530 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
536 m_clipNeedsRefresh(false),
537 m_clipNeedsReLoad(false)
539 setFont(KGlobalSettings::toolBarFont());
540 m_view.setupUi(this);
541 QString title = windowTitle();
542 title.append(' ' + i18np("(%1 clip)", "(%1 clips)", cliplist.count()));
543 setWindowTitle(title);
544 QMap <QString, QString> props = cliplist.at(0)->properties();
545 m_old_props = commonproperties;
547 if (commonproperties.contains("force_aspect_num") && !commonproperties.value("force_aspect_num").isEmpty() && commonproperties.value("force_aspect_den").toInt() > 0) {
548 m_view.clip_force_ar->setChecked(true);
549 m_view.clip_ar_num->setEnabled(true);
550 m_view.clip_ar_den->setEnabled(true);
551 m_view.clip_ar_num->setValue(commonproperties.value("force_aspect_num").toInt());
552 m_view.clip_ar_den->setValue(commonproperties.value("force_aspect_den").toInt());
555 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
556 m_view.clip_force_framerate->setChecked(true);
557 m_view.clip_framerate->setEnabled(true);
558 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
561 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
562 m_view.clip_force_progressive->setChecked(true);
563 m_view.clip_progressive->setEnabled(true);
564 m_view.clip_progressive->setValue(commonproperties.value("force_progressive").toInt());
567 if (commonproperties.contains("force_tff") && !commonproperties.value("force_tff").isEmpty()) {
568 m_view.clip_force_fieldorder->setChecked(true);
569 m_view.clip_fieldorder->setEnabled(true);
570 m_view.clip_fieldorder->setCurrentIndex(commonproperties.value("force_tff").toInt());
573 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
574 m_view.clip_force_threads->setChecked(true);
575 m_view.clip_threads->setEnabled(true);
576 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
579 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
580 m_view.clip_force_vindex->setChecked(true);
581 m_view.clip_vindex->setEnabled(true);
582 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
585 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
586 m_view.clip_force_aindex->setChecked(true);
587 m_view.clip_aindex->setEnabled(true);
588 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
591 if (props.contains("audio_max")) {
592 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
595 if (props.contains("video_max")) {
596 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
599 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
600 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
601 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
603 if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
604 m_view.clip_force_colorspace->setChecked(true);
605 m_view.clip_colorspace->setEnabled(true);
606 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
609 if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
610 m_view.clip_full_luma->setChecked(true);
613 if (commonproperties.contains("transparency")) {
614 // image transparency checkbox
615 int transparency = commonproperties.value("transparency").toInt();
616 if (transparency == 0) {
617 m_view.clip_force_transparency->setChecked(true);
619 else if (transparency == 1) {
620 m_view.clip_force_transparency->setChecked(true);
621 m_view.clip_transparency->setCurrentIndex(1);
625 m_view.clip_force_transparency->setHidden(true);
626 m_view.clip_transparency->setHidden(true);
630 connect(m_view.clip_force_transparency, SIGNAL(toggled(bool)), m_view.clip_transparency, SLOT(setEnabled(bool)));
631 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
632 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
633 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
634 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
635 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
636 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
637 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
638 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
640 m_view.tabWidget->removeTab(METATAB);
641 m_view.tabWidget->removeTab(MARKERTAB);
642 m_view.tabWidget->removeTab(IMAGETAB);
643 m_view.tabWidget->removeTab(SLIDETAB);
644 m_view.tabWidget->removeTab(COLORTAB);
645 m_view.tabWidget->removeTab(AUDIOTAB);
646 m_view.tabWidget->removeTab(VIDEOTAB);
648 m_view.clip_path->setHidden(true);
649 m_view.label_path->setHidden(true);
650 m_view.label_description->setHidden(true);
651 m_view.label_size->setHidden(true);
652 m_view.clip_filesize->setHidden(true);
653 m_view.clip_filesize->setHidden(true);
654 m_view.clip_path->setHidden(true);
655 m_view.clip_description->setHidden(true);
656 m_view.clip_thumb->setHidden(true);
657 m_view.label_duration->setHidden(true);
658 m_view.clip_duration->setHidden(true);
660 if (commonproperties.contains("out")) {
661 if (commonproperties.value("out").toInt() > 0) {
662 m_view.clip_force_out->setChecked(true);
663 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
664 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
666 m_view.clip_force_out->setHidden(true);
667 m_view.clip_out->setHidden(true);
671 ClipProperties::~ClipProperties()
673 QAbstractItemDelegate *del1 = m_view.clip_vproperties->itemDelegate();
674 if (del1) delete del1;
675 QAbstractItemDelegate *del2 = m_view.clip_aproperties->itemDelegate();
676 if (del2) delete del2;
679 void ClipProperties::slotGotThumbnail(const QString &id, QImage img)
681 if (id != m_clip->getId()) return;
682 QPixmap framedPix(img.width(), img.height());
683 framedPix.fill(Qt::transparent);
684 QPainter p(&framedPix);
685 p.setRenderHint(QPainter::Antialiasing, true);
687 path.addRoundedRect(0.5, 0.5, framedPix.width() - 1, framedPix.height() - 1, 4, 4);
689 p.drawImage(0, 0, img);
691 m_view.clip_thumb->setPixmap(framedPix);
694 void ClipProperties::slotApplyProperties()
696 if (m_clip != NULL) {
697 QMap <QString, QString> props = properties();
698 emit applyNewClipProperties(m_clip->getId(), m_clip->currentProperties(props), props, needsTimelineRefresh(), needsTimelineReload());
700 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
703 void ClipProperties::disableClipId(const QString &id)
705 if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
706 if (m_clip->getId() == id) {
707 // clip was removed from project, close this properties dialog
713 void ClipProperties::slotModified()
715 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
719 void ClipProperties::slotEnableLuma(int state)
722 if (state == Qt::Checked) enable = true;
723 m_view.luma_duration->setEnabled(enable);
724 m_view.luma_duration_frames->setEnabled(enable);
725 m_view.slide_luma->setEnabled(enable);
727 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
728 } else m_view.luma_file->setEnabled(false);
729 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
730 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
733 void ClipProperties::slotEnableLumaFile(int state)
736 if (state == Qt::Checked) enable = true;
737 m_view.luma_file->setEnabled(enable);
738 m_view.luma_softness->setEnabled(enable);
739 m_view.label_softness->setEnabled(enable);
742 void ClipProperties::slotUpdateAnalysisData(DocClipBase *clip)
744 if (m_clip != clip) return;
745 m_view.analysis_list->clear();
746 QMap <QString, QString> analysis = clip->analysisData();
747 m_view.analysis_box->setHidden(analysis.isEmpty());
748 QMap<QString, QString>::const_iterator i = analysis.constBegin();
749 while (i != analysis.constEnd()) {
750 QStringList itemtext;
751 itemtext << i.key() << i.value();
752 (void) new QTreeWidgetItem(m_view.analysis_list, itemtext);
757 void ClipProperties::slotFillMarkersList(DocClipBase *clip)
759 if (m_clip != clip) return;
760 m_view.markers_list->clear();
761 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
762 for (int count = 0; count < marks.count(); ++count) {
763 QString time = m_tc.getTimecode(marks[count].time());
764 QStringList itemtext;
765 itemtext << time << marks.at(count).comment();
766 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.markers_list, itemtext);
767 item->setData(0, Qt::DecorationRole, CommentedTime::markerColor(marks.at(count).markerType()));
771 void ClipProperties::slotAddMarker()
773 CommentedTime marker(GenTime(), i18n("Marker"));
774 QPointer<MarkerDialog> d = new MarkerDialog(m_clip, marker,
775 m_tc, i18n("Add Marker"), this);
776 if (d->exec() == QDialog::Accepted) {
777 QList <CommentedTime> markers;
778 markers << d->newMarker();
779 emit addMarkers(m_clip->getId(), markers);
784 void ClipProperties::slotSaveMarkers()
786 emit saveMarkers(m_clip->getId());
789 void ClipProperties::slotLoadMarkers()
791 emit loadMarkers(m_clip->getId());
794 void ClipProperties::slotEditMarker()
796 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
797 int pos = m_view.markers_list->currentIndex().row();
798 if (pos < 0 || pos > marks.count() - 1) return;
799 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
800 if (d.exec() == QDialog::Accepted) {
801 QList <CommentedTime> markers;
802 markers << d.newMarker();
803 emit addMarkers(m_clip->getId(), markers);
807 void ClipProperties::slotDeleteMarker()
809 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
810 QList < CommentedTime > toDelete;
811 for (int i = 0; i < marks.count(); i++) {
812 if (m_view.markers_list->topLevelItem(i)->isSelected()) {
813 CommentedTime marker = marks.at(i);
814 marker.setMarkerType(-1);
818 emit addMarkers(m_clip->getId(), toDelete);
821 void ClipProperties::slotDeleteAnalysis()
823 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
824 if (current) emit editAnalysis(m_clip->getId(), current->text(0), QString());
827 void ClipProperties::slotSaveAnalysis()
829 QString url = KFileDialog::getSaveFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Save Analysis Data"));
830 if (url.isEmpty()) return;
831 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
832 KConfigGroup analysisConfig(config, "Analysis");
833 QTreeWidgetItem *current = m_view.analysis_list->currentItem();
834 analysisConfig.writeEntry(current->text(0), current->text(1));
837 void ClipProperties::slotLoadAnalysis()
839 QString url = KFileDialog::getOpenFileName(KUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Open Analysis Data"));
840 if (url.isEmpty()) return;
841 KSharedConfigPtr config = KSharedConfig::openConfig(url, KConfig::SimpleConfig);
842 KConfigGroup transConfig(config, "Analysis");
844 QMap< QString, QString > profiles = transConfig.entryMap();
845 QMapIterator<QString, QString> i(profiles);
846 while (i.hasNext()) {
848 emit editAnalysis(m_clip->getId(), i.key(), i.value());
852 const QString &ClipProperties::clipId() const
854 return m_clip->getId();
858 QMap <QString, QString> ClipProperties::properties()
860 QMap <QString, QString> props;
862 CLIPTYPE t = UNKNOWN;
863 if (m_clip != NULL) {
864 t = m_clip->clipType();
865 m_old_props = m_clip->properties();
868 int aspectNumerator = m_view.clip_ar_num->value();
869 int aspectDenominator = m_view.clip_ar_den->value();
870 if (m_view.clip_force_ar->isChecked()) {
871 if (aspectNumerator != m_old_props.value("force_aspect_num").toInt() ||
872 aspectDenominator != m_old_props.value("force_aspect_den").toInt()) {
873 props["force_aspect_num"] = QString::number(aspectNumerator);
874 props["force_aspect_den"] = QString::number(aspectDenominator);
875 props["force_aspect_ratio"].clear();
876 m_clipNeedsRefresh = true;
879 if (m_old_props.contains("force_aspect_num") && !m_old_props.value("force_aspect_num").isEmpty()) {
880 props["force_aspect_num"].clear();
881 m_clipNeedsRefresh = true;
883 if (m_old_props.contains("force_aspect_den") && !m_old_props.value("force_aspect_den").isEmpty()) {
884 props["force_aspect_den"].clear();
885 m_clipNeedsRefresh = true;
889 double fps = m_view.clip_framerate->value();
890 if (m_view.clip_force_framerate->isChecked()) {
891 if (fps != m_old_props.value("force_fps").toDouble()) {
892 props["force_fps"] = locale.toString(fps);
893 m_clipNeedsRefresh = true;
895 } else if (m_old_props.contains("force_fps") && !m_old_props.value("force_fps").isEmpty()) {
896 props["force_fps"].clear();
897 m_clipNeedsRefresh = true;
900 int progressive = m_view.clip_progressive->value();
901 if (m_view.clip_force_progressive->isChecked()) {
902 if (progressive != m_old_props.value("force_progressive").toInt()) {
903 props["force_progressive"] = QString::number(progressive);
905 } else if (m_old_props.contains("force_progressive") && !m_old_props.value("force_progressive").isEmpty()) {
906 props["force_progressive"].clear();
909 int fieldOrder = m_view.clip_fieldorder->currentIndex();
910 if (m_view.clip_force_fieldorder->isChecked()) {
911 if (fieldOrder != m_old_props.value("force_tff").toInt()) {
912 props["force_tff"] = QString::number(fieldOrder);
914 } else if (m_old_props.contains("force_tff") && !m_old_props.value("force_tff").isEmpty()) {
915 props["force_tff"].clear();
918 int threads = m_view.clip_threads->value();
919 if (m_view.clip_force_threads->isChecked()) {
920 if (threads != m_old_props.value("threads").toInt()) {
921 props["threads"] = QString::number(threads);
923 } else if (m_old_props.contains("threads") && !m_old_props.value("threads").isEmpty()) {
924 props["threads"].clear();
927 int vindex = m_view.clip_vindex->value();
928 if (m_view.clip_force_vindex->isChecked()) {
929 if (vindex != m_old_props.value("video_index").toInt()) {
930 props["video_index"] = QString::number(vindex);
932 } else if (m_old_props.contains("video_index") && !m_old_props.value("video_index").isEmpty()) {
933 props["video_index"].clear();
936 int aindex = m_view.clip_aindex->value();
937 if (m_view.clip_force_aindex->isChecked()) {
938 if (aindex != m_old_props.value("audio_index").toInt()) {
939 props["audio_index"] = QString::number(aindex);
941 } else if (m_old_props.contains("audio_index") && !m_old_props.value("audio_index").isEmpty()) {
942 props["audio_index"].clear();
945 int colorspace = m_view.clip_colorspace->itemData(m_view.clip_colorspace->currentIndex()).toInt();
946 if (m_view.clip_force_colorspace->isChecked()) {
947 if (colorspace != m_old_props.value("force_colorspace").toInt()) {
948 props["force_colorspace"] = QString::number(colorspace);
949 m_clipNeedsRefresh = true;
951 } else if (m_old_props.contains("force_colorspace") && !m_old_props.value("force_colorspace").isEmpty()) {
952 props["force_colorspace"].clear();
953 m_clipNeedsRefresh = true;
956 if (m_view.clip_full_luma->isChecked()) {
957 props["full_luma"] = QString::number(1);
958 m_clipNeedsRefresh = true;
959 } else if (m_old_props.contains("full_luma") && !m_old_props.value("full_luma").isEmpty()) {
960 props["full_luma"].clear();
961 m_clipNeedsRefresh = true;
964 if (m_view.clip_force_transparency->isChecked()) {
965 QString transp = QString::number(m_view.clip_transparency->currentIndex());
966 if (transp != m_old_props.value("transparency")) props["transparency"] = transp;
969 // If we adjust several clips, return now
970 if (m_clip == NULL) {
971 if (m_view.clip_out->isEnabled()) {
972 int duration = m_tc.getFrameCount(m_view.clip_out->text());
973 if (duration != m_old_props.value("out").toInt()) {
974 props["out"] = QString::number(duration - 1);
980 if (m_old_props.value("description") != m_view.clip_description->text())
981 props["description"] = m_view.clip_description->text();
984 QString new_color = m_view.clip_color->color().name();
985 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
986 m_clipNeedsRefresh = true;
987 props["colour"] = "0x" + new_color.right(6) + "ff";
989 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
990 if (duration != m_clip->duration().frames(m_fps)) {
991 props["out"] = QString::number(duration - 1);
993 } else if (t == IMAGE) {
994 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
995 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
996 //m_clipNeedsRefresh = true;
998 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
999 if (duration != m_clip->duration().frames(m_fps)) {
1000 props["out"] = QString::number(duration - 1);
1002 } else if (t == SLIDESHOW) {
1003 QString value = QString::number((int) m_view.slide_loop->isChecked());
1004 if (m_old_props.value("loop") != value) props["loop"] = value;
1005 value = QString::number((int) m_view.slide_crop->isChecked());
1006 if (m_old_props.value("crop") != value) props["crop"] = value;
1007 value = QString::number((int) m_view.slide_fade->isChecked());
1008 if (m_old_props.value("fade") != value) props["fade"] = value;
1009 value = QString::number((int) m_view.luma_softness->value());
1010 if (m_old_props.value("softness") != value) props["softness"] = value;
1012 bool isMime = !(m_view.clip_path->text().contains('%'));
1014 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1015 QString new_path = m_view.clip_path->text() + extension;
1016 if (new_path != m_old_props.value("resource")) {
1017 m_clipNeedsReLoad = true;
1018 props["resource"] = new_path;
1019 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
1023 if (m_view.slide_duration_format->currentIndex() == 1) {
1024 // we are in frames mode
1025 duration = m_view.slide_duration_frames->value();
1026 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
1027 if (duration != m_old_props.value("ttl").toInt()) {
1028 m_clipNeedsRefresh = true;
1029 props["ttl"] = QString::number(duration);
1030 props["length"] = QString::number(duration * m_count);
1033 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
1034 m_clipNeedsRefresh = true;
1035 props["out"] = QString::number(duration * m_count - 1);
1037 if (m_view.slide_fade->isChecked()) {
1039 if (m_view.slide_duration_format->currentIndex() == 1) {
1040 // we are in frames mode
1041 luma_duration = m_view.luma_duration_frames->value();
1042 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
1043 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
1044 m_clipNeedsRefresh = true;
1045 props["luma_duration"] = QString::number(luma_duration);
1048 if (m_view.slide_luma->isChecked())
1049 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
1050 if (lumaFile != m_old_props.value("luma_file")) {
1051 m_clipNeedsRefresh = true;
1052 props["luma_file"] = lumaFile;
1055 if (!m_old_props.value("luma_file").isEmpty()) {
1056 props["luma_file"].clear();
1060 QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
1061 if (animation != m_old_props.value("animation")) {
1062 if (animation.isEmpty()) {
1063 props["animation"].clear();
1065 props["animation"] = animation;
1067 m_clipNeedsRefresh = true;
1073 bool ClipProperties::needsTimelineRefresh() const
1075 return m_clipNeedsRefresh;
1078 bool ClipProperties::needsTimelineReload() const
1080 return m_clipNeedsReLoad;
1084 void ClipProperties::parseFolder(bool reloadThumb)
1086 QString path = m_view.clip_path->text();
1087 bool isMime = !(path.contains('%'));
1088 if (!isMime) path = KUrl(path).directory();
1091 QStringList filters;
1095 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
1096 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1097 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
1098 dir.setNameFilters(filters);
1101 QStringList result = dir.entryList(QDir::Files);
1105 QString path = m_view.clip_path->text();
1106 if (path.contains('?')) {
1108 offset = m_view.clip_path->text().section(':', -1).toInt();
1109 path = path.section('?', 0, 0);
1111 QString filter = KUrl(path).fileName();
1112 QString ext = filter.section('.', -1);
1113 filter = filter.section('%', 0, -2);
1114 QString regexp = '^' + filter + "\\d+\\." + ext + '$';
1116 QStringList entries;
1118 foreach(const QString & path, result) {
1119 if (rx.exactMatch(path)) {
1121 // make sure our image is in the range we want (> begin)
1122 ix = path.section(filter, 1).section('.', 0, 0).toInt();
1123 if (ix < offset) continue;
1131 m_count = result.count();
1132 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(m_count > 0);
1134 // no images, do not accept that
1135 m_view.slide_info->setText(i18n("No image found"));
1136 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
1139 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
1140 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
1141 QMap <QString, QString> props = m_clip->properties();
1142 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
1144 int width = 180.0 * KdenliveSettings::project_display_ratio();
1145 if (width % 2 == 1) width++;
1146 QString filePath = m_view.clip_path->text();
1147 if (isMime) filePath.append(extension);
1148 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
1149 m_view.clip_thumb->setPixmap(pix);
1153 void ClipProperties::slotCheckMaxLength()
1155 if (m_clip->maxDuration() == GenTime()) return;
1156 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
1157 if (duration > m_clip->maxDuration().frames(m_fps)) {
1158 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
1162 void ClipProperties::slotUpdateDurationFormat(int ix)
1164 bool framesFormat = ix == 1;
1166 // switching to frames count, update widget
1167 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
1168 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
1169 m_view.slide_duration->setHidden(true);
1170 m_view.luma_duration->setHidden(true);
1171 m_view.slide_duration_frames->setHidden(false);
1172 m_view.luma_duration_frames->setHidden(false);
1174 // switching to timecode format
1175 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
1176 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
1177 m_view.slide_duration_frames->setHidden(true);
1178 m_view.luma_duration_frames->setHidden(true);
1179 m_view.slide_duration->setHidden(false);
1180 m_view.luma_duration->setHidden(false);
1184 void ClipProperties::slotDeleteProxy()
1186 QString proxy = m_clip->getProperty("proxy");
1187 if (proxy.isEmpty()) return;
1188 emit deleteProxy(proxy);
1189 if (m_proxyContainer) delete m_proxyContainer;
1192 void ClipProperties::slotOpenUrl(const QString &url)
1194 new KRun(KUrl(url), this);
1197 #include "clipproperties.moc"