1 /***************************************************************************
2 * Copyright (C) 2009 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "dvdwizardvob.h"
22 #include <KUrlRequester>
24 #include <KStandardDirs>
27 DvdWizardVob::DvdWizardVob(QWidget *parent): QWizardPage(parent) {
29 m_view.intro_vob->setEnabled(false);
30 m_view.vob_1->setFilter("video/mpeg");
31 m_view.intro_vob->setFilter("video/mpeg");
32 connect(m_view.use_intro, SIGNAL(toggled(bool)), m_view.intro_vob, SLOT(setEnabled(bool)));
33 connect(m_view.vob_1, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
34 if (KStandardDirs::findExe("dvdauthor").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 is required for the DVD wizard.", i18n("dvdauthor")));
35 if (KStandardDirs::findExe("mkisofs").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 is required for the DVD wizard.", i18n("mkisofs")));
36 if (m_errorMessage.isEmpty()) m_view.error_message->setVisible(false);
37 else m_view.error_message->setText(m_errorMessage);
40 DvdWizardVob::~DvdWizardVob() {
41 QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
47 bool DvdWizardVob::isComplete() const {
48 if (!m_view.error_message->text().isEmpty()) return false;
49 if (m_view.vob_1->url().path().isEmpty()) return false;
50 if (QFile::exists(m_view.vob_1->url().path())) return true;
54 void DvdWizardVob::setUrl(const QString &url) {
55 m_view.vob_1->setPath(url);
58 QStringList DvdWizardVob::selectedUrls() const {
60 QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
61 for (int i = 0; i < allUrls.count(); i++) {
62 if (!allUrls.at(i)->url().path().isEmpty()) {
63 result.append(allUrls.at(i)->url().path());
69 QString DvdWizardVob::introMovie() const {
70 if (!m_view.use_intro->isChecked()) return QString();
71 return m_view.intro_vob->url().path();
74 void DvdWizardVob::slotCheckVobList(const QString &text) {
75 emit completeChanged();
76 QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
77 int count = allUrls.count();
78 kDebug() << "// FOUND " << count << " URLS";
80 if (text.isEmpty()) return;
81 // insert second urlrequester
82 KUrlRequester *vob = new KUrlRequester(this);
83 vob->setFilter("video/mpeg");
84 m_view.vob_list->layout()->addWidget(vob);
85 connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
86 } else if (text.isEmpty()) {
87 if (allUrls.at(count - 1)->url().path().isEmpty() && allUrls.at(count - 2)->url().path().isEmpty()) {
88 // The last 2 urlrequesters are empty, remove last one
89 KUrlRequester *vob = allUrls.takeLast();
93 if (allUrls.at(count - 1)->url().path().isEmpty()) return;
94 KUrlRequester *vob = new KUrlRequester(this);
95 vob->setFilter("video/mpeg");
96 m_view.vob_list->layout()->addWidget(vob);
97 connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));