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>
33 static const int VIDEOTAB = 0;
34 static const int AUDIOTAB = 1;
35 static const int COLORTAB = 2;
36 static const int SLIDETAB = 3;
37 static const int IMAGETAB = 4;
38 static const int MARKERTAB = 5;
39 static const int METATAB = 6;
40 static const int ADVANCEDTAB = 7;
43 ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidget * parent) :
49 m_clipNeedsRefresh(false),
50 m_clipNeedsReLoad(false),
53 setAttribute(Qt::WA_DeleteOnClose, true);
54 setFont(KGlobalSettings::toolBarFont());
56 KUrl url = m_clip->fileURL();
57 m_view.clip_path->setText(url.path());
58 m_view.clip_description->setText(m_clip->description());
59 connect(m_view.clip_description, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
61 QMap <QString, QString> props = m_clip->properties();
62 m_view.clip_force_out->setHidden(true);
63 m_view.clip_out->setHidden(true);
65 if (props.contains("force_aspect_ratio") && props.value("force_aspect_ratio").toDouble() > 0) {
66 m_view.clip_force_ar->setChecked(true);
67 m_view.clip_ar->setEnabled(true);
68 m_view.clip_ar->setValue(props.value("force_aspect_ratio").toDouble());
69 } else if (props.contains("aspect_ratio")) m_view.clip_ar->setValue(props.value("aspect_ratio").toDouble());
70 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
71 connect(m_view.clip_ar, SIGNAL(valueChanged(double)), this, SLOT(slotModified()));
73 if (props.contains("force_fps") && props.value("force_fps").toDouble() > 0) {
74 m_view.clip_force_framerate->setChecked(true);
75 m_view.clip_framerate->setEnabled(true);
76 m_view.clip_framerate->setValue(props.value("force_fps").toDouble());
78 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
79 connect(m_view.clip_framerate, SIGNAL(valueChanged(double)), this, SLOT(slotModified()));
81 if (props.contains("force_progressive")) {
82 m_view.clip_force_progressive->setChecked(true);
83 m_view.clip_progressive->setEnabled(true);
84 m_view.clip_progressive->setValue(props.value("force_progressive").toInt());
86 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
87 connect(m_view.clip_progressive, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
89 if (props.contains("threads") && props.value("threads").toInt() != 1) {
90 m_view.clip_force_threads->setChecked(true);
91 m_view.clip_threads->setEnabled(true);
92 m_view.clip_threads->setValue(props.value("threads").toInt());
94 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
95 connect(m_view.clip_threads, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
97 if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
98 m_view.clip_force_vindex->setChecked(true);
99 m_view.clip_vindex->setEnabled(true);
100 m_view.clip_vindex->setValue(props.value("video_index").toInt());
102 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
103 connect(m_view.clip_vindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
105 if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
106 m_view.clip_force_aindex->setChecked(true);
107 m_view.clip_aindex->setEnabled(true);
108 m_view.clip_aindex->setValue(props.value("audio_index").toInt());
110 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
111 connect(m_view.clip_aindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
113 if (props.contains("audio_max")) {
114 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
117 if (props.contains("video_max")) {
118 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
121 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
122 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
123 m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
124 if (props.contains("force_colorspace")) {
125 m_view.clip_force_colorspace->setChecked(true);
126 m_view.clip_colorspace->setEnabled(true);
127 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("force_colorspace").toInt()));
128 } else if (props.contains("colorspace")) {
129 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("colorspace").toInt()));
131 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
132 connect(m_view.clip_colorspace, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
134 if (props.contains("full_luma")) {
135 m_view.clip_full_luma->setChecked(true);
137 connect(m_view.clip_full_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
139 // Check for Metadata
140 QMap<QString, QString> meta = m_clip->metadata();
141 QMap<QString, QString>::const_iterator i = meta.constBegin();
142 while (i != meta.constEnd()) {
143 QTreeWidgetItem *metaitem = new QTreeWidgetItem(m_view.metadata_list);
144 metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
145 metaitem->setText(1, i.value());
149 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
150 connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
151 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
152 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
153 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
154 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
155 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
157 if (props.contains("audiocodec"))
158 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Audio codec") << props.value("audiocodec"));
160 if (props.contains("channels"))
161 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Channels") << props.value("channels"));
163 if (props.contains("frequency"))
164 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Frequency") << props.value("frequency"));
166 CLIPTYPE t = m_clip->clipType();
167 if (t != AUDIO && t != AV) {
168 m_view.clip_force_aindex->setEnabled(false);
171 if (t != VIDEO && t != AV) {
172 m_view.clip_force_vindex->setEnabled(false);
176 m_view.tabWidget->removeTab(SLIDETAB);
177 m_view.tabWidget->removeTab(COLORTAB);
178 m_view.tabWidget->removeTab(AUDIOTAB);
179 m_view.tabWidget->removeTab(VIDEOTAB);
180 if (props.contains("frame_size"))
181 m_view.image_size->setText(props.value("frame_size"));
182 if (props.contains("transparency"))
183 m_view.image_transparency->setChecked(props.value("transparency").toInt());
184 connect(m_view.image_transparency, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
185 int width = 180.0 * KdenliveSettings::project_display_ratio();
186 if (width % 2 == 1) width++;
187 m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
188 } else if (t == COLOR) {
189 m_view.clip_path->setEnabled(false);
190 m_view.tabWidget->removeTab(METATAB);
191 m_view.tabWidget->removeTab(IMAGETAB);
192 m_view.tabWidget->removeTab(SLIDETAB);
193 m_view.tabWidget->removeTab(AUDIOTAB);
194 m_view.tabWidget->removeTab(VIDEOTAB);
195 m_view.clip_thumb->setHidden(true);
196 m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
197 connect(m_view.clip_color, SIGNAL(changed(QColor)), this, SLOT(slotModified()));
198 } else if (t == SLIDESHOW) {
200 if (url.fileName().startsWith(".all.")) {
201 // the image sequence is defined by mimetype
202 m_view.clip_path->setText(url.directory());
204 // the image sequence is defined by pattern
205 m_view.slide_type_label->setHidden(true);
206 m_view.image_type->setHidden(true);
207 m_view.clip_path->setText(url.path());
211 m_view.tabWidget->removeTab(METATAB);
212 m_view.tabWidget->removeTab(IMAGETAB);
213 m_view.tabWidget->removeTab(COLORTAB);
214 m_view.tabWidget->removeTab(AUDIOTAB);
215 m_view.tabWidget->removeTab(VIDEOTAB);
217 //WARNING: Keep in sync with slideshowclip.cpp
218 m_view.image_type->addItem("JPG (*.jpg)", "jpg");
219 m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
220 m_view.image_type->addItem("PNG (*.png)", "png");
221 m_view.image_type->addItem("BMP (*.bmp)", "bmp");
222 m_view.image_type->addItem("GIF (*.gif)", "gif");
223 m_view.image_type->addItem("TGA (*.tga)", "tga");
224 m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
225 m_view.image_type->addItem("Open EXR (*.exr)", "exr");
226 m_view.animation->addItem(i18n("None"), QString());
227 m_view.animation->addItem(i18n("Pan"), "Pan");
228 m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass");
229 m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom");
230 m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass");
231 m_view.animation->addItem(i18n("Zoom"), "Zoom");
232 m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass");
234 m_view.slide_loop->setChecked(props.value("loop").toInt());
235 m_view.slide_crop->setChecked(props.value("crop").toInt());
236 m_view.slide_fade->setChecked(props.value("fade").toInt());
237 m_view.luma_softness->setValue(props.value("softness").toInt());
238 if (!props.value("animation").isEmpty())
239 m_view.animation->setCurrentItem(props.value("animation"));
241 m_view.animation->setCurrentIndex(0);
242 QString path = props.value("resource");
243 QString ext = path.section('.', -1);
244 for (int i = 0; i < m_view.image_type->count(); i++) {
245 if (m_view.image_type->itemData(i).toString() == ext) {
246 m_view.image_type->setCurrentIndex(i);
250 m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
252 m_view.slide_duration_format->addItem(i18n("hh:mm:ss::ff"));
253 m_view.slide_duration_format->addItem(i18n("Frames"));
254 connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
255 m_view.slide_duration_frames->setHidden(true);
256 m_view.luma_duration_frames->setHidden(true);
260 m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
261 QString lumaFile = props.value("luma_file");
263 // Check for Kdenlive installed luma files
265 filters << "*.pgm" << "*.png";
267 QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
268 foreach(const QString & folder, customLumas) {
269 QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
270 foreach(const QString & fname, filesnames) {
271 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
272 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
276 // Check for MLT lumas
277 QString profilePath = KdenliveSettings::mltpath();
278 QString folder = profilePath.section('/', 0, -3);
279 folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
280 QDir lumafolder(folder);
281 QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
282 foreach(const QString & fname, filesnames) {
283 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
284 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
287 if (!lumaFile.isEmpty()) {
288 m_view.slide_luma->setChecked(true);
289 m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
290 } else m_view.luma_file->setEnabled(false);
291 slotEnableLuma(m_view.slide_fade->checkState());
292 slotEnableLumaFile(m_view.slide_luma->checkState());
294 connect(m_view.slide_fade, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
295 connect(m_view.slide_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
296 connect(m_view.slide_loop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
297 connect(m_view.slide_crop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
298 connect(m_view.slide_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
299 connect(m_view.slide_duration_frames, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
300 connect(m_view.luma_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
301 connect(m_view.luma_softness, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
302 connect(m_view.luma_file, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
303 connect(m_view.animation, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
306 connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
307 connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
308 connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
310 } else if (t != AUDIO) {
311 m_view.tabWidget->removeTab(IMAGETAB);
312 m_view.tabWidget->removeTab(SLIDETAB);
313 m_view.tabWidget->removeTab(COLORTAB);
317 m_propsDelegate = new PropertiesViewDelegate(this);
318 m_view.clip_vproperties->setItemDelegate(m_propsDelegate);
319 m_view.clip_aproperties->setItemDelegate(m_propsDelegate);
320 m_view.clip_aproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
321 m_view.clip_vproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
323 if (props.contains("videocodec"))
324 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodec"));
326 if (props.contains("frame_size"))
327 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
329 if (props.contains("fps")) {
330 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
331 if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
333 if (props.contains("aspect_ratio"))
334 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
336 if (props.contains("pix_fmt"))
337 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
339 if (props.contains("colorspace"))
340 new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
342 int width = 180.0 * KdenliveSettings::project_display_ratio();
343 if (width % 2 == 1) width++;
344 QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), width, 180);
345 m_view.clip_thumb->setPixmap(pix);
346 if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB);
348 m_view.tabWidget->removeTab(IMAGETAB);
349 m_view.tabWidget->removeTab(SLIDETAB);
350 m_view.tabWidget->removeTab(COLORTAB);
351 m_view.tabWidget->removeTab(VIDEOTAB);
352 m_view.clip_thumb->setHidden(true);
355 if (t != SLIDESHOW && t != COLOR) {
356 KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
357 m_view.clip_filesize->setText(KIO::convertSize(f.size()));
359 m_view.clip_filesize->setHidden(true);
360 m_view.label_size->setHidden(true);
362 m_view.clip_duration->setInputMask("");
363 m_view.clip_duration->setValidator(tc.validator());
364 m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
365 if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
366 else connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
369 m_view.marker_new->setIcon(KIcon("document-new"));
370 m_view.marker_new->setToolTip(i18n("Add marker"));
371 m_view.marker_edit->setIcon(KIcon("document-properties"));
372 m_view.marker_edit->setToolTip(i18n("Edit marker"));
373 m_view.marker_delete->setIcon(KIcon("trash-empty"));
374 m_view.marker_delete->setToolTip(i18n("Delete marker"));
376 slotFillMarkersList();
377 connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
378 connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
379 connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
380 connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
382 connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
383 connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
384 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
389 // Used for multiple clips editing
390 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
396 m_clipNeedsRefresh(false),
397 m_clipNeedsReLoad(false)
399 setFont(KGlobalSettings::toolBarFont());
400 m_view.setupUi(this);
401 QMap <QString, QString> props = cliplist.at(0)->properties();
402 m_old_props = commonproperties;
404 if (commonproperties.contains("force_aspect_ratio") && !commonproperties.value("force_aspect_ratio").isEmpty() && commonproperties.value("force_aspect_ratio").toDouble() > 0) {
405 m_view.clip_force_ar->setChecked(true);
406 m_view.clip_ar->setEnabled(true);
407 m_view.clip_ar->setValue(commonproperties.value("force_aspect_ratio").toDouble());
410 if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
411 m_view.clip_force_framerate->setChecked(true);
412 m_view.clip_framerate->setEnabled(true);
413 m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
416 if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
417 m_view.clip_force_progressive->setChecked(true);
418 m_view.clip_progressive->setEnabled(true);
419 m_view.clip_progressive->setValue(commonproperties.value("force_progressive").toInt());
422 if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
423 m_view.clip_force_threads->setChecked(true);
424 m_view.clip_threads->setEnabled(true);
425 m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
428 if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
429 m_view.clip_force_vindex->setChecked(true);
430 m_view.clip_vindex->setEnabled(true);
431 m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
434 if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
435 m_view.clip_force_aindex->setChecked(true);
436 m_view.clip_aindex->setEnabled(true);
437 m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
440 if (props.contains("audio_max")) {
441 m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
444 if (props.contains("video_max")) {
445 m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
448 if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
449 m_view.clip_force_colorspace->setChecked(true);
450 m_view.clip_colorspace->setEnabled(true);
451 m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
454 if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
455 m_view.clip_full_luma->setChecked(true);
458 connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
459 connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
460 connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
461 connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
462 connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
463 connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
464 connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
466 m_view.tabWidget->removeTab(METATAB);
467 m_view.tabWidget->removeTab(MARKERTAB);
468 m_view.tabWidget->removeTab(IMAGETAB);
469 m_view.tabWidget->removeTab(SLIDETAB);
470 m_view.tabWidget->removeTab(COLORTAB);
471 m_view.tabWidget->removeTab(AUDIOTAB);
472 m_view.tabWidget->removeTab(VIDEOTAB);
474 m_view.clip_path->setHidden(true);
475 m_view.label_path->setHidden(true);
476 m_view.label_description->setHidden(true);
477 m_view.label_size->setHidden(true);
478 m_view.clip_filesize->setHidden(true);
479 m_view.clip_filesize->setHidden(true);
480 m_view.clip_path->setHidden(true);
481 m_view.clip_description->setHidden(true);
482 m_view.clip_thumb->setHidden(true);
483 m_view.label_duration->setHidden(true);
484 m_view.clip_duration->setHidden(true);
486 if (commonproperties.contains("out")) {
487 if (commonproperties.value("out").toInt() > 0) {
488 m_view.clip_force_out->setChecked(true);
489 m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
490 } else m_view.clip_out->setText(KdenliveSettings::image_duration());
492 m_view.clip_force_out->setHidden(true);
493 m_view.clip_out->setHidden(true);
497 ClipProperties::~ClipProperties()
499 if (m_propsDelegate) delete m_propsDelegate;
502 void ClipProperties::slotApplyProperties()
505 emit applyNewClipProperties(m_clip->getId(), m_clip->properties(), properties(), needsTimelineRefresh(), needsTimelineReload());
506 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
509 void ClipProperties::disableClipId(const QString &id)
511 if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
512 if (m_clip->getId() == id) {
513 // clip was removed from project, close this properties dialog
519 void ClipProperties::slotModified()
521 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
525 void ClipProperties::slotEnableLuma(int state)
528 if (state == Qt::Checked) enable = true;
529 m_view.luma_duration->setEnabled(enable);
530 m_view.luma_duration_frames->setEnabled(enable);
531 m_view.slide_luma->setEnabled(enable);
533 m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
534 } else m_view.luma_file->setEnabled(false);
535 m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
536 m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
539 void ClipProperties::slotEnableLumaFile(int state)
542 if (state == Qt::Checked) enable = true;
543 m_view.luma_file->setEnabled(enable);
544 m_view.luma_softness->setEnabled(enable);
545 m_view.label_softness->setEnabled(enable);
548 void ClipProperties::slotFillMarkersList()
550 m_view.markers_list->clear();
551 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
552 for (int count = 0; count < marks.count(); ++count) {
553 QString time = m_tc.getTimecode(marks[count].time());
554 QStringList itemtext;
555 itemtext << time << marks[count].comment();
556 (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
560 void ClipProperties::slotAddMarker()
562 CommentedTime marker(GenTime(), i18n("Marker"));
563 MarkerDialog d(m_clip, marker, m_tc, i18n("Add Marker"), this);
564 if (d.exec() == QDialog::Accepted) {
565 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
567 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
570 void ClipProperties::slotEditMarker()
572 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
573 int pos = m_view.markers_list->currentIndex().row();
574 if (pos < 0 || pos > marks.count() - 1) return;
575 MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
576 if (d.exec() == QDialog::Accepted) {
577 emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
579 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
582 void ClipProperties::slotDeleteMarker()
584 QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
585 int pos = m_view.markers_list->currentIndex().row();
586 if (pos < 0 || pos > marks.count() - 1) return;
587 emit addMarker(m_clip->getId(), marks.at(pos).time(), QString());
589 QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
592 const QString &ClipProperties::clipId() const
594 return m_clip->getId();
598 QMap <QString, QString> ClipProperties::properties()
600 QMap <QString, QString> props;
601 CLIPTYPE t = UNKNOWN;
602 if (m_clip != NULL) {
603 t = m_clip->clipType();
604 m_old_props = m_clip->properties();
607 double aspect = m_view.clip_ar->value();
608 if (m_view.clip_force_ar->isChecked()) {
609 if (aspect != m_old_props.value("force_aspect_ratio").toDouble()) {
610 props["force_aspect_ratio"] = QString::number(aspect);
611 m_clipNeedsRefresh = true;
613 } else if (m_old_props.contains("force_aspect_ratio")) {
614 props["force_aspect_ratio"].clear();
615 m_clipNeedsRefresh = true;
618 double fps = m_view.clip_framerate->value();
619 if (m_view.clip_force_framerate->isChecked()) {
620 if (fps != m_old_props.value("force_fps").toDouble()) {
621 props["force_fps"] = QString::number(fps);
622 m_clipNeedsRefresh = true;
624 } else if (m_old_props.contains("force_fps")) {
625 props["force_fps"].clear();
626 m_clipNeedsRefresh = true;
629 int progressive = m_view.clip_progressive->value();
630 if (m_view.clip_force_progressive->isChecked()) {
631 if (progressive != m_old_props.value("force_progressive").toInt()) {
632 props["force_progressive"] = QString::number(progressive);
634 } else if (m_old_props.contains("force_progressive")) {
635 props["force_progressive"].clear();
638 int threads = m_view.clip_threads->value();
639 if (m_view.clip_force_threads->isChecked()) {
640 if (threads != m_old_props.value("threads").toInt()) {
641 props["threads"] = QString::number(threads);
643 } else if (m_old_props.contains("threads")) {
644 props["threads"].clear();
647 int vindex = m_view.clip_vindex->value();
648 if (m_view.clip_force_vindex->isChecked()) {
649 if (vindex != m_old_props.value("video_index").toInt()) {
650 props["video_index"] = QString::number(vindex);
652 } else if (m_old_props.contains("video_index")) {
653 props["video_index"].clear();
656 int aindex = m_view.clip_aindex->value();
657 if (m_view.clip_force_aindex->isChecked()) {
658 if (aindex != m_old_props.value("audio_index").toInt()) {
659 props["audio_index"] = QString::number(aindex);
661 } else if (m_old_props.contains("audio_index")) {
662 props["audio_index"].clear();
665 int colorspace = m_view.clip_colorspace->itemData(m_view.clip_colorspace->currentIndex()).toInt();
666 if (m_view.clip_force_colorspace->isChecked()) {
667 if (colorspace != m_old_props.value("force_colorspace").toInt()) {
668 props["force_colorspace"] = QString::number(colorspace);
669 m_clipNeedsRefresh = true;
671 } else if (m_old_props.contains("force_colorspace")) {
672 props["force_colorspace"].clear();
673 m_clipNeedsRefresh = true;
676 if (m_view.clip_full_luma->isChecked()) {
677 props["full_luma"] = QString::number(1);
678 m_clipNeedsRefresh = true;
679 } else if (m_old_props.contains("full_luma")) {
680 props["full_luma"].clear();
681 m_clipNeedsRefresh = true;
684 // If we adjust several clips, return now
685 if (m_clip == NULL) {
686 if (m_view.clip_out->isEnabled()) {
687 int duration = m_tc.getFrameCount(m_view.clip_out->text());
688 if (duration != m_old_props.value("out").toInt()) {
689 props["out"] = QString::number(duration - 1);
695 if (m_old_props.value("description") != m_view.clip_description->text())
696 props["description"] = m_view.clip_description->text();
699 QString new_color = m_view.clip_color->color().name();
700 if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
701 m_clipNeedsRefresh = true;
702 props["colour"] = "0x" + new_color.right(6) + "ff";
704 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
705 if (duration != m_clip->duration().frames(m_fps)) {
706 props["out"] = QString::number(duration - 1);
708 } else if (t == IMAGE) {
709 if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
710 props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
711 //m_clipNeedsRefresh = true;
713 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
714 if (duration != m_clip->duration().frames(m_fps)) {
715 props["out"] = QString::number(duration - 1);
717 } else if (t == SLIDESHOW) {
718 QString value = QString::number((int) m_view.slide_loop->isChecked());
719 if (m_old_props.value("loop") != value) props["loop"] = value;
720 value = QString::number((int) m_view.slide_crop->isChecked());
721 if (m_old_props.value("crop") != value) props["crop"] = value;
722 value = QString::number((int) m_view.slide_fade->isChecked());
723 if (m_old_props.value("fade") != value) props["fade"] = value;
724 value = QString::number((int) m_view.luma_softness->value());
725 if (m_old_props.value("softness") != value) props["softness"] = value;
727 bool isMime = !(m_view.clip_path->text().contains('%'));
729 QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
730 QString new_path = m_view.clip_path->text() + extension;
731 if (new_path != m_old_props.value("resource")) {
732 m_clipNeedsReLoad = true;
733 props["resource"] = new_path;
734 kDebug() << "//// SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
738 if (m_view.slide_duration_format->currentIndex() == 1) {
739 // we are in frames mode
740 duration = m_view.slide_duration_frames->value();
741 } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
742 if (duration != m_old_props.value("ttl").toInt()) {
743 m_clipNeedsRefresh = true;
744 props["ttl"] = QString::number(duration);
745 props["out"] = QString::number(duration * m_count - 1);
748 if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
749 m_clipNeedsRefresh = true;
750 props["out"] = QString::number(duration * m_count - 1);
752 if (m_view.slide_fade->isChecked()) {
754 if (m_view.slide_duration_format->currentIndex() == 1) {
755 // we are in frames mode
756 luma_duration = m_view.luma_duration_frames->value();
757 } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
758 if (luma_duration != m_old_props.value("luma_duration").toInt()) {
759 m_clipNeedsRefresh = true;
760 props["luma_duration"] = QString::number(luma_duration);
763 if (m_view.slide_luma->isChecked())
764 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
765 if (lumaFile != m_old_props.value("luma_file")) {
766 m_clipNeedsRefresh = true;
767 props["luma_file"] = lumaFile;
770 if (!m_old_props.value("luma_file").isEmpty()) {
771 props["luma_file"].clear();
775 QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
776 if (animation != m_old_props.value("animation")) {
777 if (animation.isEmpty()) {
778 props["animation"].clear();
780 props["animation"] = animation;
782 m_clipNeedsRefresh = true;
788 bool ClipProperties::needsTimelineRefresh() const
790 return m_clipNeedsRefresh;
793 bool ClipProperties::needsTimelineReload() const
795 return m_clipNeedsReLoad;
799 void ClipProperties::parseFolder()
801 QString path = m_view.clip_path->text();
802 bool isMime = !(path.contains('%'));
803 if (!isMime) path = KUrl(path).directory();
810 // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
811 filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
812 extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
813 dir.setNameFilters(filters);
816 QStringList result = dir.entryList(QDir::Files);
820 QString filter = KUrl(m_view.clip_path->text()).fileName();
821 QString ext = filter.section('.', -1);
822 filter = filter.section('%', 0, -2);
823 QString regexp = "^" + filter + "\\d+\\." + ext + "$";
826 foreach(const QString & path, result) {
827 if (rx.exactMatch(path)) entries << path;
832 m_count = result.count();
833 m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(m_count > 0);
835 // no images, do not accept that
836 m_view.slide_info->setText(i18n("No image found"));
837 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
840 m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
841 m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
842 QDomElement xml = m_clip->toXML();
843 xml.setAttribute("resource", m_view.clip_path->text() + extension);
844 int width = 180.0 * KdenliveSettings::project_display_ratio();
845 if (width % 2 == 1) width++;
846 QString filePath = m_view.clip_path->text();
847 if (isMime) filePath.append(extension);
848 QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
849 QMap <QString, QString> props = m_clip->properties();
850 m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
851 m_view.clip_thumb->setPixmap(pix);
854 void ClipProperties::slotCheckMaxLength()
856 if (m_clip->maxDuration() == GenTime()) return;
857 int duration = m_tc.getFrameCount(m_view.clip_duration->text());
858 if (duration > m_clip->maxDuration().frames(m_fps)) {
859 m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
863 void ClipProperties::slotUpdateDurationFormat(int ix)
865 bool framesFormat = ix == 1;
867 // switching to frames count, update widget
868 m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
869 m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
870 m_view.slide_duration->setHidden(true);
871 m_view.luma_duration->setHidden(true);
872 m_view.slide_duration_frames->setHidden(false);
873 m_view.luma_duration_frames->setHidden(false);
875 // switching to timecode format
876 m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
877 m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
878 m_view.slide_duration_frames->setHidden(true);
879 m_view.luma_duration_frames->setHidden(true);
880 m_view.slide_duration->setHidden(false);
881 m_view.luma_duration->setHidden(false);
885 #include "clipproperties.moc"