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