+
+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) {
+ 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;
+ }
+ }
+}
+
+void DvdWizardVob::showProfileError()
+{
+#if KDE_IS_VERSION(4,7,0)
+ m_warnMessage->setText(i18n("Your clips do not match selected DVD format, transcoding required."));
+ m_warnMessage->setCloseButtonVisible(false);
+ m_warnMessage->addAction(m_transcodeAction);
+ m_warnMessage->animatedShow();
+#else
+ m_view.error_message->setText(i18n("Your clips do not match selected DVD format, transcoding required."));
+ m_view.error_message->setVisible(true);
+#endif
+}
+
+void DvdWizardVob::showError(const QString &error)
+{
+#if KDE_IS_VERSION(4,7,0)
+ m_warnMessage->setText(error);
+ m_warnMessage->setCloseButtonVisible(true);
+ m_warnMessage->removeAction(m_transcodeAction);
+ m_warnMessage->animatedShow();
+#else
+ m_view.error_message->setText(error);
+ m_view.error_message->setVisible(true);
+#endif
+}
+
+
+#include "dvdwizardvob.moc"