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