]> git.sesse.net Git - kdenlive/commitdiff
Fix handling of several movies in dvd, improve chapters handling
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 14 May 2009 13:43:23 +0000 (13:43 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 14 May 2009 13:43:23 +0000 (13:43 +0000)
svn path=/trunk/kdenlive/; revision=3386

src/dvdwizard.cpp
src/dvdwizardmenu.cpp
src/dvdwizardmenu.h
src/dvdwizardvob.cpp

index 632b625afeae9fb0c9d2747c83f620d753689276..5a38f92dd11f66d128be490503c6b4dec5c2c2a1 100644 (file)
@@ -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());
index 30803ded0f185db011aa383f46efdb7da13da643..fbe794013eb78c0682a04a291571e5fadaf33311 100644 (file)
@@ -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<QGraphicsItem *> 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<QGraphicsItem *> 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 <QString, QRect> 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;
index ef37af245a5444419bcae2b253e68811439cfeab..68ba88fdc0f664ad1e5a721965e0690eb5e7e7ac 100644 (file)
@@ -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
index c49d116ef6197d994cd036c5bb1621bede86b8c9..25fa8b5713598eb8e2f90a7ee3b17702e37ec26b 100644 (file)
@@ -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));
                     }
                 }