]> git.sesse.net Git - kdenlive/commitdiff
Updated DVD wizard (added load/save dvd projects)
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 24 May 2009 23:26:30 +0000 (23:26 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 24 May 2009 23:26:30 +0000 (23:26 +0000)
svn path=/trunk/kdenlive/; revision=3415

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

index 938f8ca6c8c110f20d11b6dc1d4b7133b83dacd2..a22e0d2a860e6c2eeb35aab1b648c32eef36eeef 100644 (file)
@@ -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<QWizard::WizardButton> 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("<br><b>");
+
+        //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("<br><b>");
+        //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"));
+}
index e859d01ac7b69e816a68d56f84f8dd4d88dc4d8b..4ef8a9ae422876cf2868e85054eb91b42af2f3cf 100644 (file)
@@ -66,7 +66,10 @@ private slots:
     void slotBurn();
     void slotGenerate();
     void slotAbort();
+    void slotLoad();
     void slotSave();
+    void slotShowRenderInfo();
+    void slotShowIsoInfo();
 };
 
 #endif
index 549b60d16cb78d6ee85c9d66e6358925d4bcc673..cf57dd103a1e02d550aa717ecfa1a33d1d0533b8 100644 (file)
@@ -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 <QString, QString> DvdWizardChapters::chaptersData() const
+{
+    QMap <QString, QString> 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();
 }
index 77887d53d53b20eca536837a3e3707bb278771e3..2291176f8c9789a9c628839a9f6b7252ae8b154c 100644 (file)
@@ -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 <QString, QString> chaptersData() const;
 
 private:
     Ui::DvdWizardChapters_UI m_view;
@@ -58,7 +59,6 @@ private slots:
     void slotAddChapter();
     void slotRemoveChapter();
     void slotGoToChapter();
-    void slotSaveChapter();
 };
 
 #endif
index bfd0e7037c7c861b254e3e9c3e693240bd1ae7b5..ab7390d67c633187006996c387f404ff54c804ec 100644 (file)
@@ -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<QGraphicsItem *> 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<QGraphicsItem *> 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());
+
+    }
+}
+
index e2987ee356519d33b52ee8cd825e008c4b0fdfcc..d1ac8371707eb38cf2b3d85709d0c19ddb584545 100644 (file)
@@ -26,6 +26,7 @@
 #include <QGraphicsTextItem>
 #include <QGraphicsPixmapItem>
 #include <QGraphicsRectItem>
+#include <QDomElement>
 
 #include <KDebug>
 
@@ -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;
index f75ac9c968e9ec87e6aa5d25ad9366d56a1536fd..f88fab2fc604114d66843de4eeb25da7cfef9e31 100644 (file)
@@ -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 <QString, QString> 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
index 98c666a53ae108ca7099cdbf884f275ee31e26f6..6fd5b7fa31e08efbb146c3db0c00298c86b46f00 100644 (file)
@@ -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 <QString, QString> 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();
index 7c8efd11e4a8f7789c658a80efe2df236e77e8ca..46f0fd9c81338a378f28e377d2a4aeb4f3d1c1eb 100644 (file)
@@ -1442,7 +1442,7 @@ void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
 
 void MainWindow::parseProfiles(const QString &mltPath)
 {
-    //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
+    // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
 
     //KdenliveSettings::setDefaulttmpfolder();
     if (!mltPath.isEmpty()) {
@@ -2639,7 +2639,7 @@ void MainWindow::slotShowTimeline(bool show)
     }
 }
 
-void MainWindow::slotMaximizeCurrent(bool show)
+void MainWindow::slotMaximizeCurrent(bool /*show*/)
 {
     //TODO: is there a way to maximize current widget?
     //if (show == true)