X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdvdwizard.cpp;h=1d87611bd1f13d9531865825db006c3dcc415e53;hb=4b9c0b0557c3fb55a34e2c09559d44b551759843;hp=4456be41bd2214f68e3a9e4e1f787d86970ddef5;hpb=bd2c5c0474efd44d4986a8a92e57f7a5b6d972ba;p=kdenlive diff --git a/src/dvdwizard.cpp b/src/dvdwizard.cpp index 4456be41..1d87611b 100644 --- a/src/dvdwizard.cpp +++ b/src/dvdwizard.cpp @@ -40,23 +40,25 @@ #include -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); @@ -219,7 +233,6 @@ void DvdWizard::generateDvd() QListWidgetItem *images = m_status.job_progress->item(0); m_status.job_progress->setCurrentRow(0); images->setIcon(KIcon("system-run")); - qApp->processEvents(); m_status.error_log->clear(); // initialize html content m_status.error_log->setText(""); @@ -228,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: "<menuMovie()) { // create menu vob file @@ -269,6 +282,7 @@ void DvdWizard::generateDvd() //kDebug()<<"// STARTING MENU JOB, image: "<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,16 +326,16 @@ 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())); but.setAttribute("y1", QString::number(y1)); spu.appendChild(but); - i++; + ++i; } QFile data(m_menuFile.fileName()); @@ -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 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); - i++; + 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()); @@ -463,12 +484,15 @@ void DvdWizard::processSpumux() spuitem->setIcon(KIcon("dialog-ok")); kDebug() << "/// DONE: " << menuMovieUrl; + processDvdauthor(menuMovieUrl, buttons, buttonsTarget); +} +void DvdWizard::processDvdauthor(const QString &menuMovieUrl, const QMap &buttons, const QStringList &buttonsTarget) +{ // create dvdauthor xml 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; @@ -501,6 +525,31 @@ void DvdWizard::processSpumux() // 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"); @@ -524,7 +573,7 @@ void DvdWizard::processSpumux() QDomElement menuvob = dvddoc.createElement("vob"); menuvob.setAttribute("file", menuMovieUrl); pgc.appendChild(menuvob); - for (int i = 0; i < buttons.count(); i++) { + for (int i = 0; i < buttons.count(); ++i) { QDomElement button = dvddoc.createElement("button"); button.setAttribute("name", 'b' + QString::number(i)); nametext = dvddoc.createTextNode('{' + buttonsTarget.at(i) + ";}"); @@ -568,7 +617,7 @@ void DvdWizard::processSpumux() // Get list of clips QStringList voburls = m_pageVob->selectedUrls(); - for (int i = 0; i < voburls.count(); i++) { + for (int i = 0; i < voburls.count(); ++i) { if (!voburls.at(i).isEmpty()) { // Add vob entry pgc2 = dvddoc.createElement("pgc"); @@ -604,7 +653,7 @@ void DvdWizard::processSpumux() kDebug() << dvddoc.toString(); kDebug() << "------------------";*/ - args.clear(); + QStringList args; args << "-x" << m_authorFile.fileName(); kDebug() << "// DVDAUTH ARGS: " << args; if (m_dvdauthor) { @@ -617,7 +666,7 @@ void DvdWizard::processSpumux() m_dvdauthor = new QProcess(this); // Set VIDEO_FORMAT variable (required by dvdauthor 0.7) #if QT_VERSION >= 0x040600 - env = QProcessEnvironment::systemEnvironment(); + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("VIDEO_FORMAT", m_pageVob->dvdFormat() == PAL || m_pageVob->dvdFormat() == PAL_WIDE ? "PAL" : "NTSC"); m_dvdauthor->setProcessEnvironment(env); #else @@ -625,7 +674,7 @@ void DvdWizard::processSpumux() 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); @@ -639,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(); } @@ -721,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"; @@ -732,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); @@ -854,7 +902,7 @@ void DvdWizard::slotGenerate() { // clear job icons if ((m_dvdauthor && m_dvdauthor->state() != QProcess::NotRunning) || (m_mkiso && m_mkiso->state() != QProcess::NotRunning)) return; - for (int i = 0; i < m_status.job_progress->count(); i++) + for (int i = 0; i < m_status.job_progress->count(); ++i) m_status.job_progress->item(i)->setIcon(KIcon()); QString warnMessage; if (KIO::NetAccess::exists(KUrl(m_status.tmp_folder->url().path(KUrl::AddTrailingSlash) + "DVD"), KIO::NetAccess::SourceSide, this)) @@ -940,9 +988,11 @@ void DvdWizard::slotLoad() } QDomNodeList vobs = doc.elementsByTagName("vob"); - for (int i = 0; i < vobs.count(); i++) { + for (int i = 0; i < vobs.count(); ++i) { QDomElement e = vobs.at(i).toElement(); m_pageVob->slotAddVobFile(KUrl(e.attribute("file")), e.attribute("chapters")); } m_pageMenu->loadXml(m_pageVob->dvdFormat(), dvdproject.firstChildElement("menu")); } + +#include "dvdwizard.moc"