]> git.sesse.net Git - kdenlive/blobdiff - src/dvdwizardvob.cpp
Fix render dialog popping up after clicking on new project (leave it only for KDE...
[kdenlive] / src / dvdwizardvob.cpp
index 4f058e2bae874700f4e18acd3cefb29c394fbc3b..cce398d5f92128256b1d1f30b46853668d93c4dd 100644 (file)
@@ -34,6 +34,7 @@
 #include <QDomDocument>
 #include <QTreeWidgetItem>
 #include <QHeaderView>
+#include <unistd.h>
 
 DvdTreeWidget::DvdTreeWidget(QWidget *parent) :
         QTreeWidget(parent)
@@ -69,8 +70,6 @@ DvdWizardVob::DvdWizardVob(QWidget *parent) :
         m_installCheck(true)
 {
     m_view.setupUi(this);
-    m_view.intro_vob->setEnabled(false);
-    m_view.intro_vob->setFilter("video/mpeg");
     m_view.button_add->setIcon(KIcon("list-add"));
     m_view.button_delete->setIcon(KIcon("list-remove"));
     m_view.button_up->setIcon(KIcon("go-up"));
@@ -84,8 +83,6 @@ DvdWizardVob::DvdWizardVob(QWidget *parent) :
 
     connect(m_vobList, SIGNAL(addClips(QList<QUrl>)), this, SLOT(slotAddVobList(QList<QUrl>)));
     connect(m_vobList, SIGNAL(addNewClip()), this, SLOT(slotAddVobFile()));
-    
-    connect(m_view.use_intro, SIGNAL(toggled(bool)), m_view.intro_vob, SLOT(setEnabled(bool)));
     connect(m_view.button_add, SIGNAL(clicked()), this, SLOT(slotAddVobFile()));
     connect(m_view.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteVobFile()));
     connect(m_view.button_up, SIGNAL(clicked()), this, SLOT(slotItemUp()));
@@ -94,12 +91,12 @@ DvdWizardVob::DvdWizardVob(QWidget *parent) :
     
     m_vobList->setIconSize(QSize(60, 45));
 
-    if (KStandardDirs::findExe("dvdauthor").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 is required for the DVD wizard.</strong>", i18n("dvdauthor")));
-    if (KStandardDirs::findExe("mkisofs").isEmpty() && KStandardDirs::findExe("genisoimage").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 or %2 is required for the DVD wizard.</strong>", 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("<strong>Program %1 is required for the DVD wizard.</strong>", i18n("dvdauthor")));
+    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")));
+    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"));
@@ -121,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 <QGridLayout*> (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();
@@ -205,11 +212,11 @@ void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters, bool checkF
         item->setData(1, Qt::UserRole, playTime);
        int standard = -1;
        int aspect = profile.dar() * 100;
-       if (profile.height() == 576) {
+       if (profile.height() == 576 && profile.fps() == 25.0) {
            if (aspect > 150) standard = 1;
            else standard = 0;
        }
-       else if (profile.height() == 480) {
+       else if (profile.height() == 480 && qAbs(profile.fps() - 30000.0 / 1001) < 0.2) {
            if (aspect > 150) standard = 3;
            else standard = 2;
        }
@@ -230,6 +237,7 @@ void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters, bool checkF
          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()));
@@ -306,7 +314,12 @@ QStringList DvdWizardVob::selectedUrls() 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->text(0));
     }
@@ -359,20 +372,18 @@ int DvdWizardVob::duration(int ix) const
     return result;
 }
 
-
-QString DvdWizardVob::introMovie() const
+const QString DvdWizardVob::introMovie() const
 {
-    if (!m_view.use_intro->isChecked()) return QString();
-    return m_view.intro_vob->url().path();
+    QString url;
+    if (m_view.use_intro->isChecked() && m_vobList->topLevelItemCount() > 0) url = m_vobList->topLevelItem(0)->text(0);
+    return url;
 }
 
-void DvdWizardVob::setIntroMovie(const QString& path)
+void DvdWizardVob::setUseIntroMovie(bool use)
 {
-    m_view.intro_vob->setUrl(KUrl(path));
-    m_view.use_intro->setChecked(path.isEmpty() == false);
+    m_view.use_intro->setChecked(use);
 }
 
-
 void DvdWizardVob::slotCheckVobList()
 {
     emit completeChanged();
@@ -476,7 +487,7 @@ 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;
@@ -531,13 +542,20 @@ void DvdWizardVob::slotTranscodeFiles()
            }
            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++) {
         QTreeWidgetItem *item = m_vobList->topLevelItem(i);