From 98b9fcdb9c5a4e84489b37d253a7491d6a4d17ef Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 24 May 2009 23:26:30 +0000 Subject: [PATCH] Updated DVD wizard (added load/save dvd projects) svn path=/trunk/kdenlive/; revision=3415 --- src/dvdwizard.cpp | 110 ++++++++++++++++++++++++++++++++++---- src/dvdwizard.h | 3 ++ src/dvdwizardchapters.cpp | 85 ++++++++--------------------- src/dvdwizardchapters.h | 6 +-- src/dvdwizardmenu.cpp | 101 ++++++++++++++++++++++++++++++++++ src/dvdwizardmenu.h | 3 ++ src/dvdwizardvob.cpp | 106 ++++++++++++++++++++++++++++++++---- src/dvdwizardvob.h | 9 +++- src/mainwindow.cpp | 4 +- 9 files changed, 338 insertions(+), 89 deletions(-) diff --git a/src/dvdwizard.cpp b/src/dvdwizard.cpp index 938f8ca6..a22e0d2a 100644 --- a/src/dvdwizard.cpp +++ b/src/dvdwizard.cpp @@ -78,7 +78,6 @@ DvdWizard::DvdWizard(const QString &url, const QString &profile, QWidget *parent connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotPageChanged(int))); connect(m_status.button_start, SIGNAL(clicked()), this, SLOT(slotGenerate())); connect(m_status.button_abort, SIGNAL(clicked()), this, SLOT(slotAbort())); - connect(m_status.button_save, SIGNAL(clicked()), this, SLOT(slotSave())); connect(m_status.button_preview, SIGNAL(clicked()), this, SLOT(slotPreview())); QString programName("k3b"); @@ -101,6 +100,18 @@ DvdWizard::DvdWizard(const QString &url, const QString &profile, QWidget *parent m_status.button_burn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_status.button_preview->setIcon(KIcon("media-playback-start")); + // TODO: uncomment after 0.7.4 release (i18n change) + /*setButtonText(QWizard::CustomButton1, i19n("Load")); + setButtonText(QWizard::CustomButton2, i19n("Save"));*/ + button(QWizard::CustomButton1)->setIcon(KIcon("document-open")); + button(QWizard::CustomButton2)->setIcon(KIcon("document-save")); + connect(button(QWizard::CustomButton1), SIGNAL(clicked()), this, SLOT(slotLoad())); + connect(button(QWizard::CustomButton2), SIGNAL(clicked()), this, SLOT(slotSave())); + setOption(QWizard::HaveCustomButton1, true); + setOption(QWizard::HaveCustomButton2, true); + QList layout; + layout << QWizard::CustomButton1 << QWizard::CustomButton2 << QWizard::Stretch << QWizard::BackButton << QWizard::NextButton << QWizard::CancelButton << QWizard::FinishButton; + setButtonLayout(layout); } DvdWizard::~DvdWizard() @@ -123,8 +134,11 @@ DvdWizard::~DvdWizard() void DvdWizard::slotPageChanged(int page) { //kDebug() << "// PAGE CHGD: " << page << ", ID: " << visitedPages(); - if (page == 1) { - m_pageChapters->setVobFiles(m_pageVob->isPal(), m_pageVob->selectedUrls(), m_pageVob->durations()); + if (page == 0) { + // Update chapters that were modified in page 1 + m_pageVob->updateChapters(m_pageChapters->chaptersData()); + } else if (page == 1) { + m_pageChapters->setVobFiles(m_pageVob->isPal(), m_pageVob->selectedUrls(), m_pageVob->durations(), m_pageVob->chapters()); } else if (page == 2) { m_pageMenu->setTargets(m_pageChapters->selectedTitles(), m_pageChapters->selectedTargets()); m_pageMenu->changeProfile(m_pageVob->isPal()); @@ -135,6 +149,7 @@ void DvdWizard::slotPageChanged(int page) void DvdWizard::generateDvd() { + m_status.error_box->setHidden(true); KTemporaryFile temp1; temp1.setSuffix(".png"); //temp1.setAutoRemove(false); @@ -434,16 +449,28 @@ void DvdWizard::generateDvd() m_creationLog.clear(); m_dvdauthor = new QProcess(this); 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); m_status.button_abort->setEnabled(true); } +void DvdWizard::slotShowRenderInfo() +{ + QString log = QString(m_dvdauthor->readAll()); + m_status.error_log->setText(log); + m_status.error_box->setHidden(false); +} + void DvdWizard::slotRenderFinished(int exitCode, QProcess::ExitStatus status) { QListWidgetItem *authitem = m_status.job_progress->item(3); if (status == QProcess::CrashExit || exitCode != 0) { - QByteArray result = m_dvdauthor->readAllStandardError(); + QString result(m_dvdauthor->readAllStandardError()); + result.append("
"); + + //TODO: uncomment after 0.7.4 release (i18n change) + //result.append(i19n("DVDAuthor process crashed.")); m_status.error_log->setText(result); m_status.error_box->setHidden(false); kDebug() << "DVDAuthor process crashed"; @@ -485,6 +512,7 @@ void DvdWizard::slotRenderFinished(int exitCode, QProcess::ExitStatus status) } m_mkiso = new QProcess(this); 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); isoitem->setIcon(KIcon("system-run")); @@ -492,11 +520,21 @@ void DvdWizard::slotRenderFinished(int exitCode, QProcess::ExitStatus status) } +void DvdWizard::slotShowIsoInfo() +{ + QString log = QString(m_mkiso->readAll()); + m_status.error_log->setText(log); + m_status.error_box->setHidden(false); +} + void DvdWizard::slotIsoFinished(int exitCode, QProcess::ExitStatus status) { QListWidgetItem *isoitem = m_status.job_progress->item(4); if (status == QProcess::CrashExit || exitCode != 0) { - QByteArray result = m_mkiso->readAllStandardError(); + QString result(m_mkiso->readAllStandardError()); + result.append("
"); + //TODO: uncomment after 0.7.4 release (i18n change) + // result.append(i19n("ISO creation process crashed.")); m_status.error_log->setText(result); m_status.error_box->setHidden(false); m_mkiso->close(); @@ -582,7 +620,7 @@ void DvdWizard::slotGenerate() if (KIO::NetAccess::exists(KUrl(m_status.iso_image->url().path()), KIO::NetAccess::SourceSide, this)) warnMessage.append(i18n("Image file %1 already exists. Overwrite?", m_status.iso_image->url().path())); - if (!warnMessage.isEmpty() && KMessageBox::questionYesNo(this, warnMessage) == KMessageBox::Yes) { + if (warnMessage.isEmpty() || KMessageBox::questionYesNo(this, warnMessage) == KMessageBox::Yes) { KIO::NetAccess::del(KUrl(m_status.tmp_folder->url().path() + "/DVD"), this); QTimer::singleShot(300, this, SLOT(generateDvd())); m_status.button_preview->setEnabled(false); @@ -601,10 +639,11 @@ void DvdWizard::slotAbort() void DvdWizard::slotSave() { - KMessageBox::sorry(this, "Not implemented yet"); - return; - KUrl url = KFileDialog::getSaveUrl(KUrl(), "*.kdvd", this, i18n("Save DVD Project")); + KUrl url = KFileDialog::getSaveUrl(KUrl("kfiledialog:///projectfolder"), "*.kdvd", this, i18n("Save DVD Project")); if (url.isEmpty()) return; + + if (currentId() == 0) m_pageChapters->setVobFiles(m_pageVob->isPal(), m_pageVob->selectedUrls(), m_pageVob->durations(), m_pageVob->chapters()); + QDomDocument doc; QDomElement dvdproject = doc.createElement("dvdproject"); QString profile; @@ -612,10 +651,59 @@ void DvdWizard::slotSave() else profile = "dv_ntsc"; if (m_pageVob->isWide()) profile.append("_wide"); dvdproject.setAttribute("profile", profile); - doc.appendChild(dvdproject); - //for (int i = 0; i < + dvdproject.setAttribute("tmp_folder", m_status.tmp_folder->text()); + dvdproject.setAttribute("iso_image", m_status.iso_image->text()); + + dvdproject.setAttribute("intro_movie", m_pageVob->introMovie()); + doc.appendChild(dvdproject); + QDomElement menu = m_pageMenu->toXml(); + if (!menu.isNull()) dvdproject.appendChild(doc.importNode(menu, true)); + QDomElement chaps = m_pageChapters->toXml(); + if (!chaps.isNull()) dvdproject.appendChild(doc.importNode(chaps, true)); + + QFile file(url.path()); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + kWarning() << "////// ERROR writing to file: " << url.path(); + KMessageBox::error(this, i18n("Cannot write to file %1", url.path())); + return; + } + + file.write(doc.toString().toUtf8()); + if (file.error() != QFile::NoError) { + KMessageBox::error(this, i18n("Cannot write to file %1", url.path())); + } + file.close(); } +void DvdWizard::slotLoad() +{ + KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), "*.kdvd"); + if (url.isEmpty()) return; + QDomDocument doc; + QFile file(url.path()); + doc.setContent(&file, false); + file.close(); + QDomElement dvdproject = doc.documentElement(); + if (dvdproject.tagName() != "dvdproject") { + KMessageBox::error(this, i18n("File %1 is not a Kdenlive project file.", url.path())); + return; + } + + QString profile = dvdproject.attribute("profile"); + m_pageVob->setProfile(profile); + + m_status.tmp_folder->setPath(dvdproject.attribute("tmp_folder")); + m_status.iso_image->setPath(dvdproject.attribute("iso_image")); + m_pageVob->setIntroMovie(dvdproject.attribute("intro_movie")); + + QDomNodeList vobs = doc.elementsByTagName("vob"); + m_pageVob->clear(); + 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(dvdproject.firstChildElement("menu")); +} diff --git a/src/dvdwizard.h b/src/dvdwizard.h index e859d01a..4ef8a9ae 100644 --- a/src/dvdwizard.h +++ b/src/dvdwizard.h @@ -66,7 +66,10 @@ private slots: void slotBurn(); void slotGenerate(); void slotAbort(); + void slotLoad(); void slotSave(); + void slotShowRenderInfo(); + void slotShowIsoInfo(); }; #endif diff --git a/src/dvdwizardchapters.cpp b/src/dvdwizardchapters.cpp index 549b60d1..cf57dd10 100644 --- a/src/dvdwizardchapters.cpp +++ b/src/dvdwizardchapters.cpp @@ -32,7 +32,6 @@ DvdWizardChapters::DvdWizardChapters(bool isPal, QWidget *parent) : connect(m_view.vob_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateChaptersList())); connect(m_view.button_add, SIGNAL(clicked()), this, SLOT(slotAddChapter())); connect(m_view.button_delete, SIGNAL(clicked()), this, SLOT(slotRemoveChapter())); - connect(m_view.button_save, SIGNAL(clicked()), this, SLOT(slotSaveChapter())); connect(m_view.chapters_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotGoToChapter())); // Build monitor for chapters @@ -80,7 +79,6 @@ void DvdWizardChapters::slotUpdateChaptersList() m_view.chapters_list->addItems(chaptersString); bool modified = m_view.vob_list->itemData(m_view.vob_list->currentIndex(), Qt::UserRole + 2).toInt(); - m_view.button_save->setEnabled(modified); } void DvdWizardChapters::slotAddChapter() @@ -107,7 +105,6 @@ void DvdWizardChapters::slotAddChapter() m_view.vob_list->setItemData(m_view.vob_list->currentIndex(), 1, Qt::UserRole + 2); m_view.chapters_list->clear(); m_view.chapters_list->addItems(chaptersString); - m_view.button_save->setEnabled(true); } void DvdWizardChapters::slotRemoveChapter() @@ -128,7 +125,6 @@ void DvdWizardChapters::slotRemoveChapter() } m_view.chapters_list->clear(); m_view.chapters_list->addItems(chaptersString); - m_view.button_save->setEnabled(true); } void DvdWizardChapters::slotGoToChapter() @@ -136,27 +132,7 @@ void DvdWizardChapters::slotGoToChapter() m_monitor->setTimePos(m_view.chapters_list->currentItem()->text() + ":00"); } -void DvdWizardChapters::slotGetChaptersList(int ix) -{ - QString url = m_view.vob_list->itemText(ix); - if (QFile::exists(url + ".dvdchapter")) { - // insert chapters as children - QFile file(url + ".dvdchapter"); - if (file.open(QIODevice::ReadOnly)) { - QDomDocument doc; - doc.setContent(&file); - file.close(); - QDomNodeList chapters = doc.elementsByTagName("chapter"); - QStringList chaptersList; - for (int j = 0; j < chapters.count(); j++) { - chaptersList.append(QString::number(chapters.at(j).toElement().attribute("time").toInt())); - } - m_view.vob_list->setItemData(ix, chaptersList, Qt::UserRole + 1); - } - } -} - -void DvdWizardChapters::setVobFiles(bool isPal, const QStringList movies, const QStringList durations) +void DvdWizardChapters::setVobFiles(bool isPal, const QStringList movies, const QStringList durations, const QStringList chapters) { m_isPal = isPal; if (m_isPal) m_tc.setFormat(25); @@ -164,24 +140,25 @@ void DvdWizardChapters::setVobFiles(bool isPal, const QStringList movies, const m_manager->resetProfiles(m_tc); m_monitor->resetProfile(); - if (m_view.vob_list->count() == movies.count()) { - bool equal = true; - for (int i = 0; i < movies.count(); i++) { - if (movies.at(i) != m_view.vob_list->itemText(i)) { - equal = false; - break; - } - } - if (equal) return; - } m_view.vob_list->clear(); for (int i = 0; i < movies.count(); i++) { m_view.vob_list->addItem(movies.at(i), durations.at(i)); - slotGetChaptersList(i); + m_view.vob_list->setItemData(i, chapters.at(i).split(';'), Qt::UserRole + 1); } slotUpdateChaptersList(); } +QMap DvdWizardChapters::chaptersData() const +{ + QMap result; + int max = m_view.vob_list->count(); + for (int i = 0; i < max; i++) { + QString chapters = m_view.vob_list->itemData(i, Qt::UserRole + 1).toStringList().join(";"); + result.insert(m_view.vob_list->itemText(i), chapters); + } + return result; +} + QStringList DvdWizardChapters::selectedTitles() const { QStringList result; @@ -220,33 +197,17 @@ QStringList DvdWizardChapters::selectedTargets() const return result; } -void DvdWizardChapters::slotSaveChapter() + +QDomElement DvdWizardChapters::toXml() const { QDomDocument doc; - QDomElement chapters = doc.createElement("chapters"); - chapters.setAttribute("fps", m_tc.fps()); - doc.appendChild(chapters); - - QStringList chaptersList = m_view.vob_list->itemData(m_view.vob_list->currentIndex(), Qt::UserRole + 1).toStringList(); - - for (int i = 0; i < chaptersList.count(); i++) { - QDomElement chapter = doc.createElement("chapter"); - chapters.appendChild(chapter); - chapter.setAttribute("title", i18n("Chapter %1", i)); - chapter.setAttribute("time", chaptersList.at(i)); - } - // save chapters file - QFile file(m_view.vob_list->currentText() + ".dvdchapter"); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - kWarning() << "////// ERROR writing DVD CHAPTER file: " << m_view.vob_list->currentText() + ".dvdchapter"; - } else { - file.write(doc.toString().toUtf8()); - if (file.error() != QFile::NoError) - kWarning() << "////// ERROR writing DVD CHAPTER file: " << m_view.vob_list->currentText() + ".dvdchapter"; - else { - m_view.vob_list->setItemData(m_view.vob_list->currentIndex(), 0, Qt::UserRole + 2); - m_view.button_save->setEnabled(false); - } - file.close(); + QDomElement xml = doc.createElement("xml"); + doc.appendChild(xml); + for (int i = 0; i < m_view.vob_list->count(); i++) { + QDomElement vob = doc.createElement("vob"); + vob.setAttribute("file", m_view.vob_list->itemText(i)); + vob.setAttribute("chapters", m_view.vob_list->itemData(i, Qt::UserRole + 1).toStringList().join(";")); + xml.appendChild(vob); } + return doc.documentElement(); } diff --git a/src/dvdwizardchapters.h b/src/dvdwizardchapters.h index 77887d53..2291176f 100644 --- a/src/dvdwizardchapters.h +++ b/src/dvdwizardchapters.h @@ -38,12 +38,13 @@ public: virtual ~DvdWizardChapters(); virtual bool isComplete() const; void changeProfile(bool isPal); - void slotGetChaptersList(int ix); void setPal(bool isPal); - void setVobFiles(bool isPal, const QStringList movies, const QStringList durations); + void setVobFiles(bool isPal, const QStringList movies, const QStringList durations, const QStringList chapters); QStringList selectedTitles() const; QStringList selectedTargets() const; QStringList chapters(int ix) const; + QDomElement toXml() const; + QMap chaptersData() const; private: Ui::DvdWizardChapters_UI m_view; @@ -58,7 +59,6 @@ private slots: void slotAddChapter(); void slotRemoveChapter(); void slotGoToChapter(); - void slotSaveChapter(); }; #endif diff --git a/src/dvdwizardmenu.cpp b/src/dvdwizardmenu.cpp index bfd0e703..ab7390d6 100644 --- a/src/dvdwizardmenu.cpp +++ b/src/dvdwizardmenu.cpp @@ -503,3 +503,104 @@ bool DvdWizardMenu::isPalMenu() const { return m_isPal; } + +QDomElement DvdWizardMenu::toXml() const +{ + QDomDocument doc; + if (!m_view.create_menu->isChecked()) return doc.documentElement(); + QDomElement xml = doc.createElement("menu"); + doc.appendChild(xml); + if (m_view.background_list->currentIndex() == 0) { + // Color bg + xml.setAttribute("background_color", m_view.background_color->color().name()); + } else if (m_view.background_list->currentIndex() == 1) { + // Image bg + xml.setAttribute("background_image", m_view.background_image->text()); + } else { + // Video bg + xml.setAttribute("background_video", m_view.background_image->text()); + } + xml.setAttribute("text_color", m_view.text_color->color().name()); + xml.setAttribute("selected_color", m_view.selected_color->color().name()); + xml.setAttribute("highlighted_color", m_view.highlighted_color->color().name()); + + QList list = m_scene->items(); + int buttonCount = 0; + + for (int i = 0; i < list.count(); i++) { + if (list.at(i)->type() == QGraphicsItem::UserType + 1) { + buttonCount++; + DvdButton *button = static_cast < DvdButton* >(list.at(i)); + QDomElement xmlbutton = doc.createElement("button"); + xmlbutton.setAttribute("target", button->target()); + xmlbutton.setAttribute("command", button->command()); + xmlbutton.setAttribute("backtomenu", button->backMenu()); + xmlbutton.setAttribute("posx", button->pos().x()); + xmlbutton.setAttribute("posy", button->pos().y()); + xmlbutton.setAttribute("text", button->toPlainText()); + QFont font = button->font(); + xmlbutton.setAttribute("font_size", font.pixelSize()); + xmlbutton.setAttribute("font_family", font.family()); + xml.appendChild(xmlbutton); + } + } + return doc.documentElement(); +} + + +void DvdWizardMenu::loadXml(QDomElement xml) +{ + kDebug() << "// LOADING MENU"; + if (xml.isNull()) return; + kDebug() << "// LOADING MENU 1"; + m_view.create_menu->setChecked(true) ; + if (xml.hasAttribute("background_color")) { + m_view.background_list->setCurrentIndex(0); + m_view.background_color->setColor(xml.attribute("background_color")); + } else if (xml.hasAttribute("background_image")) { + m_view.background_list->setCurrentIndex(1); + m_view.background_image->setPath(xml.attribute("background_image")); + } else if (xml.hasAttribute("background_video")) { + m_view.background_list->setCurrentIndex(2); + m_view.background_image->setPath(xml.attribute("background_video")); + } + + m_view.text_color->setColor(xml.attribute("text_color")); + m_view.selected_color->setColor(xml.attribute("selected_color")); + m_view.highlighted_color->setColor(xml.attribute("highlighted_color")); + + QDomNodeList buttons = xml.elementsByTagName("button"); + kDebug() << "// LOADING MENU 2" << buttons.count(); + + if (buttons.count() > 0) { + // Clear existing buttons + QList list = m_scene->items(); + + for (int i = 0; i < list.count(); i++) { + if (list.at(i)->type() == QGraphicsItem::UserType + 1) { + delete list.at(i); + i--; + } + } + } + + for (int i = 0; i < buttons.count(); i++) { + QDomElement e = buttons.at(i).toElement(); + // create menu button + DvdButton *button = new DvdButton(e.attribute("text")); + QFont font(e.attribute("font_family")); + font.setPixelSize(e.attribute("font_size").toInt()); + font.setStyleStrategy(QFont::NoAntialias); + button->setFont(font); + button->setTarget(e.attribute("target").toInt(), e.attribute("command")); + button->setBackMenu(e.attribute("backtomenu").toInt()); + button->setDefaultTextColor(m_view.text_color->color()); + button->setZValue(4); + button->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); + QRectF r = button->sceneBoundingRect(); + m_scene->addItem(button); + button->setPos(e.attribute("posx").toDouble(), e.attribute("posy").toDouble()); + + } +} + diff --git a/src/dvdwizardmenu.h b/src/dvdwizardmenu.h index e2987ee3..d1ac8371 100644 --- a/src/dvdwizardmenu.h +++ b/src/dvdwizardmenu.h @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -129,6 +130,8 @@ public: QString menuMoviePath() const; bool isPalMenu() const; void changeProfile(bool isPal); + QDomElement toXml() const; + void loadXml(QDomElement xml); private: Ui::DvdWizardMenu_UI m_view; diff --git a/src/dvdwizardvob.cpp b/src/dvdwizardvob.cpp index f75ac9c9..f88fab2f 100644 --- a/src/dvdwizardvob.cpp +++ b/src/dvdwizardvob.cpp @@ -86,23 +86,38 @@ DvdWizardVob::~DvdWizardVob() } -void DvdWizardVob::slotAddVobFile(KUrl url) +void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters) { if (url.isEmpty()) url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), "video/mpeg", this, i18n("Add new video file")); if (url.isEmpty()) return; QFile f(url.path()); qint64 fileSize = f.size(); QString profilename; - if (m_view.dvd_profile->currentIndex() == 0) profilename = "dv_pal"; - else profilename = "dv_ntsc"; - Mlt::Profile profile((char*) profilename.data()); + switch (m_view.dvd_profile->currentIndex()) { + case 1: + profilename = "dv_pal_wide"; + break; + case 2: + profilename = "dv_ntsc"; + break; + case 3: + profilename = "dv_ntsc_wide"; + break; + default: + profilename = "dv_pal"; + break; + } + + char *tmp = (char*) qstrdup(profilename.toUtf8().data()); + Mlt::Profile profile(tmp); + delete[] tmp; QTreeWidgetItem *item = new QTreeWidgetItem(m_view.vobs_list, QStringList() << url.path() << QString() << KIO::convertSize(fileSize)); item->setData(0, Qt::UserRole, fileSize); item->setIcon(0, KIcon("video-x-generic")); QPixmap pix(60, 45); - char *tmp = (char *) qstrdup(url.path().toUtf8().data()); + tmp = (char *) qstrdup(url.path().toUtf8().data()); Mlt::Producer *producer = new Mlt::Producer(profile, tmp); delete[] tmp; @@ -115,6 +130,24 @@ void DvdWizardVob::slotAddVobFile(KUrl url) } delete producer; + if (chapters.isEmpty() == false) { + item->setData(1, Qt::UserRole + 1, chapters); + } else if (QFile::exists(url.path() + ".dvdchapter")) { + // insert chapters as children + QFile file(url.path() + ".dvdchapter"); + if (file.open(QIODevice::ReadOnly)) { + QDomDocument doc; + doc.setContent(&file); + file.close(); + QDomNodeList chapters = doc.elementsByTagName("chapter"); + QStringList chaptersList; + for (int j = 0; j < chapters.count(); j++) { + chaptersList.append(QString::number(chapters.at(j).toElement().attribute("time").toInt())); + } + item->setData(1, Qt::UserRole + 1, chaptersList.join(";")); + } + } + slotCheckVobList(); } @@ -122,14 +155,29 @@ void DvdWizardVob::changeFormat() { int max = m_view.vobs_list->topLevelItemCount(); QString profilename; - if (m_view.dvd_profile->currentIndex() == 0) profilename = "dv_pal"; - else profilename = "dv_ntsc"; - Mlt::Profile profile((char*) profilename.data()); + switch (m_view.dvd_profile->currentIndex()) { + case 1: + profilename = "dv_pal_wide"; + break; + case 2: + profilename = "dv_ntsc"; + break; + case 3: + profilename = "dv_ntsc_wide"; + break; + default: + profilename = "dv_pal"; + break; + } + + char *tmp = (char*) qstrdup(profilename.toUtf8().data()); + Mlt::Profile profile(tmp); + delete[] tmp; QPixmap pix(180, 135); for (int i = 0; i < max; i++) { QTreeWidgetItem *item = m_view.vobs_list->topLevelItem(i); - char *tmp = (char *) qstrdup(item->text(0).toUtf8().data()); + tmp = (char *) qstrdup(item->text(0).toUtf8().data()); Mlt::Producer *producer = new Mlt::Producer(profile, tmp); delete[] tmp; @@ -195,6 +243,27 @@ QStringList DvdWizardVob::durations() const return result; } +QStringList DvdWizardVob::chapters() const +{ + QStringList result; + QString path; + int max = m_view.vobs_list->topLevelItemCount(); + for (int i = 0; i < max; i++) { + QTreeWidgetItem *item = m_view.vobs_list->topLevelItem(i); + if (item) result.append(item->data(1, Qt::UserRole + 1).toString()); + } + return result; +} + +void DvdWizardVob::updateChapters(QMap chaptersdata) +{ + int max = m_view.vobs_list->topLevelItemCount(); + for (int i = 0; i < max; i++) { + QTreeWidgetItem *item = m_view.vobs_list->topLevelItem(i); + item->setData(1, Qt::UserRole + 1, chaptersdata.value(item->text(0))); + } +} + int DvdWizardVob::duration(int ix) const { int result = -1; @@ -212,6 +281,13 @@ QString DvdWizardVob::introMovie() const return m_view.intro_vob->url().path(); } +void DvdWizardVob::setIntroMovie(const QString path) +{ + m_view.intro_vob->setPath(path); + m_view.use_intro->setChecked(path.isEmpty() == false); +} + + void DvdWizardVob::slotCheckVobList() { emit completeChanged(); @@ -267,5 +343,15 @@ bool DvdWizardVob::isWide() const return (m_view.dvd_profile->currentIndex() == 1 || m_view.dvd_profile->currentIndex() == 3); } +void DvdWizardVob::setProfile(const QString profile) +{ + if (profile == "dv_pal") m_view.dvd_profile->setCurrentIndex(0); + else if (profile == "dv_pal_wide") m_view.dvd_profile->setCurrentIndex(1); + else if (profile == "dv_ntsc") m_view.dvd_profile->setCurrentIndex(2); + else if (profile == "dv_ntsc_wide") m_view.dvd_profile->setCurrentIndex(3); +} - +void DvdWizardVob::clear() +{ + m_view.vobs_list->clear(); +} \ No newline at end of file diff --git a/src/dvdwizardvob.h b/src/dvdwizardvob.h index 98c666a5..6fd5b7fa 100644 --- a/src/dvdwizardvob.h +++ b/src/dvdwizardvob.h @@ -48,6 +48,11 @@ public: bool isWide() const; int duration(int ix) const; QStringList durations() const; + QStringList chapters() const; + void setProfile(const QString profile); + void clear(); + void updateChapters(QMap chaptersdata); + void setIntroMovie(const QString path); private: Ui::DvdWizardVob_UI m_view; @@ -57,9 +62,11 @@ private: KCapacityBar *m_capacityBar; #endif +public slots: + void slotAddVobFile(KUrl url = KUrl(), const QString &chapters = QString()); + private slots: void slotCheckVobList(); - void slotAddVobFile(KUrl url = KUrl()); void slotDeleteVobFile(); void slotItemUp(); void slotItemDown(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7c8efd11..46f0fd9c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1442,7 +1442,7 @@ void MainWindow::recoverFiles(QList staleFiles) void MainWindow::parseProfiles(const QString &mltPath) { - //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <