]> git.sesse.net Git - kdenlive/blob - src/clipproperties.cpp
* Allow to edit transparent background for images in group properties
[kdenlive] / src / clipproperties.cpp
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21 #include "clipproperties.h"
22 #include "kdenlivesettings.h"
23 #include "kthumb.h"
24 #include "markerdialog.h"
25 #include "profilesdialog.h"
26
27 #include <KStandardDirs>
28 #include <KDebug>
29 #include <KFileItem>
30
31 #include <QDir>
32
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;
41
42
43 ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidget * parent) :
44     QDialog(parent),
45     m_clip(clip),
46     m_tc(tc),
47     m_fps(fps),
48     m_count(0),
49     m_clipNeedsRefresh(false),
50     m_clipNeedsReLoad(false)
51 {
52     setAttribute(Qt::WA_DeleteOnClose, true);
53     setFont(KGlobalSettings::toolBarFont());
54     m_view.setupUi(this);
55     
56     // force transparency is only for group properties, so hide it
57     m_view.clip_force_transparency->setHidden(true);
58     m_view.clip_transparency->setHidden(true);
59     
60     KUrl url = m_clip->fileURL();
61     m_view.clip_path->setText(url.path());
62     m_view.clip_description->setText(m_clip->description());
63     connect(m_view.clip_description, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
64
65     QMap <QString, QString> props = m_clip->properties();
66     m_view.clip_force_out->setHidden(true);
67     m_view.clip_out->setHidden(true);
68
69     // New display aspect ratio support
70     if (props.contains("force_aspect_num") && props.value("force_aspect_num").toInt() > 0 &&
71         props.contains("force_aspect_den") && props.value("force_aspect_den").toInt() > 0) {
72         m_view.clip_force_ar->setChecked(true);
73         m_view.clip_ar_num->setEnabled(true);
74         m_view.clip_ar_den->setEnabled(true);
75         m_view.clip_ar_num->setValue(props.value("force_aspect_num").toInt());
76         m_view.clip_ar_den->setValue(props.value("force_aspect_den").toInt());
77     }
78     // Legacy support for pixel aspect ratio
79     else if (props.contains("force_aspect_ratio") && props.value("force_aspect_ratio").toDouble() > 0) {
80         m_view.clip_force_ar->setChecked(true);
81         m_view.clip_ar_num->setEnabled(true);
82         m_view.clip_ar_den->setEnabled(true);
83         if (props.contains("frame_size")) {
84             int width = props.value("force_aspect_ratio").toDouble() * props.value("frame_size").section('x', 0, 0).toInt();
85             int height = props.value("frame_size").section('x', 1, 1).toInt();
86             if (width > 0 && height > 0) {
87                 if ((width / height * 100) == 133) {
88                     width = 4;
89                     height = 3;
90                 }
91                 else if (int(width / height * 100) == 177) {
92                     width = 16;
93                     height = 9;
94                 }
95                 m_view.clip_ar_num->setValue(width);
96                 m_view.clip_ar_den->setValue(height);
97             }
98         }
99     }
100     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
101     connect(m_view.clip_ar_num, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
102     connect(m_view.clip_ar_den, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
103
104     if (props.contains("force_fps") && props.value("force_fps").toDouble() > 0) {
105         m_view.clip_force_framerate->setChecked(true);
106         m_view.clip_framerate->setEnabled(true);
107         m_view.clip_framerate->setValue(props.value("force_fps").toDouble());
108     }
109     connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
110     connect(m_view.clip_framerate, SIGNAL(valueChanged(double)), this, SLOT(slotModified()));
111
112     if (props.contains("force_progressive")) {
113         m_view.clip_force_progressive->setChecked(true);
114         m_view.clip_progressive->setEnabled(true);
115         m_view.clip_progressive->setValue(props.value("force_progressive").toInt());
116     }
117     connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
118     connect(m_view.clip_progressive, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
119
120     m_view.clip_fieldorder->addItem(i18n("Bottom first"), 0);
121     m_view.clip_fieldorder->addItem(i18n("Top first"), 1);
122     if (props.contains("force_tff")) {
123         m_view.clip_force_fieldorder->setChecked(true);
124         m_view.clip_fieldorder->setEnabled(true);
125         m_view.clip_fieldorder->setCurrentIndex(props.value("force_tff").toInt());
126     }
127     connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
128     connect(m_view.clip_fieldorder, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
129     
130     if (props.contains("threads") && props.value("threads").toInt() != 1) {
131         m_view.clip_force_threads->setChecked(true);
132         m_view.clip_threads->setEnabled(true);
133         m_view.clip_threads->setValue(props.value("threads").toInt());
134     }
135     connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
136     connect(m_view.clip_threads, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
137
138     if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
139         m_view.clip_force_vindex->setChecked(true);
140         m_view.clip_vindex->setEnabled(true);
141         m_view.clip_vindex->setValue(props.value("video_index").toInt());
142     }
143     connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
144     connect(m_view.clip_vindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
145
146     if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
147         m_view.clip_force_aindex->setChecked(true);
148         m_view.clip_aindex->setEnabled(true);
149         m_view.clip_aindex->setValue(props.value("audio_index").toInt());
150     }
151     connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
152     connect(m_view.clip_aindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
153
154     if (props.contains("audio_max")) {
155         m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
156     }
157
158     if (props.contains("video_max")) {
159         m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
160     }
161     
162     m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
163     m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
164     m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
165     if (props.contains("force_colorspace")) {
166         m_view.clip_force_colorspace->setChecked(true);
167         m_view.clip_colorspace->setEnabled(true);
168         m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("force_colorspace").toInt()));
169     } else if (props.contains("colorspace")) {
170         m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("colorspace").toInt()));
171     }
172     connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
173     connect(m_view.clip_colorspace, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
174     
175     if (props.contains("full_luma")) {
176         m_view.clip_full_luma->setChecked(true);
177     }
178     connect(m_view.clip_full_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
179
180     // Check for Metadata
181     QMap<QString, QString> meta = m_clip->metadata();
182     QMap<QString, QString>::const_iterator i = meta.constBegin();
183     while (i != meta.constEnd()) {
184         QTreeWidgetItem *metaitem = new QTreeWidgetItem(m_view.metadata_list);
185         metaitem->setText(0, i.key()); //i18n(i.key().section('.', 2, 3).toUtf8().data()));
186         metaitem->setText(1, i.value());
187         ++i;
188     }
189
190     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
191     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
192     connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), m_view.clip_framerate, SLOT(setEnabled(bool)));
193     connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
194     connect(m_view.clip_force_fieldorder, SIGNAL(toggled(bool)), m_view.clip_fieldorder, SLOT(setEnabled(bool)));
195     connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
196     connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
197     connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
198     connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
199
200     if (props.contains("audiocodec"))
201         QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Audio codec") << props.value("audiocodec"));
202
203     if (props.contains("channels"))
204         QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Channels") << props.value("channels"));
205
206     if (props.contains("frequency"))
207         QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Frequency") << props.value("frequency"));
208
209     CLIPTYPE t = m_clip->clipType();
210     if (t != AUDIO && t != AV) {
211         m_view.clip_force_aindex->setEnabled(false);
212     }
213
214     if (t != VIDEO && t != AV) {
215         m_view.clip_force_vindex->setEnabled(false);
216     }
217
218     if (t == IMAGE) {
219         m_view.tabWidget->removeTab(SLIDETAB);
220         m_view.tabWidget->removeTab(COLORTAB);
221         m_view.tabWidget->removeTab(AUDIOTAB);
222         m_view.tabWidget->removeTab(VIDEOTAB);
223         if (props.contains("frame_size"))
224             m_view.image_size->setText(props.value("frame_size"));
225         if (props.contains("transparency"))
226             m_view.image_transparency->setChecked(props.value("transparency").toInt());
227         connect(m_view.image_transparency, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
228         int width = 180.0 * KdenliveSettings::project_display_ratio();
229         if (width % 2 == 1) width++;
230         m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
231     } else if (t == COLOR) {
232         m_view.clip_path->setEnabled(false);
233         m_view.tabWidget->removeTab(METATAB);
234         m_view.tabWidget->removeTab(IMAGETAB);
235         m_view.tabWidget->removeTab(SLIDETAB);
236         m_view.tabWidget->removeTab(AUDIOTAB);
237         m_view.tabWidget->removeTab(VIDEOTAB);
238         m_view.clip_thumb->setHidden(true);
239         m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
240         connect(m_view.clip_color, SIGNAL(changed(QColor)), this, SLOT(slotModified()));
241     } else if (t == SLIDESHOW) {
242         bool isMime = true;
243         if (url.fileName().startsWith(".all.")) {
244             // the image sequence is defined by mimetype
245             m_view.clip_path->setText(url.directory());
246         } else {
247             // the image sequence is defined by pattern
248             m_view.slide_type_label->setHidden(true);
249             m_view.image_type->setHidden(true);
250             m_view.clip_path->setText(url.path());
251             isMime = false;
252         }
253
254         m_view.tabWidget->removeTab(METATAB);
255         m_view.tabWidget->removeTab(IMAGETAB);
256         m_view.tabWidget->removeTab(COLORTAB);
257         m_view.tabWidget->removeTab(AUDIOTAB);
258         m_view.tabWidget->removeTab(VIDEOTAB);
259
260         //WARNING: Keep in sync with slideshowclip.cpp
261         m_view.image_type->addItem("JPG (*.jpg)", "jpg");
262         m_view.image_type->addItem("JPEG (*.jpeg)", "jpeg");
263         m_view.image_type->addItem("PNG (*.png)", "png");
264         m_view.image_type->addItem("BMP (*.bmp)", "bmp");
265         m_view.image_type->addItem("GIF (*.gif)", "gif");
266         m_view.image_type->addItem("TGA (*.tga)", "tga");
267         m_view.image_type->addItem("TIF (*.tif)", "tif");
268         m_view.image_type->addItem("TIFF (*.tiff)", "tiff");
269         m_view.image_type->addItem("Open EXR (*.exr)", "exr");
270         m_view.animation->addItem(i18n("None"), QString());
271         m_view.animation->addItem(i18n("Pan"), "Pan");
272         m_view.animation->addItem(i18n("Pan, low-pass"), "Pan, low-pass");
273         m_view.animation->addItem(i18n("Pan and zoom"), "Pan and zoom");
274         m_view.animation->addItem(i18n("Pan and zoom, low-pass"), "Pan and zoom, low-pass");
275         m_view.animation->addItem(i18n("Zoom"), "Zoom");
276         m_view.animation->addItem(i18n("Zoom, low-pass"), "Zoom, low-pass");
277
278         m_view.slide_loop->setChecked(props.value("loop").toInt());
279         m_view.slide_crop->setChecked(props.value("crop").toInt());
280         m_view.slide_fade->setChecked(props.value("fade").toInt());
281         m_view.luma_softness->setValue(props.value("softness").toInt());
282         if (!props.value("animation").isEmpty())
283             m_view.animation->setCurrentItem(props.value("animation"));
284         else
285             m_view.animation->setCurrentIndex(0);
286         QString path = props.value("resource");
287         QString ext = path.section('.', -1);
288         for (int i = 0; i < m_view.image_type->count(); i++) {
289             if (m_view.image_type->itemData(i).toString() == ext) {
290                 m_view.image_type->setCurrentIndex(i);
291                 break;
292             }
293         }
294         m_view.slide_duration->setText(tc.getTimecodeFromFrames(props.value("ttl").toInt()));
295
296         m_view.slide_duration_format->addItem(i18n("hh:mm:ss:ff"));
297         m_view.slide_duration_format->addItem(i18n("Frames"));
298         connect(m_view.slide_duration_format, SIGNAL(activated(int)), this, SLOT(slotUpdateDurationFormat(int)));
299         m_view.slide_duration_frames->setHidden(true);
300         m_view.luma_duration_frames->setHidden(true);
301
302         parseFolder();
303
304         m_view.luma_duration->setText(tc.getTimecodeFromFrames(props.value("luma_duration").toInt()));
305         QString lumaFile = props.value("luma_file");
306
307         // Check for Kdenlive installed luma files
308         QStringList filters;
309         filters << "*.pgm" << "*.png";
310
311         QStringList customLumas = KGlobal::dirs()->findDirs("appdata", "lumas");
312         foreach(const QString & folder, customLumas) {
313             QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
314             foreach(const QString & fname, filesnames) {
315                 QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
316                 m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
317             }
318         }
319
320         // Check for MLT lumas
321         QString profilePath = KdenliveSettings::mltpath();
322         QString folder = profilePath.section('/', 0, -3);
323         folder.append("/lumas/PAL"); // TODO: cleanup the PAL / NTSC mess in luma files
324         QDir lumafolder(folder);
325         QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
326         foreach(const QString & fname, filesnames) {
327             QString filePath = KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
328             m_view.luma_file->addItem(KIcon(filePath), fname, filePath);
329         }
330
331         if (!lumaFile.isEmpty()) {
332             m_view.slide_luma->setChecked(true);
333             m_view.luma_file->setCurrentIndex(m_view.luma_file->findData(lumaFile));
334         } else m_view.luma_file->setEnabled(false);
335         slotEnableLuma(m_view.slide_fade->checkState());
336         slotEnableLumaFile(m_view.slide_luma->checkState());
337
338         connect(m_view.slide_fade, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
339         connect(m_view.slide_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
340         connect(m_view.slide_loop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
341         connect(m_view.slide_crop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
342         connect(m_view.slide_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
343         connect(m_view.slide_duration_frames, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
344         connect(m_view.luma_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
345         connect(m_view.luma_softness, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
346         connect(m_view.luma_file, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
347         connect(m_view.animation, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
348
349
350         connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
351         connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
352         connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
353
354     } else if (t != AUDIO) {
355         m_view.tabWidget->removeTab(IMAGETAB);
356         m_view.tabWidget->removeTab(SLIDETAB);
357         m_view.tabWidget->removeTab(COLORTAB);
358
359         PropertiesViewDelegate *del1 = new PropertiesViewDelegate(this);
360         PropertiesViewDelegate *del2 = new PropertiesViewDelegate(this);
361         m_view.clip_vproperties->setItemDelegate(del1);
362         m_view.clip_aproperties->setItemDelegate(del2);
363         m_view.clip_aproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
364         m_view.clip_vproperties->setStyleSheet(QString("QTreeWidget { background-color: transparent;}"));
365
366         if (props.contains("videocodec"))
367             QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodec"));
368
369         if (props.contains("frame_size"))
370             new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
371
372         if (props.contains("fps")) {
373             new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
374             if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
375         }
376         if (props.contains("aspect_ratio"))
377             new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
378
379         if (props.contains("pix_fmt"))
380             new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
381
382         if (props.contains("colorspace"))
383             new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
384
385         int width = 180.0 * KdenliveSettings::project_display_ratio();
386         if (width % 2 == 1) width++;
387         QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), width, 180);
388         m_view.clip_thumb->setPixmap(pix);
389         if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB);
390     } else {
391         m_view.tabWidget->removeTab(IMAGETAB);
392         m_view.tabWidget->removeTab(SLIDETAB);
393         m_view.tabWidget->removeTab(COLORTAB);
394         m_view.tabWidget->removeTab(VIDEOTAB);
395         m_view.clip_thumb->setHidden(true);
396     }
397
398     if (t != SLIDESHOW && t != COLOR) {
399         KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
400         m_view.clip_filesize->setText(KIO::convertSize(f.size()));
401     } else {
402         m_view.clip_filesize->setHidden(true);
403         m_view.label_size->setHidden(true);
404     }
405     m_view.clip_duration->setInputMask("");
406     m_view.clip_duration->setValidator(tc.validator());
407     m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
408     if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
409     else {
410         connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
411         connect(m_view.clip_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
412     }
413
414     // markers
415     m_view.marker_new->setIcon(KIcon("document-new"));
416     m_view.marker_new->setToolTip(i18n("Add marker"));
417     m_view.marker_edit->setIcon(KIcon("document-properties"));
418     m_view.marker_edit->setToolTip(i18n("Edit marker"));
419     m_view.marker_delete->setIcon(KIcon("trash-empty"));
420     m_view.marker_delete->setToolTip(i18n("Delete marker"));
421
422     slotFillMarkersList();
423     connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
424     connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
425     connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
426     connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
427
428     connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
429     connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
430     m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
431     //adjustSize();
432 }
433
434
435 // Used for multiple clips editing
436 ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap <QString, QString> commonproperties, QWidget * parent) :
437     QDialog(parent),
438     m_clip(NULL),
439     m_tc(tc),
440     m_fps(0),
441     m_count(0),
442     m_clipNeedsRefresh(false),
443     m_clipNeedsReLoad(false)
444 {
445     setFont(KGlobalSettings::toolBarFont());
446     m_view.setupUi(this);
447     QString title = windowTitle();
448     title.append(" " + i18np("(%1 clip)", "(%1 clips)", cliplist.count()));
449     setWindowTitle(title);
450     QMap <QString, QString> props = cliplist.at(0)->properties();
451     m_old_props = commonproperties;
452
453     if (commonproperties.contains("force_aspect_num") && !commonproperties.value("force_aspect_num").isEmpty() && commonproperties.value("force_aspect_den").toInt() > 0) {
454         m_view.clip_force_ar->setChecked(true);
455         m_view.clip_ar_num->setEnabled(true);
456         m_view.clip_ar_den->setEnabled(true);
457         m_view.clip_ar_num->setValue(commonproperties.value("force_aspect_num").toInt());
458         m_view.clip_ar_den->setValue(commonproperties.value("force_aspect_den").toInt());
459     }
460
461     if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
462         m_view.clip_force_framerate->setChecked(true);
463         m_view.clip_framerate->setEnabled(true);
464         m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
465     }
466
467     if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
468         m_view.clip_force_progressive->setChecked(true);
469         m_view.clip_progressive->setEnabled(true);
470         m_view.clip_progressive->setValue(commonproperties.value("force_progressive").toInt());
471     }
472
473     if (commonproperties.contains("force_tff") && !commonproperties.value("force_tff").isEmpty()) {
474         m_view.clip_force_fieldorder->setChecked(true);
475         m_view.clip_fieldorder->setEnabled(true);
476         m_view.clip_fieldorder->setCurrentIndex(commonproperties.value("force_tff").toInt());
477     }
478     
479     if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
480         m_view.clip_force_threads->setChecked(true);
481         m_view.clip_threads->setEnabled(true);
482         m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
483     }
484
485     if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
486         m_view.clip_force_vindex->setChecked(true);
487         m_view.clip_vindex->setEnabled(true);
488         m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
489     }
490
491     if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
492         m_view.clip_force_aindex->setChecked(true);
493         m_view.clip_aindex->setEnabled(true);
494         m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
495     }
496
497     if (props.contains("audio_max")) {
498         m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
499     }
500
501     if (props.contains("video_max")) {
502         m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
503     }
504     
505     m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
506     m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
507     m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
508     
509     if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
510         m_view.clip_force_colorspace->setChecked(true);
511         m_view.clip_colorspace->setEnabled(true);
512         m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
513     }
514     
515     if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
516         m_view.clip_full_luma->setChecked(true);
517     }
518     
519     if (commonproperties.contains("transparency")) {
520         // image transparency checkbox
521         int transparency = commonproperties.value("transparency").toInt();
522         if (transparency == 0) {
523             m_view.clip_force_transparency->setChecked(true);
524         }
525         else if (transparency == 1) {
526             m_view.clip_force_transparency->setChecked(true);
527             m_view.clip_transparency->setCurrentIndex(1);
528         }
529     }
530     else {
531         m_view.clip_force_transparency->setHidden(true);
532         m_view.clip_transparency->setHidden(true);
533     }
534     
535
536     connect(m_view.clip_force_transparency, SIGNAL(toggled(bool)), m_view.clip_transparency, SLOT(setEnabled(bool)));
537     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
538     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
539     connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
540     connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
541     connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
542     connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
543     connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
544     connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
545
546     m_view.tabWidget->removeTab(METATAB);
547     m_view.tabWidget->removeTab(MARKERTAB);
548     m_view.tabWidget->removeTab(IMAGETAB);
549     m_view.tabWidget->removeTab(SLIDETAB);
550     m_view.tabWidget->removeTab(COLORTAB);
551     m_view.tabWidget->removeTab(AUDIOTAB);
552     m_view.tabWidget->removeTab(VIDEOTAB);
553
554     m_view.clip_path->setHidden(true);
555     m_view.label_path->setHidden(true);
556     m_view.label_description->setHidden(true);
557     m_view.label_size->setHidden(true);
558     m_view.clip_filesize->setHidden(true);
559     m_view.clip_filesize->setHidden(true);
560     m_view.clip_path->setHidden(true);
561     m_view.clip_description->setHidden(true);
562     m_view.clip_thumb->setHidden(true);
563     m_view.label_duration->setHidden(true);
564     m_view.clip_duration->setHidden(true);
565
566     if (commonproperties.contains("out")) {
567         if (commonproperties.value("out").toInt() > 0) {
568             m_view.clip_force_out->setChecked(true);
569             m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
570         } else m_view.clip_out->setText(KdenliveSettings::image_duration());
571     } else {
572         m_view.clip_force_out->setHidden(true);
573         m_view.clip_out->setHidden(true);
574     }
575 }
576
577 ClipProperties::~ClipProperties()
578 {
579     QAbstractItemDelegate *del1 = m_view.clip_vproperties->itemDelegate();
580     if (del1) delete del1;
581     QAbstractItemDelegate *del2 = m_view.clip_aproperties->itemDelegate();
582     if (del2) delete del2;
583 }
584
585 void ClipProperties::slotApplyProperties()
586 {
587     if (m_clip != NULL)
588         emit applyNewClipProperties(m_clip->getId(), m_clip->properties(), properties(), needsTimelineRefresh(), needsTimelineReload());
589     m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
590 }
591
592 void ClipProperties::disableClipId(const QString &id)
593 {
594     if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
595         if (m_clip->getId() == id) {
596             // clip was removed from project, close this properties dialog
597             close();
598         }
599     }
600 }
601
602 void ClipProperties::slotModified()
603 {
604     m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
605 }
606
607
608 void ClipProperties::slotEnableLuma(int state)
609 {
610     bool enable = false;
611     if (state == Qt::Checked) enable = true;
612     m_view.luma_duration->setEnabled(enable);
613     m_view.luma_duration_frames->setEnabled(enable);
614     m_view.slide_luma->setEnabled(enable);
615     if (enable) {
616         m_view.luma_file->setEnabled(m_view.slide_luma->isChecked());
617     } else m_view.luma_file->setEnabled(false);
618     m_view.label_softness->setEnabled(m_view.slide_luma->isChecked() && enable);
619     m_view.luma_softness->setEnabled(m_view.label_softness->isEnabled());
620 }
621
622 void ClipProperties::slotEnableLumaFile(int state)
623 {
624     bool enable = false;
625     if (state == Qt::Checked) enable = true;
626     m_view.luma_file->setEnabled(enable);
627     m_view.luma_softness->setEnabled(enable);
628     m_view.label_softness->setEnabled(enable);
629 }
630
631 void ClipProperties::slotFillMarkersList()
632 {
633     m_view.markers_list->clear();
634     QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
635     for (int count = 0; count < marks.count(); ++count) {
636         QString time = m_tc.getTimecode(marks[count].time());
637         QStringList itemtext;
638         itemtext << time << marks[count].comment();
639         (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
640     }
641 }
642
643 void ClipProperties::slotAddMarker()
644 {
645     CommentedTime marker(GenTime(), i18n("Marker"));
646     MarkerDialog d(m_clip, marker, m_tc, i18n("Add Marker"), this);
647     if (d.exec() == QDialog::Accepted) {
648         emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
649     }
650     QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
651 }
652
653 void ClipProperties::slotEditMarker()
654 {
655     QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
656     int pos = m_view.markers_list->currentIndex().row();
657     if (pos < 0 || pos > marks.count() - 1) return;
658     MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
659     if (d.exec() == QDialog::Accepted) {
660         emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
661     }
662     QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
663 }
664
665 void ClipProperties::slotDeleteMarker()
666 {
667     QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
668     int pos = m_view.markers_list->currentIndex().row();
669     if (pos < 0 || pos > marks.count() - 1) return;
670     emit addMarker(m_clip->getId(), marks.at(pos).time(), QString());
671
672     QTimer::singleShot(500, this, SLOT(slotFillMarkersList()));
673 }
674
675 const QString &ClipProperties::clipId() const
676 {
677     return m_clip->getId();
678 }
679
680
681 QMap <QString, QString> ClipProperties::properties()
682 {
683     QMap <QString, QString> props;
684     CLIPTYPE t = UNKNOWN;
685     if (m_clip != NULL) {
686         t = m_clip->clipType();
687         m_old_props = m_clip->properties();
688     }
689
690     int aspectNumerator = m_view.clip_ar_num->value();
691     int aspectDenominator = m_view.clip_ar_den->value();
692     if (m_view.clip_force_ar->isChecked()) {
693         if (aspectNumerator != m_old_props.value("force_aspect_num").toInt() ||
694             aspectDenominator != m_old_props.value("force_aspect_den").toInt()) {
695             props["force_aspect_num"] = QString::number(aspectNumerator);
696             props["force_aspect_den"] = QString::number(aspectDenominator);
697             props["force_aspect_ratio"].clear();
698             m_clipNeedsRefresh = true;
699         }
700     } else {
701         if (m_old_props.contains("force_aspect_num") && !m_old_props.value("force_aspect_num").isEmpty()) {
702             props["force_aspect_num"].clear();
703             m_clipNeedsRefresh = true;
704         }
705         if (m_old_props.contains("force_aspect_den") && !m_old_props.value("force_aspect_den").isEmpty()) {
706             props["force_aspect_den"].clear();
707             m_clipNeedsRefresh = true;
708         }
709     }
710
711     double fps = m_view.clip_framerate->value();
712     if (m_view.clip_force_framerate->isChecked()) {
713         if (fps != m_old_props.value("force_fps").toDouble()) {
714             props["force_fps"] = QString::number(fps);
715             m_clipNeedsRefresh = true;
716         }
717     } else if (m_old_props.contains("force_fps") && !m_old_props.value("force_fps").isEmpty()) {
718         props["force_fps"].clear();
719         m_clipNeedsRefresh = true;
720     }
721
722     int progressive = m_view.clip_progressive->value();
723     if (m_view.clip_force_progressive->isChecked()) {
724         if (progressive != m_old_props.value("force_progressive").toInt()) {
725             props["force_progressive"] = QString::number(progressive);
726         }
727     } else if (m_old_props.contains("force_progressive") && !m_old_props.value("force_progressive").isEmpty()) {
728         props["force_progressive"].clear();
729     }
730
731     int fieldOrder = m_view.clip_fieldorder->currentIndex();
732     if (m_view.clip_force_fieldorder->isChecked()) {
733         if (fieldOrder != m_old_props.value("force_tff").toInt()) {
734             props["force_tff"] = QString::number(fieldOrder);
735         }
736     } else if (m_old_props.contains("force_tff") && !m_old_props.value("force_tff").isEmpty()) {
737         props["force_tff"].clear();
738     }
739
740     int threads = m_view.clip_threads->value();
741     if (m_view.clip_force_threads->isChecked()) {
742         if (threads != m_old_props.value("threads").toInt()) {
743             props["threads"] = QString::number(threads);
744         }
745     } else if (m_old_props.contains("threads") && !m_old_props.value("threads").isEmpty()) {
746         props["threads"].clear();
747     }
748
749     int vindex = m_view.clip_vindex->value();
750     if (m_view.clip_force_vindex->isChecked()) {
751         if (vindex != m_old_props.value("video_index").toInt()) {
752             props["video_index"] = QString::number(vindex);
753         }
754     } else if (m_old_props.contains("video_index") && !m_old_props.value("video_index").isEmpty()) {
755         props["video_index"].clear();
756     }
757
758     int aindex = m_view.clip_aindex->value();
759     if (m_view.clip_force_aindex->isChecked()) {
760         if (aindex != m_old_props.value("audio_index").toInt()) {
761             props["audio_index"] = QString::number(aindex);
762         }
763     } else if (m_old_props.contains("audio_index") && !m_old_props.value("audio_index").isEmpty()) {
764         props["audio_index"].clear();
765     }
766     
767     int colorspace = m_view.clip_colorspace->itemData(m_view.clip_colorspace->currentIndex()).toInt();
768     if (m_view.clip_force_colorspace->isChecked()) {
769         if (colorspace != m_old_props.value("force_colorspace").toInt()) {
770             props["force_colorspace"] = QString::number(colorspace);
771             m_clipNeedsRefresh = true;
772         }
773     } else if (m_old_props.contains("force_colorspace") && !m_old_props.value("force_colorspace").isEmpty()) {
774         props["force_colorspace"].clear();
775         m_clipNeedsRefresh = true;
776     }
777
778     if (m_view.clip_full_luma->isChecked()) {
779         props["full_luma"] = QString::number(1);
780         m_clipNeedsRefresh = true;
781     } else if (m_old_props.contains("full_luma") && !m_old_props.value("full_luma").isEmpty()) {
782         props["full_luma"].clear();
783         m_clipNeedsRefresh = true;
784     }
785     
786     if (m_view.clip_force_transparency->isChecked()) {
787         QString transp = QString::number(m_view.clip_transparency->currentIndex());
788         if (transp != m_old_props.value("transparency")) props["transparency"] = transp;
789     }
790
791     // If we adjust several clips, return now
792     if (m_clip == NULL) {
793         if (m_view.clip_out->isEnabled()) {
794             int duration = m_tc.getFrameCount(m_view.clip_out->text());
795             if (duration != m_old_props.value("out").toInt()) {
796                 props["out"] = QString::number(duration - 1);
797             }
798         }
799         return props;
800     }
801
802     if (m_old_props.value("description") != m_view.clip_description->text())
803         props["description"] = m_view.clip_description->text();
804
805     if (t == COLOR) {
806         QString new_color = m_view.clip_color->color().name();
807         if (new_color != QString('#' + m_old_props.value("colour").right(8).left(6))) {
808             m_clipNeedsRefresh = true;
809             props["colour"] = "0x" + new_color.right(6) + "ff";
810         }
811         int duration = m_tc.getFrameCount(m_view.clip_duration->text());
812         if (duration != m_clip->duration().frames(m_fps)) {
813             props["out"] = QString::number(duration - 1);
814         }
815     } else if (t == IMAGE) {
816         if ((int) m_view.image_transparency->isChecked() != m_old_props.value("transparency").toInt()) {
817             props["transparency"] = QString::number((int)m_view.image_transparency->isChecked());
818             //m_clipNeedsRefresh = true;
819         }
820         int duration = m_tc.getFrameCount(m_view.clip_duration->text());
821         if (duration != m_clip->duration().frames(m_fps)) {
822             props["out"] = QString::number(duration - 1);
823         }
824     } else if (t == SLIDESHOW) {
825         QString value = QString::number((int) m_view.slide_loop->isChecked());
826         if (m_old_props.value("loop") != value) props["loop"] = value;
827         value = QString::number((int) m_view.slide_crop->isChecked());
828         if (m_old_props.value("crop") != value) props["crop"] = value;
829         value = QString::number((int) m_view.slide_fade->isChecked());
830         if (m_old_props.value("fade") != value) props["fade"] = value;
831         value = QString::number((int) m_view.luma_softness->value());
832         if (m_old_props.value("softness") != value) props["softness"] = value;
833
834         bool isMime = !(m_view.clip_path->text().contains('%'));
835         if (isMime) {
836             QString extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
837             QString new_path = m_view.clip_path->text() + extension;
838             if (new_path != m_old_props.value("resource")) {
839                 m_clipNeedsReLoad = true;
840                 props["resource"] = new_path;
841                 kDebug() << "////  SLIDE EDIT, NEW:" << new_path << ", OLD; " << m_old_props.value("resource");
842             }
843         }
844         int duration;
845         if (m_view.slide_duration_format->currentIndex() == 1) {
846             // we are in frames mode
847             duration = m_view.slide_duration_frames->value();
848         } else duration = m_tc.getFrameCount(m_view.slide_duration->text());
849         if (duration != m_old_props.value("ttl").toInt()) {
850             m_clipNeedsRefresh = true;
851             props["ttl"] = QString::number(duration);
852             props["length"] = QString::number(duration * m_count);
853         }
854
855         if (duration * m_count - 1 != m_old_props.value("out").toInt()) {
856             m_clipNeedsRefresh = true;
857             props["out"] = QString::number(duration * m_count - 1);
858         }
859         if (m_view.slide_fade->isChecked()) {
860             int luma_duration;
861             if (m_view.slide_duration_format->currentIndex() == 1) {
862                 // we are in frames mode
863                 luma_duration = m_view.luma_duration_frames->value();
864             } else luma_duration = m_tc.getFrameCount(m_view.luma_duration->text());
865             if (luma_duration != m_old_props.value("luma_duration").toInt()) {
866                 m_clipNeedsRefresh = true;
867                 props["luma_duration"] = QString::number(luma_duration);
868             }
869             QString lumaFile;
870             if (m_view.slide_luma->isChecked())
871                 lumaFile = m_view.luma_file->itemData(m_view.luma_file->currentIndex()).toString();
872             if (lumaFile != m_old_props.value("luma_file")) {
873                 m_clipNeedsRefresh = true;
874                 props["luma_file"] = lumaFile;
875             }
876         } else {
877             if (!m_old_props.value("luma_file").isEmpty()) {
878                 props["luma_file"].clear();
879             }
880         }
881
882         QString animation = m_view.animation->itemData(m_view.animation->currentIndex()).toString();
883         if (animation != m_old_props.value("animation")) {
884             if (animation.isEmpty()) {
885                 props["animation"].clear();
886             } else {
887                 props["animation"] = animation;
888             }
889             m_clipNeedsRefresh = true;
890         }
891     }
892     return props;
893 }
894
895 bool ClipProperties::needsTimelineRefresh() const
896 {
897     return m_clipNeedsRefresh;
898 }
899
900 bool ClipProperties::needsTimelineReload() const
901 {
902     return m_clipNeedsReLoad;
903 }
904
905
906 void ClipProperties::parseFolder()
907 {
908     QString path = m_view.clip_path->text();
909     bool isMime = !(path.contains('%'));
910     if (!isMime) path = KUrl(path).directory();
911     QDir dir(path);
912
913     QStringList filters;
914     QString extension;
915
916     if (isMime) {
917         // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
918         filters << "*." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
919         extension = "/.all." + m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
920         dir.setNameFilters(filters);
921     }
922
923     QStringList result = dir.entryList(QDir::Files);
924
925     if (!isMime) {
926         // find pattern
927         QString filter = KUrl(m_view.clip_path->text()).fileName();
928         QString ext = filter.section('.', -1);
929         filter = filter.section('%', 0, -2);
930         QString regexp = "^" + filter + "\\d+\\." + ext + "$";
931         QRegExp rx(regexp);
932         QStringList entries;
933         foreach(const QString & path, result) {
934             if (rx.exactMatch(path)) entries << path;
935         }
936         result = entries;
937     }
938
939     m_count = result.count();
940     m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(m_count > 0);
941     if (m_count == 0) {
942         // no images, do not accept that
943         m_view.slide_info->setText(i18n("No image found"));
944         m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
945         return;
946     }
947     m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
948     m_view.slide_info->setText(i18np("1 image found", "%1 images found", m_count));
949     QDomElement xml = m_clip->toXML();
950     xml.setAttribute("resource", m_view.clip_path->text() + extension);
951     int width = 180.0 * KdenliveSettings::project_display_ratio();
952     if (width % 2 == 1) width++;
953     QString filePath = m_view.clip_path->text();
954     if (isMime) filePath.append(extension);
955     QPixmap pix = m_clip->thumbProducer()->getImage(KUrl(filePath), 1, width, 180);
956     QMap <QString, QString> props = m_clip->properties();
957     m_view.clip_duration->setText(m_tc.getTimecodeFromFrames(props.value("ttl").toInt() * m_count));
958     m_view.clip_thumb->setPixmap(pix);
959 }
960
961 void ClipProperties::slotCheckMaxLength()
962 {
963     if (m_clip->maxDuration() == GenTime()) return;
964     int duration = m_tc.getFrameCount(m_view.clip_duration->text());
965     if (duration > m_clip->maxDuration().frames(m_fps)) {
966         m_view.clip_duration->setText(m_tc.getTimecode(m_clip->maxDuration()));
967     }
968 }
969
970 void ClipProperties::slotUpdateDurationFormat(int ix)
971 {
972     bool framesFormat = ix == 1;
973     if (framesFormat) {
974         // switching to frames count, update widget
975         m_view.slide_duration_frames->setValue(m_tc.getFrameCount(m_view.slide_duration->text()));
976         m_view.luma_duration_frames->setValue(m_tc.getFrameCount(m_view.luma_duration->text()));
977         m_view.slide_duration->setHidden(true);
978         m_view.luma_duration->setHidden(true);
979         m_view.slide_duration_frames->setHidden(false);
980         m_view.luma_duration_frames->setHidden(false);
981     } else {
982         // switching to timecode format
983         m_view.slide_duration->setText(m_tc.getTimecodeFromFrames(m_view.slide_duration_frames->value()));
984         m_view.luma_duration->setText(m_tc.getTimecodeFromFrames(m_view.luma_duration_frames->value()));
985         m_view.slide_duration_frames->setHidden(true);
986         m_view.luma_duration_frames->setHidden(true);
987         m_view.slide_duration->setHidden(false);
988         m_view.luma_duration->setHidden(false);
989     }
990 }
991
992 #include "clipproperties.moc"
993
994
995