]> git.sesse.net Git - kdenlive/commitdiff
start improving dvd wizard
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 19 Jan 2009 18:18:59 +0000 (18:18 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 19 Jan 2009 18:18:59 +0000 (18:18 +0000)
svn path=/branches/KDE4/; revision=2933

src/CMakeLists.txt
src/dvdwizard.cpp
src/dvdwizard.h
src/dvdwizardvob.cpp [new file with mode: 0644]
src/dvdwizardvob.h [new file with mode: 0644]
src/mainwindow.cpp

index d85e13384d3095f90369a5d1b027602ded69bbd2..b798b74d8cab5b016a76153e6f8a57180e2b8ec5 100644 (file)
@@ -146,6 +146,7 @@ set(kdenlive_SRCS
   addtrackcommand.cpp
   changetrackcommand.cpp
   movegroupcommand.cpp
+  dvdwizardvob.cpp
   dvdwizard.cpp
 )
 
index 97fd7ba1ecd25a8c764ae9c551732aab9fc1c243..1cdff176dfa382f788197f5d63e64b84b9a58be3 100644 (file)
 DvdWizard::DvdWizard(const QString &url, const QString &profile, QWidget *parent): QWizard(parent), m_profile(profile) {
     //setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
     setAttribute(Qt::WA_DeleteOnClose);
-    QWizardPage *page1 = new QWizardPage;
-    page1->setTitle(i18n("Select Files For Your Dvd"));
-    m_vob.setupUi(page1);
-    addPage(page1);
-    m_vob.intro_vob->setEnabled(false);
-    m_vob.vob_1->setFilter("video/mpeg");
-    m_vob.intro_vob->setFilter("video/mpeg");
-    connect(m_vob.use_intro, SIGNAL(toggled(bool)), m_vob.intro_vob, SLOT(setEnabled(bool)));
-    connect(m_vob.vob_1, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
-    if (!url.isEmpty()) m_vob.vob_1->setPath(url);
+    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_width = 720;
     if (m_profile.startsWith("dv_pal")) m_height = 576;
@@ -154,32 +149,6 @@ void DvdWizard::slotPageChanged(int page) {
     }
 }
 
-void DvdWizard::slotCheckVobList(const QString &text) {
-    QList<KUrlRequester *> allUrls = m_vob.vob_list->findChildren<KUrlRequester *>();
-    int count = allUrls.count();
-    kDebug() << "// FOUND " << count << " URLS";
-    if (count == 1) {
-        if (text.isEmpty()) return;
-        // insert second urlrequester
-        KUrlRequester *vob = new KUrlRequester(this);
-        vob->setFilter("video/mpeg");
-        m_vob.vob_list->layout()->addWidget(vob);
-        connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
-    } else if (text.isEmpty()) {
-        if (allUrls.at(count - 1)->url().path().isEmpty() && allUrls.at(count - 2)->url().path().isEmpty()) {
-            // The last 2 urlrequesters are empty, remove last one
-            KUrlRequester *vob = allUrls.takeLast();
-            delete vob;
-        }
-    } else {
-        if (allUrls.at(count - 1)->url().path().isEmpty()) return;
-        KUrlRequester *vob = new KUrlRequester(this);
-        vob->setFilter("video/mpeg");
-        m_vob.vob_list->layout()->addWidget(vob);
-        connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
-    }
-}
-
 void DvdWizard::buildColor() {
     m_color->setBrush(m_menu.background_color->color());
 }
@@ -436,12 +405,13 @@ void DvdWizard::generateDvd() {
         post.appendChild(call);
         pgc2.appendChild(post);
     }
-    QList<KUrlRequester *> allUrls = m_vob.vob_list->findChildren<KUrlRequester *>();
-    for (int i = 0; i < allUrls.count(); i++) {
-        if (!allUrls.at(i)->url().path().isEmpty()) {
+
+    QStringList voburls = m_pageVob->selectedUrls();
+    for (int i = 0; i < voburls.count(); i++) {
+        if (!voburls.at(i).isEmpty()) {
             // Add vob entry
             QDomElement vob = dvddoc.createElement("vob");
-            vob.setAttribute("file", allUrls.at(i)->url().path());
+            vob.setAttribute("file", voburls.at(i));
             pgc2.appendChild(vob);
         }
     }
index e610a70fd18589a3c4109fe73066b625b50036ed..931c6752dc35b0e8ae1e878462fb9f2552b68f8b 100644 (file)
@@ -35,7 +35,7 @@
 #include <KDebug>
 #include <KTemporaryFile>
 
-#include "ui_dvdwizardvob_ui.h"
+#include "dvdwizardvob.h"
 #include "ui_dvdwizardmenu_ui.h"
 #include "ui_dvdwizardiso_ui.h"
 #include "ui_dvdwizardstatus_ui.h"
@@ -47,7 +47,7 @@ public:
     virtual ~DvdWizard();
 
 private:
-    Ui::DvdWizardVob_UI m_vob;
+    DvdWizardVob *m_pageVob;
     Ui::DvdWizardMenu_UI m_menu;
     Ui::DvdWizardIso_UI m_iso;
     Ui::DvdWizardStatus_UI m_status;
@@ -64,7 +64,6 @@ private:
     KTemporaryFile m_authorFile;
 
 private slots:
-    void slotCheckVobList(const QString &text);
     void buildButton();
     void buildColor();
     void buildImage();
diff --git a/src/dvdwizardvob.cpp b/src/dvdwizardvob.cpp
new file mode 100644 (file)
index 0000000..2e8797a
--- /dev/null
@@ -0,0 +1,88 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#include <KUrlRequester>
+#include <KDebug>
+
+#include "dvdwizardvob.h"
+
+DvdWizardVob::DvdWizardVob(QWidget *parent): QWizardPage(parent) {
+    m_view.setupUi(this);
+    m_view.intro_vob->setEnabled(false);
+    m_view.vob_1->setFilter("video/mpeg");
+    m_view.intro_vob->setFilter("video/mpeg");
+    connect(m_view.use_intro, SIGNAL(toggled(bool)), m_view.intro_vob, SLOT(setEnabled(bool)));
+    connect(m_view.vob_1, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
+
+}
+
+DvdWizardVob::~DvdWizardVob() {
+    QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
+    qDeleteAll(allUrls);
+}
+
+// virtual
+
+bool DvdWizardVob::isComplete() const {
+    if (m_view.vob_1->url().path().isEmpty()) return false;
+    if (QFile::exists(m_view.vob_1->url().path())) return true;
+    return false;
+}
+
+void DvdWizardVob::setUrl(const QString &url) {
+    m_view.vob_1->setPath(url);
+}
+
+QStringList DvdWizardVob::selectedUrls() const {
+    QStringList result;
+    QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
+    for (int i = 0; i < allUrls.count(); i++) {
+        if (!allUrls.at(i)->url().path().isEmpty()) {
+            result.append(allUrls.at(i)->url().path());
+        }
+    }
+}
+
+void DvdWizardVob::slotCheckVobList(const QString &text) {
+    emit completeChanged();
+    QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
+    int count = allUrls.count();
+    kDebug() << "// FOUND " << count << " URLS";
+    if (count == 1) {
+        if (text.isEmpty()) return;
+        // insert second urlrequester
+        KUrlRequester *vob = new KUrlRequester(this);
+        vob->setFilter("video/mpeg");
+        m_view.vob_list->layout()->addWidget(vob);
+        connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
+    } else if (text.isEmpty()) {
+        if (allUrls.at(count - 1)->url().path().isEmpty() && allUrls.at(count - 2)->url().path().isEmpty()) {
+            // The last 2 urlrequesters are empty, remove last one
+            KUrlRequester *vob = allUrls.takeLast();
+            delete vob;
+        }
+    } else {
+        if (allUrls.at(count - 1)->url().path().isEmpty()) return;
+        KUrlRequester *vob = new KUrlRequester(this);
+        vob->setFilter("video/mpeg");
+        m_view.vob_list->layout()->addWidget(vob);
+        connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
+    }
+}
+
diff --git a/src/dvdwizardvob.h b/src/dvdwizardvob.h
new file mode 100644 (file)
index 0000000..f8b560c
--- /dev/null
@@ -0,0 +1,46 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+
+#ifndef DVDWIZARDVOB_H
+#define DVDWIZARDVOB_H
+
+#include <QWizardPage>
+
+#include "ui_dvdwizardvob_ui.h"
+
+class DvdWizardVob : public QWizardPage {
+    Q_OBJECT
+
+public:
+    DvdWizardVob(QWidget * parent = 0);
+    virtual ~DvdWizardVob();
+    virtual bool isComplete() const;
+    QStringList selectedUrls() const;
+    void setUrl(const QString &url);
+
+private:
+    Ui::DvdWizardVob_UI m_view;
+
+private slots:
+    void slotCheckVobList(const QString &text);
+};
+
+#endif
+
index 99000fe580351173217efd4ff7172924eda172d1..f623434450d15b8f3b26e49fb38b15b56d044df9 100644 (file)
@@ -809,8 +809,8 @@ void MainWindow::setupActions() {
     collection->addAction("monitor_loop_zone", m_loopZone);
     connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
 
-    KAction *dvdWizard = collection->addAction("dvd_wizard");
-    dvdWizard->setText(i18n("Dvd Wizard"));
+    KAction *dvdWizard =  new KAction(KIcon("media-optical"), i18n("Dvd Wizard"), this);
+    collection->addAction("dvd_wizard", dvdWizard);
     connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
 
     KAction *markIn = collection->addAction("mark_in");