From d8dcc0d93068a347710cb2fab7f4dbeba44bd19f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 14 May 2009 13:43:23 +0000 Subject: [PATCH 1/1] Fix handling of several movies in dvd, improve chapters handling svn path=/trunk/kdenlive/; revision=3386 --- src/dvdwizard.cpp | 50 +++++++++++++++++-------------------------- src/dvdwizardmenu.cpp | 38 ++++++++++++++++++++++++++------ src/dvdwizardmenu.h | 10 ++++++++- src/dvdwizardvob.cpp | 4 ++-- 4 files changed, 63 insertions(+), 39 deletions(-) diff --git a/src/dvdwizard.cpp b/src/dvdwizard.cpp index 632b625a..5a38f92d 100644 --- a/src/dvdwizard.cpp +++ b/src/dvdwizard.cpp @@ -362,10 +362,14 @@ void DvdWizard::generateDvd() QDomElement pgc = dvddoc.createElement("pgc"); pgc.setAttribute("entry", "root"); menus.appendChild(pgc); + QDomElement pre = dvddoc.createElement("pre"); + pgc.appendChild(pre); + QDomText nametext = dvddoc.createTextNode("{g1 = 0;}"); + pre.appendChild(nametext); for (int i = 0; i < buttons.count(); i++) { QDomElement button = dvddoc.createElement("button"); button.setAttribute("name", 'b' + QString::number(i)); - QDomText nametext = dvddoc.createTextNode("jump " + buttonsTarget.at(i) + ';'); + nametext = dvddoc.createTextNode('{' + buttonsTarget.at(i) + ";}"); button.appendChild(nametext); pgc.appendChild(button); } @@ -380,19 +384,15 @@ void DvdWizard::generateDvd() QStringList voburls = m_pageVob->selectedUrls(); - QDomElement pgc2 = dvddoc.createElement("pgc"); - titles.appendChild(pgc2); - if (m_pageMenu->createMenu()) { - QDomElement post = dvddoc.createElement("post"); - QDomText call = dvddoc.createTextNode("call menu;"); - post.appendChild(call); - pgc2.appendChild(post); - } + QDomElement pgc2; for (int i = 0; i < voburls.count(); i++) { if (!voburls.at(i).isEmpty()) { // Add vob entry + pgc2 = dvddoc.createElement("pgc"); + pgc2.setAttribute("pause", 0); + titles.appendChild(pgc2); QDomElement vob = dvddoc.createElement("vob"); vob.setAttribute("file", voburls.at(i)); if (m_pageVob->useChapters()) { @@ -413,30 +413,20 @@ void DvdWizard::generateDvd() } } pgc2.appendChild(vob); + if (m_pageMenu->createMenu()) { + QDomElement post = dvddoc.createElement("post"); + QDomText call; + if (i == voburls.count() - 1) call = dvddoc.createTextNode("{g1 = 0; call menu;}"); + else { + call = dvddoc.createTextNode("{if ( g1 eq 999 ) { call menu; } jump title " + QString::number(i + 2) + ";}"); + } + post.appendChild(call); + pgc2.appendChild(post); + } } } - /* - // create one pgc for each video - for (int i = 0; i < voburls.count(); i++) { - if (!voburls.at(i).isEmpty()) { - // Add vob entry - - QDomElement pgc2 = dvddoc.createElement("pgc"); - titles.appendChild(pgc2); - if (m_pageMenu->createMenu()) { - QDomElement post = dvddoc.createElement("post"); - QDomText call = dvddoc.createTextNode("call vmgm menu 1;"); - post.appendChild(call); - pgc2.appendChild(post); - } - - QDomElement vob = dvddoc.createElement("vob"); - vob.setAttribute("file", voburls.at(i)); - pgc2.appendChild(vob); - } - } - */ + QFile data2(m_authorFile.fileName()); if (data2.open(QFile::WriteOnly)) { data2.write(dvddoc.toString().toUtf8()); diff --git a/src/dvdwizardmenu.cpp b/src/dvdwizardmenu.cpp index 30803ded..fbe79401 100644 --- a/src/dvdwizardmenu.cpp +++ b/src/dvdwizardmenu.cpp @@ -38,9 +38,8 @@ DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget *parent) : m_view.add_button->setIcon(KIcon("document-new")); m_view.delete_button->setIcon(KIcon("trash-empty")); - // TODO: re-enable add button options - /*m_view.add_button->setVisible(false); - m_view.delete_button->setVisible(false);*/ + m_view.add_button->setToolTip(i18n("Add new button")); + m_view.delete_button->setToolTip(i18n("Delete current button")); m_view.menu_profile->addItems(QStringList() << i18n("PAL") << i18n("NTSC")); @@ -105,6 +104,7 @@ DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget *parent) : connect(m_view.background_list, SIGNAL(activated(int)), this, SLOT(checkBackgroundType(int))); connect(m_view.target_list, SIGNAL(activated(int)), this, SLOT(setButtonTarget(int))); + connect(m_view.back_to_menu, SIGNAL(toggled(bool)), this, SLOT(setBackToMenu(bool))); connect(m_view.add_button, SIGNAL(pressed()), this, SLOT(addButton())); connect(m_view.delete_button, SIGNAL(pressed()), this, SLOT(deleteButton())); @@ -159,7 +159,8 @@ bool DvdWizardMenu::isComplete() const if (targets.contains(0)) return true; // ... or that each video file has a button for (int i = m_view.target_list->count() - 1; i > 0; i--) { - if (!targets.contains(i)) return false; + // If there is a vob file entry and it has no button assigned, don't allow to go further + if (m_view.target_list->itemIcon(i).isNull() == false && !targets.contains(i)) return false; } return true; } @@ -177,6 +178,19 @@ void DvdWizardMenu::setButtonTarget(int ix) emit completeChanged(); } +void DvdWizardMenu::setBackToMenu(bool backToMenu) +{ + QList list = m_scene->selectedItems(); + for (int i = 0; i < list.count(); i++) { + if (list.at(i)->type() == QGraphicsItem::UserType + 1) { + DvdButton *button = static_cast < DvdButton* >(list.at(i)); + button->setBackMenu(backToMenu); + break; + } + } + emit completeChanged(); +} + void DvdWizardMenu::buttonChanged() { QList list = m_scene->selectedItems(); @@ -187,11 +201,13 @@ void DvdWizardMenu::buttonChanged() m_view.font_size->blockSignals(true); m_view.font_family->blockSignals(true); m_view.target_list->blockSignals(true); + m_view.back_to_menu->blockSignals(true); foundButton = true; m_view.tabWidget->widget(0)->setEnabled(true); DvdButton *button = static_cast < DvdButton* >(list.at(i)); m_view.target_list->setCurrentIndex(button->target()); m_view.play_text->setText(button->toPlainText()); + m_view.back_to_menu->setChecked(button->backMenu()); QFont font = button->font(); m_view.font_size->setValue(font.pixelSize()); m_view.font_family->setCurrentFont(font); @@ -199,6 +215,7 @@ void DvdWizardMenu::buttonChanged() m_view.font_size->blockSignals(false); m_view.font_family->blockSignals(false); m_view.target_list->blockSignals(false); + m_view.back_to_menu->blockSignals(false); break; } } @@ -270,9 +287,16 @@ void DvdWizardMenu::setTargets(QStringList list, QStringList targetlist) { m_view.target_list->clear(); m_view.target_list->addItem(i18n("Play All"), "title 1"); + int movieCount = 0; for (int i = 0; i < list.count(); i++) { - m_view.target_list->addItem(list.at(i), targetlist.at(i)); + if (targetlist.at(i).contains("chapter")) + m_view.target_list->addItem(list.at(i), targetlist.at(i)); + else { + m_view.target_list->addItem(KIcon("video-x-generic"), list.at(i), targetlist.at(i)); + movieCount++; + } } + m_view.back_to_menu->setHidden(movieCount == 1); } void DvdWizardMenu::checkBackgroundType(int ix) @@ -473,7 +497,9 @@ QMap DvdWizardMenu::buttonsInfo() // Make sure y1 is not odd (requested by spumux) if (r.height() % 2 == 1) r.setHeight(r.height() + 1); if (r.y() % 2 == 1) r.setY(r.y() - 1); - info.insertMulti(button->command(), r); + QString command = button->command(); + if (button->backMenu()) command.prepend("g1 = 999;"); + info.insertMulti(command, r); } } return info; diff --git a/src/dvdwizardmenu.h b/src/dvdwizardmenu.h index ef37af24..68ba88fd 100644 --- a/src/dvdwizardmenu.h +++ b/src/dvdwizardmenu.h @@ -56,7 +56,7 @@ class DvdButton : public QGraphicsTextItem { public: - DvdButton(const QString & text): QGraphicsTextItem(text), m_target(0), m_command(QString("title 1")) {} + DvdButton(const QString & text): QGraphicsTextItem(text), m_target(0), m_command(QString("jump title 1")), m_backToMenu(false) {} enum { Type = UserType + 1 }; void setTarget(int t, QString c) { m_target = t; @@ -68,14 +68,21 @@ public: QString command() const { return m_command; } + bool backMenu() const { + return m_backToMenu; + } int type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } + void setBackMenu(bool back) { + m_backToMenu = back; + } private: int m_target; QString m_command; + bool m_backToMenu; protected: @@ -146,6 +153,7 @@ private slots: void deleteButton(); void updateColor(); void updateColor(QColor c); + void setBackToMenu(bool backToMenu); }; #endif diff --git a/src/dvdwizardvob.cpp b/src/dvdwizardvob.cpp index c49d116e..25fa8b57 100644 --- a/src/dvdwizardvob.cpp +++ b/src/dvdwizardvob.cpp @@ -131,7 +131,7 @@ QStringList DvdWizardVob::selectedTargets() const for (int i = 0; i < allUrls.count(); i++) { path = allUrls.at(i)->url().path(); if (!path.isEmpty()) { - result.append("title " + QString::number(i)); + result.append("jump title " + QString::number(i + 1)); if (useChapters() && QFile::exists(path + ".dvdchapter")) { // insert chapters as targets QFile file(path + ".dvdchapter"); @@ -142,7 +142,7 @@ QStringList DvdWizardVob::selectedTargets() const QDomNodeList chapters = doc.elementsByTagName("chapter"); QStringList chaptersList; for (int j = 0; j < chapters.count(); j++) { - result.append("title " + QString::number(i + 1) + " chapter " + QString::number(j + 1)); + result.append("jump title " + QString::number(i + 1) + " chapter " + QString::number(j + 1)); } } -- 2.39.2