]> git.sesse.net Git - kdenlive/blob - src/dvdwizardvob.cpp
Fix label
[kdenlive] / src / dvdwizardvob.cpp
1 /***************************************************************************
2  *   Copyright (C) 2009 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 #include "dvdwizardvob.h"
21 #include "kthumb.h"
22 #include "timecode.h"
23 #include "cliptranscode.h"
24
25 #include <mlt++/Mlt.h>
26
27 #include <KUrlRequester>
28 #include <KDebug>
29 #include <KStandardDirs>
30 #include <KFileItem>
31 #include <KFileDialog>
32
33 #include <QHBoxLayout>
34 #include <QDomDocument>
35 #include <QTreeWidgetItem>
36 #include <QHeaderView>
37 #include <unistd.h>
38
39 DvdTreeWidget::DvdTreeWidget(QWidget *parent) :
40     QTreeWidget(parent)
41 {
42     setAcceptDrops(true);
43 }
44
45 void DvdTreeWidget::dragEnterEvent(QDragEnterEvent * event ) {
46     if (event->mimeData()->hasUrls()) {
47         event->setDropAction(Qt::CopyAction);
48         event->setAccepted(true);
49     }
50     else QTreeWidget::dragEnterEvent(event);
51 }
52
53 void DvdTreeWidget::dragMoveEvent(QDragMoveEvent * event) {
54     event->acceptProposedAction();
55 }
56
57 void DvdTreeWidget::mouseDoubleClickEvent( QMouseEvent * )
58 {
59     emit addNewClip();
60 }
61
62 void DvdTreeWidget::dropEvent(QDropEvent * event ) {
63     QList<QUrl> clips = event->mimeData()->urls();
64     event->accept();
65     emit addClips(clips);
66 }
67
68 DvdWizardVob::DvdWizardVob(QWidget *parent) :
69     QWizardPage(parent),
70     m_installCheck(true)
71 {
72     m_view.setupUi(this);
73     m_view.button_add->setIcon(KIcon("list-add"));
74     m_view.button_delete->setIcon(KIcon("list-remove"));
75     m_view.button_up->setIcon(KIcon("go-up"));
76     m_view.button_down->setIcon(KIcon("go-down"));
77     m_vobList = new DvdTreeWidget(this);
78     QVBoxLayout *lay1 = new QVBoxLayout;
79     lay1->addWidget(m_vobList);
80     m_view.list_frame->setLayout(lay1);
81     m_vobList->setColumnCount(3);
82     m_vobList->setHeaderHidden(true);
83
84     connect(m_vobList, SIGNAL(addClips(QList<QUrl>)), this, SLOT(slotAddVobList(QList<QUrl>)));
85     connect(m_vobList, SIGNAL(addNewClip()), this, SLOT(slotAddVobFile()));
86     connect(m_view.button_add, SIGNAL(clicked()), this, SLOT(slotAddVobFile()));
87     connect(m_view.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteVobFile()));
88     connect(m_view.button_up, SIGNAL(clicked()), this, SLOT(slotItemUp()));
89     connect(m_view.button_down, SIGNAL(clicked()), this, SLOT(slotItemDown()));
90     connect(m_vobList, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckVobList()));
91     
92     m_vobList->setIconSize(QSize(60, 45));
93
94     QString errorMessage;
95     if (KStandardDirs::findExe("dvdauthor").isEmpty()) errorMessage.append(i18n("<strong>Program %1 is required for the DVD wizard.</strong>", i18n("dvdauthor")));
96     if (KStandardDirs::findExe("mkisofs").isEmpty() && KStandardDirs::findExe("genisoimage").isEmpty()) errorMessage.append(i18n("<strong>Program %1 or %2 is required for the DVD wizard.</strong>", i18n("mkisofs"), i18n("genisoimage")));
97     if (!errorMessage.isEmpty()) {
98         m_view.button_add->setEnabled(false);
99         m_view.dvd_profile->setEnabled(false);
100     }
101
102     m_view.dvd_profile->addItems(QStringList() << i18n("PAL 4:3") << i18n("PAL 16:9") << i18n("NTSC 4:3") << i18n("NTSC 16:9"));
103
104     connect(m_view.dvd_profile, SIGNAL(activated(int)), this, SLOT(slotCheckProfiles()));
105     m_vobList->header()->setStretchLastSection(false);
106     m_vobList->header()->setResizeMode(0, QHeaderView::Stretch);
107     m_vobList->header()->setResizeMode(1, QHeaderView::Custom);
108     m_vobList->header()->setResizeMode(2, QHeaderView::Custom);
109
110     m_capacityBar = new KCapacityBar(KCapacityBar::DrawTextInline, this);
111     QHBoxLayout *lay = new QHBoxLayout;
112     lay->addWidget(m_capacityBar);
113     m_view.size_box->setLayout(lay);
114
115     m_vobList->setItemDelegate(new DvdViewDelegate(m_vobList));
116     m_transcodeAction = new QAction(i18n("Transcode"), this);
117     connect(m_transcodeAction, SIGNAL(triggered()), this, SLOT(slotTranscodeFiles()));
118
119 #if KDE_IS_VERSION(4,7,0)
120     m_warnMessage = new KMessageWidget;
121     m_warnMessage->setCloseButtonVisible(false);
122     QGridLayout *s =  static_cast <QGridLayout*> (layout());
123     s->addWidget(m_warnMessage, 2, 0, 1, -1);
124     if (!errorMessage.isEmpty()) {
125         m_warnMessage->setMessageType(KMessageWidget::Error);
126         m_warnMessage->setText(errorMessage);
127         m_installCheck = false;
128     }else {
129         m_warnMessage->setMessageType(KMessageWidget::Warning);
130         m_warnMessage->setText(i18n("Your clips do not match selected DVD format, transcoding required."));
131         m_warnMessage->addAction(m_transcodeAction);
132         m_warnMessage->hide();
133     }
134     m_view.button_transcode->setHidden(true);
135 #else
136     m_view.button_transcode->setDefaultAction(m_transcodeAction);
137     m_view.button_transcode->setEnabled(false);
138     if (!errorMessage.isEmpty()) {
139         m_view.error_message->setText(errorMessage);
140         m_installCheck = false;
141     }
142 #endif
143     
144     slotCheckVobList();
145 }
146
147 DvdWizardVob::~DvdWizardVob()
148 {
149     delete m_capacityBar;
150 }
151
152 void DvdWizardVob::slotCheckProfiles()
153 {
154     bool conflict = false;
155     int comboProfile = m_view.dvd_profile->currentIndex();
156     for (int i = 0; i < m_vobList->topLevelItemCount(); ++i) {
157         QTreeWidgetItem *item = m_vobList->topLevelItem(i);
158         if (item->data(0, Qt::UserRole + 1).toInt() != comboProfile) {
159             conflict = true;
160             break;
161         }
162     }
163     m_transcodeAction->setEnabled(conflict);
164     if (conflict) {
165         showProfileError();
166     }
167     else {
168 #if KDE_IS_VERSION(4,7,0)      
169         m_warnMessage->animatedHide();
170 #else
171         if (m_installCheck) m_view.error_message->setVisible(false);
172 #endif
173     }
174 }
175
176 void DvdWizardVob::slotAddVobList(const QList<QUrl> &list)
177 {
178     foreach (const QUrl &url, list) {
179         slotAddVobFile(KUrl(url), QString(), false);
180     }
181     slotCheckVobList();
182     slotCheckProfiles();
183 }
184
185 void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters, bool checkFormats)
186 {
187     if (url.isEmpty()) url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), "video/mpeg", this, i18n("Add new video file"));
188     if (url.isEmpty()) return;
189     QFile f(url.path());
190     qint64 fileSize = f.size();
191
192     Mlt::Profile profile;
193     profile.set_explicit(false);
194     QTreeWidgetItem *item = new QTreeWidgetItem(m_vobList, QStringList() << url.path() << QString() << KIO::convertSize(fileSize));
195     item->setData(2, Qt::UserRole, fileSize);
196     item->setData(0, Qt::DecorationRole, KIcon("video-x-generic").pixmap(60, 45));
197     item->setToolTip(0, url.path());
198
199     QString resource = url.path();
200     resource.prepend("avformat:");
201     Mlt::Producer *producer = new Mlt::Producer(profile, resource.toUtf8().data());
202     if (producer && producer->is_valid() && !producer->is_blank()) {
203         //Mlt::Frame *frame = producer->get_frame();
204         //delete frame;
205         profile.from_producer(*producer);
206         int width = 45.0 * profile.dar();
207         int swidth = 45.0 * profile.width() / profile.height();
208         if (width % 2 == 1) width++;
209         item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, swidth, width, 45)));
210         int playTime = producer->get_playtime();
211         item->setText(1, Timecode::getStringTimecode(playTime, profile.fps()));
212         item->setData(1, Qt::UserRole, playTime);
213         int standard = -1;
214         int aspect = profile.dar() * 100;
215         if (profile.height() == 576 && profile.fps() == 25.0) {
216             if (aspect > 150) standard = 1;
217             else standard = 0;
218         }
219         else if (profile.height() == 480 && qAbs(profile.fps() - 30000.0 / 1001) < 0.2) {
220             if (aspect > 150) standard = 3;
221             else standard = 2;
222         }
223         QString standardName;
224         switch (standard) {
225         case 3:
226             standardName = i18n("NTSC 16:9");
227             break;
228         case 2:
229             standardName = i18n("NTSC 4:3");
230             break;
231         case 1:
232             standardName = i18n("PAL 16:9");
233             break;
234         case 0:
235             standardName = i18n("PAL 4:3");
236             break;
237         default:
238             standardName = i18n("Unknown");
239         }
240         standardName.append(QString(" | %1x%2, %3fps").arg(profile.width()).arg(profile.height()).arg(profile.fps()));
241         item->setData(0, Qt::UserRole, standardName);
242         item->setData(0, Qt::UserRole + 1, standard);
243         item->setData(0, Qt::UserRole + 2, QSize(profile.dar() * profile.height(), profile.height()));
244         if (m_vobList->topLevelItemCount() == 1) {
245             // This is the first added movie, auto select DVD format
246             if (standard >= 0) {
247                 m_view.dvd_profile->blockSignals(true);
248                 m_view.dvd_profile->setCurrentIndex(standard);
249                 m_view.dvd_profile->blockSignals(false);
250             }
251         }
252
253     }
254     else {
255         // Cannot load movie, reject
256         showError(i18n("The clip %1 is invalid.", url.fileName()));
257     }
258     if (producer) delete producer;
259
260     if (chapters.isEmpty() == false) {
261         item->setData(1, Qt::UserRole + 1, chapters);
262     }
263     else if (QFile::exists(url.path() + ".dvdchapter")) {
264         // insert chapters as children
265         QFile file(url.path() + ".dvdchapter");
266         if (file.open(QIODevice::ReadOnly)) {
267             QDomDocument doc;
268             if (doc.setContent(&file) == false) {
269                 file.close();
270                 return;
271             }
272             file.close();
273             QDomNodeList chapters = doc.elementsByTagName("chapter");
274             QStringList chaptersList;
275             for (int j = 0; j < chapters.count(); j++) {
276                 chaptersList.append(QString::number(chapters.at(j).toElement().attribute("time").toInt()));
277             }
278             item->setData(1, Qt::UserRole + 1, chaptersList.join(";"));
279         }
280     } else // Explicitly add a chapter at 00:00:00:00
281         item->setData(1, Qt::UserRole + 1, "0");
282
283     if (checkFormats) {
284         slotCheckVobList();
285         slotCheckProfiles();
286     }
287     emit prepareMonitor();
288 }
289
290 void DvdWizardVob::slotDeleteVobFile()
291 {
292     QTreeWidgetItem *item = m_vobList->currentItem();
293     if (item == NULL) return;
294     delete item;
295     slotCheckVobList();
296     slotCheckProfiles();
297 }
298
299
300 // virtual
301 bool DvdWizardVob::isComplete() const
302 {
303     if (!m_installCheck) return false;
304     if (m_vobList->topLevelItemCount() == 0) return false;
305     return true;
306 }
307
308 void DvdWizardVob::setUrl(const QString &url)
309 {
310     slotAddVobFile(KUrl(url));
311 }
312
313 QStringList DvdWizardVob::selectedUrls() const
314 {
315     QStringList result;
316     QString path;
317     int max = m_vobList->topLevelItemCount();
318     int i = 0;
319     if (m_view.use_intro->isChecked()) {
320         // First movie is only for intro
321         i = 1;
322     }
323     for (; i < max; ++i) {
324         QTreeWidgetItem *item = m_vobList->topLevelItem(i);
325         if (item) result.append(item->text(0));
326     }
327     return result;
328 }
329
330
331 QStringList DvdWizardVob::durations() const
332 {
333     QStringList result;
334     QString path;
335     int max = m_vobList->topLevelItemCount();
336     int i = 0;
337     if (m_view.use_intro->isChecked()) {
338         // First movie is only for intro
339         i = 1;
340     }
341     for (; i < max; ++i) {
342         QTreeWidgetItem *item = m_vobList->topLevelItem(i);
343         if (item) result.append(QString::number(item->data(1, Qt::UserRole).toInt()));
344     }
345     return result;
346 }
347
348 QStringList DvdWizardVob::chapters() const
349 {
350     QStringList result;
351     QString path;
352     int max = m_vobList->topLevelItemCount();
353     int i = 0;
354     if (m_view.use_intro->isChecked()) {
355         // First movie is only for intro
356         i = 1;
357     }
358     for (; i < max; ++i) {
359         QTreeWidgetItem *item = m_vobList->topLevelItem(i);
360         if (item) {
361             result.append(item->data(1, Qt::UserRole + 1).toString());
362         }
363     }
364     return result;
365 }
366
367 void DvdWizardVob::updateChapters(const QMap <QString, QString> &chaptersdata)
368 {
369     int max = m_vobList->topLevelItemCount();
370     int i = 0;
371     if (m_view.use_intro->isChecked()) {
372         // First movie is only for intro
373         i = 1;
374     }
375     for (; i < max; ++i) {
376         QTreeWidgetItem *item = m_vobList->topLevelItem(i);
377         if (chaptersdata.contains(item->text(0)))
378             item->setData(1, Qt::UserRole + 1, chaptersdata.value(item->text(0)));
379     }
380 }
381
382 int DvdWizardVob::duration(int ix) const
383 {
384     int result = -1;
385     QTreeWidgetItem *item = m_vobList->topLevelItem(ix);
386     if (item) {
387         result = item->data(1, Qt::UserRole).toInt();
388     }
389     return result;
390 }
391
392 const QString DvdWizardVob::introMovie() const
393 {
394     QString url;
395     if (m_view.use_intro->isChecked() && m_vobList->topLevelItemCount() > 0)
396         url = m_vobList->topLevelItem(0)->text(0);
397     return url;
398 }
399
400 void DvdWizardVob::setUseIntroMovie(bool use)
401 {
402     m_view.use_intro->setChecked(use);
403 }
404
405 void DvdWizardVob::slotCheckVobList()
406 {
407     emit completeChanged();
408     int max = m_vobList->topLevelItemCount();
409     QTreeWidgetItem *item = m_vobList->currentItem();
410     bool hasItem = true;
411     if (item == NULL) hasItem = false;
412     m_view.button_delete->setEnabled(hasItem);
413     if (hasItem && m_vobList->indexOfTopLevelItem(item) == 0) m_view.button_up->setEnabled(false);
414     else m_view.button_up->setEnabled(hasItem);
415     if (hasItem && m_vobList->indexOfTopLevelItem(item) == max - 1) m_view.button_down->setEnabled(false);
416     else m_view.button_down->setEnabled(hasItem);
417
418     qint64 totalSize = 0;
419     for (int i = 0; i < max; ++i) {
420         item = m_vobList->topLevelItem(i);
421         if (item)
422             totalSize += (qint64) item->data(2, Qt::UserRole).toInt();
423     }
424
425     qint64 maxSize = (qint64) 47000 * 100000;
426     m_capacityBar->setValue(100 * totalSize / maxSize);
427     m_capacityBar->setText(KIO::convertSize(totalSize));
428 }
429
430 void DvdWizardVob::slotItemUp()
431 {
432     QTreeWidgetItem *item = m_vobList->currentItem();
433     if (item == NULL) return;
434     int index = m_vobList->indexOfTopLevelItem(item);
435     if (index == 0) return;
436     m_vobList->insertTopLevelItem(index - 1, m_vobList->takeTopLevelItem(index));
437 }
438
439 void DvdWizardVob::slotItemDown()
440 {
441     int max = m_vobList->topLevelItemCount();
442     QTreeWidgetItem *item = m_vobList->currentItem();
443     if (item == NULL)
444         return;
445     int index = m_vobList->indexOfTopLevelItem(item);
446     if (index == max - 1)
447         return;
448     m_vobList->insertTopLevelItem(index + 1, m_vobList->takeTopLevelItem(index));
449 }
450
451 DVDFORMAT DvdWizardVob::dvdFormat() const
452 {
453     return (DVDFORMAT) m_view.dvd_profile->currentIndex();
454 }
455
456 const QString DvdWizardVob::dvdProfile() const
457 {
458     QString profile;
459     switch (m_view.dvd_profile->currentIndex()) {
460     case PAL_WIDE:
461         profile = "dv_pal_wide";
462         break;
463     case NTSC:
464         profile = "dv_ntsc";
465         break;
466     case NTSC_WIDE:
467         profile = "dv_ntsc_wide";
468         break;
469     default:
470         profile = "dv_pal";
471     }
472     return profile;
473 }
474
475 //static
476 QString DvdWizardVob::getDvdProfile(DVDFORMAT format)
477 {
478     QString profile;
479     switch (format) {
480     case PAL_WIDE:
481         profile = "dv_pal_wide";
482         break;
483     case NTSC:
484         profile = "dv_ntsc";
485         break;
486     case NTSC_WIDE:
487         profile = "dv_ntsc_wide";
488         break;
489     default:
490         profile = "dv_pal";
491     }
492     return profile;
493 }
494
495 void DvdWizardVob::setProfile(const QString& profile)
496 {
497     if (profile == "dv_pal_wide")
498         m_view.dvd_profile->setCurrentIndex(PAL_WIDE);
499     else if (profile == "dv_ntsc")
500         m_view.dvd_profile->setCurrentIndex(NTSC);
501     else if (profile == "dv_ntsc_wide")
502         m_view.dvd_profile->setCurrentIndex(NTSC_WIDE);
503     else
504         m_view.dvd_profile->setCurrentIndex(PAL);
505 }
506
507 void DvdWizardVob::clear()
508 {
509     m_vobList->clear();
510 }
511
512 void DvdWizardVob::slotTranscodeFiles()
513 {
514     // Find transcoding infos related to selected DVD profile
515     KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc", KConfig::CascadeConfig);
516     KConfigGroup transConfig(config, "Transcoding");
517     // read the entries
518     QString profileEasyName;
519     QSize destSize;
520     QSize finalSize;
521     switch (m_view.dvd_profile->currentIndex()) {
522     case PAL_WIDE:
523         profileEasyName = "DVD PAL 16:9";
524         destSize = QSize(1024, 576);
525         finalSize = QSize(720, 576);
526         break;
527     case NTSC:
528         profileEasyName = "DVD NTSC 4:3";
529         destSize = QSize(640, 480);
530         finalSize = QSize(720, 480);
531         break;
532     case NTSC_WIDE:
533         profileEasyName = "DVD NTSC 16:9";
534         destSize = QSize(853, 480);
535         finalSize = QSize(720, 480);
536         break;
537     default:
538         profileEasyName = "DVD PAL 4:3";
539         destSize = QSize(768, 576);
540         finalSize = QSize(720, 576);
541     }
542     QString params = transConfig.readEntry(profileEasyName);
543
544     // Transcode files that do not match selected profile
545     int max = m_vobList->topLevelItemCount();
546     int format = m_view.dvd_profile->currentIndex();
547     for (int i = 0; i < max; ++i) {
548         QTreeWidgetItem *item = m_vobList->topLevelItem(i);
549         if (item->data(0, Qt::UserRole + 1).toInt() != format) {
550             // File needs to be transcoded
551             m_transcodeAction->setEnabled(false);
552             QSize original = item->data(0, Qt::UserRole + 2).toSize();
553             double input_aspect= (double) original.width() / original.height();
554             QStringList postParams;
555             if (input_aspect > (double) destSize.width() / destSize.height()) {
556                 // letterboxing
557                 int conv_height = (int) (destSize.width() / input_aspect);
558                 int conv_pad = (int) (((double) (destSize.height() - conv_height)) / 2.0);
559                 if (conv_pad %2 == 1) conv_pad --;
560                 postParams << "-vf" << QString("scale=%1:%2,pad=%3:%4:0:%5,setdar=%6").arg(finalSize.width()).arg(destSize.height() - 2 * conv_pad).arg(finalSize.width()).arg(finalSize.height()).arg(conv_pad).arg(input_aspect);
561             } else {
562                 // pillarboxing
563                 int conv_width = (int) (destSize.height() * input_aspect);
564                 int conv_pad = (int) (((double) (destSize.width() - conv_width)) / destSize.width() * finalSize.width() / 2.0);
565                 if (conv_pad %2 == 1) conv_pad --;
566                 postParams << "-vf" << QString("scale=%1:%2,pad=%3:%4:%5:0,setdar=%6").arg(finalSize.width() - 2 * conv_pad).arg(destSize.height()).arg(finalSize.width()).arg(finalSize.height()).arg(conv_pad).arg(input_aspect);
567             }
568             ClipTranscode *d = new ClipTranscode(KUrl::List () << KUrl(item->text(0)), params.section(';', 0, 0), postParams, i18n("Transcoding to DVD format"), true, this);
569             connect(d, SIGNAL(transcodedClip(KUrl,KUrl)), this, SLOT(slotTranscodedClip(KUrl,KUrl)));
570             d->slotStartTransCode();
571             d->show();
572
573         }
574     }
575 }
576
577 void DvdWizardVob::slotTranscodedClip(KUrl src, KUrl transcoded)
578 {
579     if (transcoded.isEmpty()) {
580         // Transcoding canceled or failed
581         m_transcodeAction->setEnabled(true);
582         return;
583     }
584     int max = m_vobList->topLevelItemCount();
585     for (int i = 0; i < max; ++i) {
586         QTreeWidgetItem *item = m_vobList->topLevelItem(i);
587         if (KUrl(item->text(0)).path() == src.path()) {
588             // Replace movie with transcoded version
589             item->setText(0, transcoded.path());
590
591             QFile f(transcoded.path());
592             qint64 fileSize = f.size();
593
594             Mlt::Profile profile;
595             profile.set_explicit(false);
596             item->setText(2, KIO::convertSize(fileSize));
597             item->setData(2, Qt::UserRole, fileSize);
598             item->setData(0, Qt::DecorationRole, KIcon("video-x-generic").pixmap(60, 45));
599             item->setToolTip(0, transcoded.path());
600
601             QString resource = transcoded.path();
602             resource.prepend("avformat:");
603             Mlt::Producer *producer = new Mlt::Producer(profile, resource.toUtf8().data());
604             if (producer && producer->is_valid() && !producer->is_blank()) {
605                 profile.from_producer(*producer);
606                 int width = 45.0 * profile.dar();
607                 int swidth = 45.0 * profile.width() / profile.height();
608                 if (width % 2 == 1) width++;
609                 item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, swidth, width, 45)));
610                 int playTime = producer->get_playtime();
611                 item->setText(1, Timecode::getStringTimecode(playTime, profile.fps()));
612                 item->setData(1, Qt::UserRole, playTime);
613                 int standard = -1;
614                 int aspect = profile.dar() * 100;
615                 if (profile.height() == 576) {
616                     if (aspect > 150) standard = 1;
617                     else standard = 0;
618                 }
619                 else if (profile.height() == 480) {
620                     if (aspect > 150) standard = 3;
621                     else standard = 2;
622                 }
623                 QString standardName;
624                 switch (standard) {
625                 case 3:
626                     standardName = i18n("NTSC 16:9");
627                     break;
628                 case 2:
629                     standardName = i18n("NTSC 4:3");
630                     break;
631                 case 1:
632                     standardName = i18n("PAL 16:9");
633                     break;
634                 case 0:
635                     standardName = i18n("PAL 4:3");
636                     break;
637                 default:
638                     standardName = i18n("Unknown");
639                 }
640                 item->setData(0, Qt::UserRole, standardName);
641                 item->setData(0, Qt::UserRole + 1, standard);
642                 item->setData(0, Qt::UserRole + 2, QSize(profile.dar() * profile.height(), profile.height()));
643             }
644             else {
645                 // Cannot load movie, reject
646                 showError(i18n("The clip %1 is invalid.", transcoded.fileName()));
647             }
648             if (producer) delete producer;
649             slotCheckVobList();
650             slotCheckProfiles();
651             break;
652         }
653     }
654 }
655
656 void DvdWizardVob::showProfileError()
657 {
658 #if KDE_IS_VERSION(4,7,0)
659     m_warnMessage->setText(i18n("Your clips do not match selected DVD format, transcoding required."));
660     m_warnMessage->setCloseButtonVisible(false);
661     m_warnMessage->addAction(m_transcodeAction);
662     m_warnMessage->animatedShow();
663 #else
664     m_view.error_message->setText(i18n("Your clips do not match selected DVD format, transcoding required."));
665     m_view.error_message->setVisible(true);
666 #endif
667 }
668
669 void DvdWizardVob::showError(const QString &error)
670 {
671 #if KDE_IS_VERSION(4,7,0)
672     m_warnMessage->setText(error);
673     m_warnMessage->setCloseButtonVisible(true);
674     m_warnMessage->removeAction(m_transcodeAction);
675     m_warnMessage->animatedShow();
676 #else
677     m_view.error_message->setText(error);
678     m_view.error_message->setVisible(true);
679 #endif    
680 }
681
682
683 #include "dvdwizardvob.moc"