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