X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdvdwizardvob.cpp;h=76e87920b56b130f2cd58ebf2141636357f21af0;hb=4f9bd66f4c236423b440b10ae1e543d162cec0ed;hp=dc268ab866c0471b07dc032884e9f866fce8fac7;hpb=21e141ba0746dc1cc11111d639cc2812c88f4c7e;p=kdenlive diff --git a/src/dvdwizardvob.cpp b/src/dvdwizardvob.cpp index dc268ab8..76e87920 100644 --- a/src/dvdwizardvob.cpp +++ b/src/dvdwizardvob.cpp @@ -34,23 +34,24 @@ #include #include #include +#include DvdTreeWidget::DvdTreeWidget(QWidget *parent) : - QTreeWidget(parent) + QTreeWidget(parent) { setAcceptDrops(true); } void DvdTreeWidget::dragEnterEvent(QDragEnterEvent * event ) { if (event->mimeData()->hasUrls()) { - event->setDropAction(Qt::CopyAction); - event->setAccepted(true); + event->setDropAction(Qt::CopyAction); + event->setAccepted(true); } else QTreeWidget::dragEnterEvent(event); } void DvdTreeWidget::dragMoveEvent(QDragMoveEvent * event) { - event->acceptProposedAction(); + event->acceptProposedAction(); } void DvdTreeWidget::mouseDoubleClickEvent( QMouseEvent * ) @@ -65,8 +66,8 @@ void DvdTreeWidget::dropEvent(QDropEvent * event ) { } DvdWizardVob::DvdWizardVob(QWidget *parent) : - QWizardPage(parent), - m_installCheck(true) + QWizardPage(parent), + m_installCheck(true) { m_view.setupUi(this); m_view.button_add->setIcon(KIcon("list-add")); @@ -90,12 +91,12 @@ DvdWizardVob::DvdWizardVob(QWidget *parent) : m_vobList->setIconSize(QSize(60, 45)); - if (KStandardDirs::findExe("dvdauthor").isEmpty()) m_errorMessage.append(i18n("Program %1 is required for the DVD wizard.", i18n("dvdauthor"))); - if (KStandardDirs::findExe("mkisofs").isEmpty() && KStandardDirs::findExe("genisoimage").isEmpty()) m_errorMessage.append(i18n("Program %1 or %2 is required for the DVD wizard.", i18n("mkisofs"), i18n("genisoimage"))); - if (m_errorMessage.isEmpty()) m_view.error_message->setVisible(false); - else { - m_view.error_message->setText(m_errorMessage); - m_installCheck = false; + QString errorMessage; + if (KStandardDirs::findExe("dvdauthor").isEmpty()) errorMessage.append(i18n("Program %1 is required for the DVD wizard.", i18n("dvdauthor"))); + if (KStandardDirs::findExe("mkisofs").isEmpty() && KStandardDirs::findExe("genisoimage").isEmpty()) errorMessage.append(i18n("Program %1 or %2 is required for the DVD wizard.", i18n("mkisofs"), i18n("genisoimage"))); + if (!errorMessage.isEmpty()) { + m_view.button_add->setEnabled(false); + m_view.dvd_profile->setEnabled(false); } m_view.dvd_profile->addItems(QStringList() << i18n("PAL 4:3") << i18n("PAL 16:9") << i18n("NTSC 4:3") << i18n("NTSC 16:9")); @@ -117,17 +118,27 @@ DvdWizardVob::DvdWizardVob(QWidget *parent) : #if KDE_IS_VERSION(4,7,0) m_warnMessage = new KMessageWidget; - m_warnMessage->setMessageType(KMessageWidget::Warning); - m_warnMessage->setText(i18n("Your clips do not match selected DVD format, transcoding required.")); m_warnMessage->setCloseButtonVisible(false); - m_warnMessage->addAction(m_transcodeAction); QGridLayout *s = static_cast (layout()); - s->addWidget(m_warnMessage, 3, 0, 1, -1); - m_warnMessage->hide(); + s->addWidget(m_warnMessage, 2, 0, 1, -1); + if (!errorMessage.isEmpty()) { + m_warnMessage->setMessageType(KMessageWidget::Error); + m_warnMessage->setText(errorMessage); + m_installCheck = false; + }else { + m_warnMessage->setMessageType(KMessageWidget::Warning); + m_warnMessage->setText(i18n("Your clips do not match selected DVD format, transcoding required.")); + m_warnMessage->addAction(m_transcodeAction); + m_warnMessage->hide(); + } m_view.button_transcode->setHidden(true); #else m_view.button_transcode->setDefaultAction(m_transcodeAction); m_view.button_transcode->setEnabled(false); + if (!errorMessage.isEmpty()) { + m_view.error_message->setText(errorMessage); + m_installCheck = false; + } #endif slotCheckVobList(); @@ -142,30 +153,30 @@ void DvdWizardVob::slotCheckProfiles() { bool conflict = false; int comboProfile = m_view.dvd_profile->currentIndex(); - for (int i = 0; i < m_vobList->topLevelItemCount(); i++) { + for (int i = 0; i < m_vobList->topLevelItemCount(); ++i) { QTreeWidgetItem *item = m_vobList->topLevelItem(i); if (item->data(0, Qt::UserRole + 1).toInt() != comboProfile) { - conflict = true; - break; - } + conflict = true; + break; + } } m_transcodeAction->setEnabled(conflict); if (conflict) { - showProfileError(); + showProfileError(); } else { #if KDE_IS_VERSION(4,7,0) - m_warnMessage->animatedHide(); + m_warnMessage->animatedHide(); #else - if (m_installCheck) m_view.error_message->setVisible(false); + if (m_installCheck) m_view.error_message->setVisible(false); #endif } } -void DvdWizardVob::slotAddVobList(QList list) +void DvdWizardVob::slotAddVobList(const QList &list) { - foreach (const QUrl url, list) { - slotAddVobFile(KUrl(url), QString(), false); + foreach (const QUrl &url, list) { + slotAddVobFile(KUrl(url), QString(), false); } slotCheckVobList(); slotCheckProfiles(); @@ -189,59 +200,60 @@ void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters, bool checkF resource.prepend("avformat:"); Mlt::Producer *producer = new Mlt::Producer(profile, resource.toUtf8().data()); if (producer && producer->is_valid() && !producer->is_blank()) { - //Mlt::Frame *frame = producer->get_frame(); - //delete frame; - profile.from_producer(*producer); + //Mlt::Frame *frame = producer->get_frame(); + //delete frame; + profile.from_producer(*producer); int width = 45.0 * profile.dar(); int swidth = 45.0 * profile.width() / profile.height(); if (width % 2 == 1) width++; - item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, swidth, width, 45))); + item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, swidth, width, 45))); int playTime = producer->get_playtime(); item->setText(1, Timecode::getStringTimecode(playTime, profile.fps())); item->setData(1, Qt::UserRole, playTime); - int standard = -1; - int aspect = profile.dar() * 100; - if (profile.height() == 576) { - if (aspect > 150) standard = 1; - else standard = 0; - } - else if (profile.height() == 480) { - if (aspect > 150) standard = 3; - else standard = 2; - } - QString standardName; - switch (standard) { - case 3: - standardName = i18n("NTSC 16:9"); - break; - case 2: - standardName = i18n("NTSC 4:3"); - break; - case 1: - standardName = i18n("PAL 16:9"); - break; - case 0: - standardName = i18n("PAL 4:3"); - break; - default: - standardName = i18n("Unknown"); - } - item->setData(0, Qt::UserRole, standardName); - item->setData(0, Qt::UserRole + 1, standard); - item->setData(0, Qt::UserRole + 2, QSize(profile.dar() * profile.height(), profile.height())); - if (m_vobList->topLevelItemCount() == 1) { - // This is the first added movie, auto select DVD format - if (standard >= 0) { - m_view.dvd_profile->blockSignals(true); - m_view.dvd_profile->setCurrentIndex(standard); - m_view.dvd_profile->blockSignals(false); - } - } - + int standard = -1; + int aspect = profile.dar() * 100; + if (profile.height() == 576 && profile.fps() == 25.0) { + if (aspect > 150) standard = 1; + else standard = 0; + } + else if (profile.height() == 480 && qAbs(profile.fps() - 30000.0 / 1001) < 0.2) { + if (aspect > 150) standard = 3; + else standard = 2; + } + QString standardName; + switch (standard) { + case 3: + standardName = i18n("NTSC 16:9"); + break; + case 2: + standardName = i18n("NTSC 4:3"); + break; + case 1: + standardName = i18n("PAL 16:9"); + break; + case 0: + standardName = i18n("PAL 4:3"); + break; + default: + standardName = i18n("Unknown"); + } + standardName.append(QString(" | %1x%2, %3fps").arg(profile.width()).arg(profile.height()).arg(profile.fps())); + item->setData(0, Qt::UserRole, standardName); + item->setData(0, Qt::UserRole + 1, standard); + item->setData(0, Qt::UserRole + 2, QSize(profile.dar() * profile.height(), profile.height())); + if (m_vobList->topLevelItemCount() == 1) { + // This is the first added movie, auto select DVD format + if (standard >= 0) { + m_view.dvd_profile->blockSignals(true); + m_view.dvd_profile->setCurrentIndex(standard); + m_view.dvd_profile->blockSignals(false); + } + } + } else { - // Cannot load movie, reject - showError(i18n("The clip %1 is invalid.", url.fileName())); + // Cannot load movie, reject + showError(i18n("The clip %1 is invalid.", url.fileName())); } if (producer) delete producer; @@ -269,9 +281,10 @@ void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters, bool checkF item->setData(1, Qt::UserRole + 1, "0"); if (checkFormats) { - slotCheckVobList(); - slotCheckProfiles(); + slotCheckVobList(); + slotCheckProfiles(); } + emit prepareMonitor(); } void DvdWizardVob::slotDeleteVobFile() @@ -304,10 +317,10 @@ QStringList DvdWizardVob::selectedUrls() const int max = m_vobList->topLevelItemCount(); int i = 0; if (m_view.use_intro->isChecked()) { - // First movie is only for intro - i = 1; + // First movie is only for intro + i = 1; } - for (; i < max; i++) { + for (; i < max; ++i) { QTreeWidgetItem *item = m_vobList->topLevelItem(i); if (item) result.append(item->text(0)); } @@ -320,7 +333,12 @@ QStringList DvdWizardVob::durations() const QStringList result; QString path; int max = m_vobList->topLevelItemCount(); - for (int i = 0; i < max; i++) { + int i = 0; + if (m_view.use_intro->isChecked()) { + // First movie is only for intro + i = 1; + } + for (; i < max; ++i) { QTreeWidgetItem *item = m_vobList->topLevelItem(i); if (item) result.append(QString::number(item->data(1, Qt::UserRole).toInt())); } @@ -332,7 +350,12 @@ QStringList DvdWizardVob::chapters() const QStringList result; QString path; int max = m_vobList->topLevelItemCount(); - for (int i = 0; i < max; i++) { + int i = 0; + if (m_view.use_intro->isChecked()) { + // First movie is only for intro + i = 1; + } + for (; i < max; ++i) { QTreeWidgetItem *item = m_vobList->topLevelItem(i); if (item) { result.append(item->data(1, Qt::UserRole + 1).toString()); @@ -341,12 +364,18 @@ QStringList DvdWizardVob::chapters() const return result; } -void DvdWizardVob::updateChapters(QMap chaptersdata) +void DvdWizardVob::updateChapters(const QMap &chaptersdata) { int max = m_vobList->topLevelItemCount(); - for (int i = 0; i < max; i++) { + int i = 0; + if (m_view.use_intro->isChecked()) { + // First movie is only for intro + i = 1; + } + for (; i < max; ++i) { QTreeWidgetItem *item = m_vobList->topLevelItem(i); - if (chaptersdata.contains(item->text(0))) item->setData(1, Qt::UserRole + 1, chaptersdata.value(item->text(0))); + if (chaptersdata.contains(item->text(0))) + item->setData(1, Qt::UserRole + 1, chaptersdata.value(item->text(0))); } } @@ -363,7 +392,8 @@ int DvdWizardVob::duration(int ix) const const QString DvdWizardVob::introMovie() const { QString url; - if (m_view.use_intro->isChecked() && m_vobList->topLevelItemCount() > 0) url = m_vobList->topLevelItem(0)->text(0); + if (m_view.use_intro->isChecked() && m_vobList->topLevelItemCount() > 0) + url = m_vobList->topLevelItem(0)->text(0); return url; } @@ -386,9 +416,10 @@ void DvdWizardVob::slotCheckVobList() else m_view.button_down->setEnabled(hasItem); qint64 totalSize = 0; - for (int i = 0; i < max; i++) { + for (int i = 0; i < max; ++i) { item = m_vobList->topLevelItem(i); - if (item) totalSize += (qint64) item->data(2, Qt::UserRole).toInt(); + if (item) + totalSize += (qint64) item->data(2, Qt::UserRole).toInt(); } qint64 maxSize = (qint64) 47000 * 100000; @@ -409,9 +440,11 @@ void DvdWizardVob::slotItemDown() { int max = m_vobList->topLevelItemCount(); QTreeWidgetItem *item = m_vobList->currentItem(); - if (item == NULL) return; + if (item == NULL) + return; int index = m_vobList->indexOfTopLevelItem(item); - if (index == max - 1) return; + if (index == max - 1) + return; m_vobList->insertTopLevelItem(index + 1, m_vobList->takeTopLevelItem(index)); } @@ -424,17 +457,17 @@ const QString DvdWizardVob::dvdProfile() const { QString profile; switch (m_view.dvd_profile->currentIndex()) { - case PAL_WIDE: - profile = "dv_pal_wide"; - break; - case NTSC: - profile = "dv_ntsc"; - break; - case NTSC_WIDE: - profile = "dv_ntsc_wide"; - break; - default: - profile = "dv_pal"; + case PAL_WIDE: + profile = "dv_pal_wide"; + break; + case NTSC: + profile = "dv_ntsc"; + break; + case NTSC_WIDE: + profile = "dv_ntsc_wide"; + break; + default: + profile = "dv_pal"; } return profile; } @@ -444,27 +477,31 @@ QString DvdWizardVob::getDvdProfile(DVDFORMAT format) { QString profile; switch (format) { - case PAL_WIDE: - profile = "dv_pal_wide"; - break; - case NTSC: - profile = "dv_ntsc"; - break; - case NTSC_WIDE: - profile = "dv_ntsc_wide"; - break; - default: - profile = "dv_pal"; + case PAL_WIDE: + profile = "dv_pal_wide"; + break; + case NTSC: + profile = "dv_ntsc"; + break; + case NTSC_WIDE: + profile = "dv_ntsc_wide"; + break; + default: + profile = "dv_pal"; } return profile; } void DvdWizardVob::setProfile(const QString& profile) { - if (profile == "dv_pal_wide") m_view.dvd_profile->setCurrentIndex(PAL_WIDE); - else if (profile == "dv_ntsc") m_view.dvd_profile->setCurrentIndex(NTSC); - else if (profile == "dv_ntsc_wide") m_view.dvd_profile->setCurrentIndex(NTSC_WIDE); - else m_view.dvd_profile->setCurrentIndex(PAL); + if (profile == "dv_pal_wide") + m_view.dvd_profile->setCurrentIndex(PAL_WIDE); + else if (profile == "dv_ntsc") + m_view.dvd_profile->setCurrentIndex(NTSC); + else if (profile == "dv_ntsc_wide") + m_view.dvd_profile->setCurrentIndex(NTSC_WIDE); + else + m_view.dvd_profile->setCurrentIndex(PAL); } void DvdWizardVob::clear() @@ -475,137 +512,144 @@ void DvdWizardVob::clear() void DvdWizardVob::slotTranscodeFiles() { // Find transcoding infos related to selected DVD profile - KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc"); + KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc", KConfig::CascadeConfig); KConfigGroup transConfig(config, "Transcoding"); // read the entries QString profileEasyName; QSize destSize; QSize finalSize; switch (m_view.dvd_profile->currentIndex()) { - case PAL_WIDE: - profileEasyName = "DVD PAL 16:9"; - destSize = QSize(1024, 576); - finalSize = QSize(720, 576); - break; - case NTSC: - profileEasyName = "DVD NTSC 4:3"; - destSize = QSize(640, 480); - finalSize = QSize(720, 480); - break; - case NTSC_WIDE: - profileEasyName = "DVD NTSC 16:9"; - destSize = QSize(853, 480); - finalSize = QSize(720, 480); - break; - default: - profileEasyName = "DVD PAL 4:3"; - destSize = QSize(768, 576); - finalSize = QSize(720, 576); + case PAL_WIDE: + profileEasyName = "DVD PAL 16:9"; + destSize = QSize(1024, 576); + finalSize = QSize(720, 576); + break; + case NTSC: + profileEasyName = "DVD NTSC 4:3"; + destSize = QSize(640, 480); + finalSize = QSize(720, 480); + break; + case NTSC_WIDE: + profileEasyName = "DVD NTSC 16:9"; + destSize = QSize(853, 480); + finalSize = QSize(720, 480); + break; + default: + profileEasyName = "DVD PAL 4:3"; + destSize = QSize(768, 576); + finalSize = QSize(720, 576); } - QString params = transConfig.readEntry(profileEasyName); - + QString params = transConfig.readEntry(profileEasyName); + // Transcode files that do not match selected profile int max = m_vobList->topLevelItemCount(); int format = m_view.dvd_profile->currentIndex(); - for (int i = 0; i < max; i++) { + for (int i = 0; i < max; ++i) { QTreeWidgetItem *item = m_vobList->topLevelItem(i); - if (item->data(0, Qt::UserRole + 1).toInt() != format) { - // File needs to be transcoded - m_transcodeAction->setEnabled(false); - QSize original = item->data(0, Qt::UserRole + 2).toSize(); - double input_aspect= (double) original.width() / original.height(); - QStringList postParams; - if (input_aspect > (double) destSize.width() / destSize.height()) { - // letterboxing - int conv_height = (int) (destSize.width() / input_aspect); - int conv_pad = (int) (((double) (destSize.height() - conv_height)) / 2.0); - if (conv_pad %2 == 1) conv_pad --; - 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); - } else { - // pillarboxing - int conv_width = (int) (destSize.height() * input_aspect); - int conv_pad = (int) (((double) (destSize.width() - conv_width)) / destSize.width() * finalSize.width() / 2.0); - if (conv_pad %2 == 1) conv_pad --; - 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); - } - ClipTranscode *d = new ClipTranscode(KUrl::List () << KUrl(item->text(0)), params.section(';', 0, 0), postParams, i18n("Transcoding to DVD format"), true, this); - connect(d, SIGNAL(transcodedClip(KUrl,KUrl)), this, SLOT(slotTranscodedClip(KUrl, KUrl))); - d->show(); - } + if (item->data(0, Qt::UserRole + 1).toInt() != format) { + // File needs to be transcoded + m_transcodeAction->setEnabled(false); + QSize original = item->data(0, Qt::UserRole + 2).toSize(); + double input_aspect= (double) original.width() / original.height(); + QStringList postParams; + if (input_aspect > (double) destSize.width() / destSize.height()) { + // letterboxing + int conv_height = (int) (destSize.width() / input_aspect); + int conv_pad = (int) (((double) (destSize.height() - conv_height)) / 2.0); + if (conv_pad %2 == 1) conv_pad --; + 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); + } else { + // pillarboxing + int conv_width = (int) (destSize.height() * input_aspect); + int conv_pad = (int) (((double) (destSize.width() - conv_width)) / destSize.width() * finalSize.width() / 2.0); + if (conv_pad %2 == 1) conv_pad --; + 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); + } + ClipTranscode *d = new ClipTranscode(KUrl::List () << KUrl(item->text(0)), params.section(';', 0, 0), postParams, i18n("Transcoding to DVD format"), true, this); + connect(d, SIGNAL(transcodedClip(KUrl,KUrl)), this, SLOT(slotTranscodedClip(KUrl,KUrl))); + d->slotStartTransCode(); + d->show(); + + } } } void DvdWizardVob::slotTranscodedClip(KUrl src, KUrl transcoded) { + if (transcoded.isEmpty()) { + // Transcoding canceled or failed + m_transcodeAction->setEnabled(true); + return; + } int max = m_vobList->topLevelItemCount(); - for (int i = 0; i < max; i++) { + for (int i = 0; i < max; ++i) { QTreeWidgetItem *item = m_vobList->topLevelItem(i); - if (KUrl(item->text(0)).path() == src.path()) { - // Replace movie with transcoded version - item->setText(0, transcoded.path()); - - QFile f(transcoded.path()); - qint64 fileSize = f.size(); - - Mlt::Profile profile; - profile.set_explicit(false); - item->setText(2, KIO::convertSize(fileSize)); - item->setData(2, Qt::UserRole, fileSize); - item->setData(0, Qt::DecorationRole, KIcon("video-x-generic").pixmap(60, 45)); - item->setToolTip(0, transcoded.path()); - - QString resource = transcoded.path(); - resource.prepend("avformat:"); - Mlt::Producer *producer = new Mlt::Producer(profile, resource.toUtf8().data()); - if (producer && producer->is_valid() && !producer->is_blank()) { - profile.from_producer(*producer); - int width = 45.0 * profile.dar(); - int swidth = 45.0 * profile.width() / profile.height(); - if (width % 2 == 1) width++; - item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, swidth, width, 45))); - int playTime = producer->get_playtime(); - item->setText(1, Timecode::getStringTimecode(playTime, profile.fps())); - item->setData(1, Qt::UserRole, playTime); - int standard = -1; - int aspect = profile.dar() * 100; - if (profile.height() == 576) { - if (aspect > 150) standard = 1; - else standard = 0; - } - else if (profile.height() == 480) { - if (aspect > 150) standard = 3; - else standard = 2; - } - QString standardName; - switch (standard) { - case 3: - standardName = i18n("NTSC 16:9"); - break; - case 2: - standardName = i18n("NTSC 4:3"); - break; - case 1: - standardName = i18n("PAL 16:9"); - break; - case 0: - standardName = i18n("PAL 4:3"); - break; - default: - standardName = i18n("Unknown"); - } - item->setData(0, Qt::UserRole, standardName); - item->setData(0, Qt::UserRole + 1, standard); - item->setData(0, Qt::UserRole + 2, QSize(profile.dar() * profile.height(), profile.height())); - } - else { - // Cannot load movie, reject - showError(i18n("The clip %1 is invalid.", transcoded.fileName())); - } - if (producer) delete producer; - slotCheckVobList(); - slotCheckProfiles(); - break; - } + if (KUrl(item->text(0)).path() == src.path()) { + // Replace movie with transcoded version + item->setText(0, transcoded.path()); + + QFile f(transcoded.path()); + qint64 fileSize = f.size(); + + Mlt::Profile profile; + profile.set_explicit(false); + item->setText(2, KIO::convertSize(fileSize)); + item->setData(2, Qt::UserRole, fileSize); + item->setData(0, Qt::DecorationRole, KIcon("video-x-generic").pixmap(60, 45)); + item->setToolTip(0, transcoded.path()); + + QString resource = transcoded.path(); + resource.prepend("avformat:"); + Mlt::Producer *producer = new Mlt::Producer(profile, resource.toUtf8().data()); + if (producer && producer->is_valid() && !producer->is_blank()) { + profile.from_producer(*producer); + int width = 45.0 * profile.dar(); + int swidth = 45.0 * profile.width() / profile.height(); + if (width % 2 == 1) width++; + item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, swidth, width, 45))); + int playTime = producer->get_playtime(); + item->setText(1, Timecode::getStringTimecode(playTime, profile.fps())); + item->setData(1, Qt::UserRole, playTime); + int standard = -1; + int aspect = profile.dar() * 100; + if (profile.height() == 576) { + if (aspect > 150) standard = 1; + else standard = 0; + } + else if (profile.height() == 480) { + if (aspect > 150) standard = 3; + else standard = 2; + } + QString standardName; + switch (standard) { + case 3: + standardName = i18n("NTSC 16:9"); + break; + case 2: + standardName = i18n("NTSC 4:3"); + break; + case 1: + standardName = i18n("PAL 16:9"); + break; + case 0: + standardName = i18n("PAL 4:3"); + break; + default: + standardName = i18n("Unknown"); + } + item->setData(0, Qt::UserRole, standardName); + item->setData(0, Qt::UserRole + 1, standard); + item->setData(0, Qt::UserRole + 2, QSize(profile.dar() * profile.height(), profile.height())); + } + else { + // Cannot load movie, reject + showError(i18n("The clip %1 is invalid.", transcoded.fileName())); + } + if (producer) delete producer; + slotCheckVobList(); + slotCheckProfiles(); + break; + } } } @@ -622,7 +666,7 @@ void DvdWizardVob::showProfileError() #endif } -void DvdWizardVob::showError(const QString error) +void DvdWizardVob::showError(const QString &error) { #if KDE_IS_VERSION(4,7,0) m_warnMessage->setText(error); @@ -633,4 +677,7 @@ void DvdWizardVob::showError(const QString error) m_view.error_message->setText(error); m_view.error_message->setVisible(true); #endif -} \ No newline at end of file +} + + +#include "dvdwizardvob.moc"