From: Jean-Baptiste Mardelle Date: Mon, 19 Jan 2009 18:18:59 +0000 (+0000) Subject: start improving dvd wizard X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=5972b11e71d08b5bfdd92fb97cb3ad864f3970fd;p=kdenlive start improving dvd wizard svn path=/branches/KDE4/; revision=2933 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d85e1338..b798b74d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -146,6 +146,7 @@ set(kdenlive_SRCS addtrackcommand.cpp changetrackcommand.cpp movegroupcommand.cpp + dvdwizardvob.cpp dvdwizard.cpp ) diff --git a/src/dvdwizard.cpp b/src/dvdwizard.cpp index 97fd7ba1..1cdff176 100644 --- a/src/dvdwizard.cpp +++ b/src/dvdwizard.cpp @@ -39,16 +39,11 @@ 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 allUrls = m_vob.vob_list->findChildren(); - 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 allUrls = m_vob.vob_list->findChildren(); - 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); } } diff --git a/src/dvdwizard.h b/src/dvdwizard.h index e610a70f..931c6752 100644 --- a/src/dvdwizard.h +++ b/src/dvdwizard.h @@ -35,7 +35,7 @@ #include #include -#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 index 00000000..2e8797ad --- /dev/null +++ b/src/dvdwizardvob.cpp @@ -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 +#include + +#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 allUrls = m_view.vob_list->findChildren(); + 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 allUrls = m_view.vob_list->findChildren(); + 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 allUrls = m_view.vob_list->findChildren(); + 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 index 00000000..f8b560c5 --- /dev/null +++ b/src/dvdwizardvob.h @@ -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 + +#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 + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 99000fe5..f6234344 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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");