]> git.sesse.net Git - kdenlive/blobdiff - src/dvdwizard.cpp
const'ify
[kdenlive] / src / dvdwizard.cpp
index 47dba0155a7bf13c2ce85d1cf1f64da8ae4170ae..888b57d56d397c292cf92c7981f9a2dec88ae1f5 100644 (file)
 #include <QGridLayout>
 
 
-DvdWizard::DvdWizard(const QString &url, QWidget *parent) :
-        QWizard(parent),
-        m_dvdauthor(NULL),
-        m_mkiso(NULL),
-        m_burnMenu(new QMenu(this))
+DvdWizard::DvdWizard(MonitorManager *manager, const QString &url, QWidget *parent) :
+        QWizard(parent)
+        , m_dvdauthor(NULL)
+        , m_mkiso(NULL)
+        , m_vobitem(NULL)
+        , m_burnMenu(new QMenu(this))
 {
     setWindowTitle(i18n("DVD Wizard"));
     //setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
     m_pageVob = new DvdWizardVob(this);
     m_pageVob->setTitle(i18n("Select Files For Your DVD"));
     addPage(m_pageVob);
-    if (!url.isEmpty()) m_pageVob->setUrl(url);
-
 
-    m_pageChapters = new DvdWizardChapters(m_pageVob->dvdFormat(), this);
+    m_pageChapters = new DvdWizardChapters(manager, m_pageVob->dvdFormat(), this);
     m_pageChapters->setTitle(i18n("DVD Chapters"));
     addPage(m_pageChapters);
+    
+    if (!url.isEmpty()) m_pageVob->setUrl(url);
+    connect(m_pageVob, SIGNAL(prepareMonitor()), this, SLOT(slotprepareMonitor()));
 
 
 
@@ -154,6 +156,7 @@ void DvdWizard::slotPageChanged(int page)
         m_pageVob->updateChapters(m_pageChapters->chaptersData());
     } else if (page == 1) {
         m_pageChapters->setVobFiles(m_pageVob->dvdFormat(), m_pageVob->selectedUrls(), m_pageVob->durations(), m_pageVob->chapters());
+       setTitleFormat(Qt::PlainText);
     } else if (page == 2) {
         m_pageChapters->stopMonitor();
         m_pageVob->updateChapters(m_pageChapters->chaptersData());
@@ -162,7 +165,10 @@ void DvdWizard::slotPageChanged(int page)
     }
 }
 
-
+void DvdWizard::slotprepareMonitor()
+{
+    m_pageChapters->createMonitor(m_pageVob->dvdFormat());
+}
 
 void DvdWizard::generateDvd()
 {
@@ -178,10 +184,18 @@ void DvdWizard::generateDvd()
     m_selectedImage.setSuffix(".png");
     //m_selectedImage.setAutoRemove(false);
     m_selectedImage.open();
+    
+    m_selectedLetterImage.setSuffix(".png");
+    //m_selectedLetterImage.setAutoRemove(false);
+    m_selectedLetterImage.open();
 
     m_highlightedImage.setSuffix(".png");
     //m_highlightedImage.setAutoRemove(false);
     m_highlightedImage.open();
+    
+    m_highlightedLetterImage.setSuffix(".png");
+    //m_highlightedLetterImage.setAutoRemove(false);
+    m_highlightedLetterImage.open();
 
     m_menuImageBackground.setSuffix(".png");
     m_menuImageBackground.setAutoRemove(false);
@@ -227,7 +241,7 @@ void DvdWizard::generateDvd()
         m_pageMenu->createButtonImages(m_selectedImage.fileName(), m_highlightedImage.fileName(), false);
         m_pageMenu->createBackgroundImage(m_menuImageBackground.fileName(), false);
         images->setIcon(KIcon("dialog-ok"));
-       connect(&m_menuJob, SIGNAL(finished (int, QProcess::ExitStatus)), this, SLOT(slotProcessMenuStatus(int, QProcess::ExitStatus)));
+       connect(&m_menuJob, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotProcessMenuStatus(int,QProcess::ExitStatus)));
         //kDebug() << "/// STARTING MLT VOB CREATION: "<<m_selectedImage.fileName()<<m_menuImageBackground.fileName();
         if (!m_pageMenu->menuMovie()) {
             // create menu vob file
@@ -280,7 +294,6 @@ void DvdWizard::processSpumux()
     QListWidgetItem *spuitem =  m_status.job_progress->item(2);
     m_status.job_progress->setCurrentRow(2);
     spuitem->setIcon(KIcon("system-run"));
-    qApp->processEvents();
     QDomDocument doc;
     QDomElement sub = doc.createElement("subpictures");
     doc.appendChild(sub);
@@ -313,10 +326,10 @@ void DvdWizard::processSpumux()
 
         // We need to make sure that the y coordinate is a multiple of 2, otherwise button may not be displayed
         buttonsTarget.append(it.key());
-       int y0 = r.y() - 2;
+       int y0 = r.y();
        if (y0 % 2 == 1) y0++;
-       int y1 = r.bottom() + 2;
-       if (y1 % 2 == 1) y1++;
+       int y1 = r.bottom();
+       if (y1 % 2 == 1) y1--;
         but.setAttribute("x0", QString::number(r.x()));
         but.setAttribute("y0", QString::number(y0));
         but.setAttribute("x1", QString::number(r.right()));
@@ -384,19 +397,27 @@ void DvdWizard::processSpumux()
     }
     if (m_pageVob->dvdFormat() == PAL_WIDE || m_pageVob->dvdFormat() == NTSC_WIDE) {
        // Second step processing for 16:9 DVD, add letterbox stream
-       m_pageMenu->createButtonImages(m_selectedImage.fileName(), m_highlightedImage.fileName(), true);
+       m_pageMenu->createButtonImages(m_selectedLetterImage.fileName(), m_highlightedLetterImage.fileName(), true);
        buttons = m_pageMenu->buttonsInfo(true);
-       // Remove previous button info
-       while(!spu.firstChild().isNull()) {
-           spu.removeChild(spu.firstChild());
-       }
+       
+       QDomDocument docLetter;
+       QDomElement subLetter = docLetter.createElement("subpictures");
+       docLetter.appendChild(subLetter);
+       QDomElement streamLetter = docLetter.createElement("stream");
+       subLetter.appendChild(streamLetter);
+       QDomElement spuLetter = docLetter.createElement("spu");
+       streamLetter.appendChild(spuLetter);
+       spuLetter.setAttribute("force", "yes");
+       spuLetter.setAttribute("start", "00:00:00.00");
+       spuLetter.setAttribute("select", m_selectedLetterImage.fileName());
+       spuLetter.setAttribute("highlight", m_highlightedLetterImage.fileName());
 
        max = buttons.count() - 1;
        i = 0;
        QMapIterator<QString, QRect> it2(buttons);
        while (it2.hasNext()) {
            it2.next();
-           QDomElement but = doc.createElement("button");
+           QDomElement but = docLetter.createElement("button");
            but.setAttribute("name", 'b' + QString::number(i));
            if (i < max) but.setAttribute("down", 'b' + QString::number(i + 1));
            else but.setAttribute("down", "b0");
@@ -405,22 +426,22 @@ void DvdWizard::processSpumux()
            QRect r = it2.value();
            // We need to make sure that the y coordinate is a multiple of 2, otherwise button may not be displayed
            buttonsTarget.append(it2.key());
-           int y0 = r.y() - 2;
+           int y0 = r.y();
            if (y0 % 2 == 1) y0++;
-           int y1 = r.bottom() + 2;
-           if (y1 % 2 == 1) y1++;
+           int y1 = r.bottom();
+           if (y1 % 2 == 1) y1--;
            but.setAttribute("x0", QString::number(r.x()));
            but.setAttribute("y0", QString::number(y0));
            but.setAttribute("x1", QString::number(r.right()));
            but.setAttribute("y1", QString::number(y1));
-           spu.appendChild(but);
+           spuLetter.appendChild(but);
            i++;
        }
 
        //kDebug() << " SPUMUX DATA: " << doc.toString();
     
        if (data.open(QFile::WriteOnly)) {
-           data.write(doc.toString().toUtf8());
+           data.write(docLetter.toString().toUtf8());
        }
        data.close();
        spumux.setStandardInputFile(m_menuVobFile.fileName());
@@ -472,7 +493,6 @@ void DvdWizard::processDvdauthor(QString menuMovieUrl, QMap <QString, QRect> but
     QListWidgetItem *authitem =  m_status.job_progress->item(3);
     m_status.job_progress->setCurrentRow(3);
     authitem->setIcon(KIcon("system-run"));
-    qApp->processEvents();
     KIO::NetAccess::mkdir(KUrl(m_status.tmp_folder->url().path(KUrl::AddTrailingSlash) + "DVD"), this);
 
     QDomDocument dvddoc;
@@ -505,6 +525,31 @@ void DvdWizard::processDvdauthor(QString menuMovieUrl, QMap <QString, QRect> but
         // DVD main menu
         QDomElement menus = dvddoc.createElement("menus");
         titleset.appendChild(menus);
+       
+       QDomElement menuvideo = dvddoc.createElement("video");
+       menus.appendChild(menuvideo);
+       switch (m_pageVob->dvdFormat()) {
+           case PAL_WIDE:
+               menuvideo.setAttribute("format", "pal");
+               menuvideo.setAttribute("aspect", "16:9");
+               menuvideo.setAttribute("widescreen", "nopanscan");
+               break;
+           case NTSC_WIDE:
+               menuvideo.setAttribute("format", "ntsc");
+               menuvideo.setAttribute("aspect", "16:9");
+               menuvideo.setAttribute("widescreen", "nopanscan");
+               break;
+           case NTSC:
+               menuvideo.setAttribute("format", "ntsc");
+               menuvideo.setAttribute("aspect", "4:3");
+               break;
+           default:
+               menuvideo.setAttribute("format", "pal");
+               menuvideo.setAttribute("aspect", "4:3");
+               break;
+       }
+
+       
        if (m_pageVob->dvdFormat() == PAL_WIDE || m_pageVob->dvdFormat() == NTSC_WIDE) {
            // Add letterbox stream info
            QDomElement subpict = dvddoc.createElement("subpicture");
@@ -629,7 +674,7 @@ void DvdWizard::processDvdauthor(QString menuMovieUrl, QMap <QString, QRect> but
     env << QString("VIDEO_FORMAT=") + QString(m_pageVob->dvdFormat() == PAL || m_pageVob->dvdFormat() == PAL_WIDE ? "PAL" : "NTSC");
     m_dvdauthor->setEnvironment(env);
 #endif
-    connect(m_dvdauthor, SIGNAL(finished(int , QProcess::ExitStatus)), this, SLOT(slotRenderFinished(int, QProcess::ExitStatus)));
+    connect(m_dvdauthor, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotRenderFinished(int,QProcess::ExitStatus)));
     connect(m_dvdauthor, SIGNAL(readyReadStandardOutput()), this, SLOT(slotShowRenderInfo()));
     m_dvdauthor->setProcessChannelMode(QProcess::MergedChannels);
     m_dvdauthor->start("dvdauthor", args);
@@ -643,14 +688,14 @@ void DvdWizard::slotProcessMenuStatus(int, QProcess::ExitStatus status)
        kDebug() << "/// RENDERING MENU vob crashed";
         errorMessage(i18n("Rendering menu crashed"));
         QByteArray result = m_menuJob.readAllStandardError();
-        m_vobitem->setIcon(KIcon("dialog-close"));
+        if (m_vobitem) m_vobitem->setIcon(KIcon("dialog-close"));
         m_status.error_log->append(result);
         m_status.error_box->setHidden(false);
         m_status.button_start->setEnabled(true);
         m_status.button_abort->setEnabled(false);
         return;
     }
-    m_vobitem->setIcon(KIcon("dialog-ok"));
+    if (m_vobitem) m_vobitem->setIcon(KIcon("dialog-ok"));
     processSpumux();
 }
 
@@ -725,7 +770,6 @@ void DvdWizard::slotRenderFinished(int exitCode, QProcess::ExitStatus status)
         return;
     }
     authitem->setIcon(KIcon("dialog-ok"));
-    qApp->processEvents();
     QStringList args;
     args << "-dvd-video" << "-v" << "-o" << m_status.iso_image->url().path() << m_status.tmp_folder->url().path(KUrl::AddTrailingSlash) + "DVD";
 
@@ -736,7 +780,7 @@ void DvdWizard::slotRenderFinished(int exitCode, QProcess::ExitStatus status)
         m_mkiso = NULL;
     }
     m_mkiso = new QProcess(this);
-    connect(m_mkiso, SIGNAL(finished(int , QProcess::ExitStatus)), this, SLOT(slotIsoFinished(int, QProcess::ExitStatus)));
+    connect(m_mkiso, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotIsoFinished(int,QProcess::ExitStatus)));
     connect(m_mkiso, SIGNAL(readyReadStandardOutput()), this, SLOT(slotShowIsoInfo()));
     m_mkiso->setProcessChannelMode(QProcess::MergedChannels);
     QListWidgetItem *isoitem =  m_status.job_progress->item(4);