]> git.sesse.net Git - kdenlive/blob - src/dvdwizardvob.cpp
Consistent messages: Same text not translated twice anymore
[kdenlive] / src / dvdwizardvob.cpp
1 /***************************************************************************
2  *   Copyright (C) 2009 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20 #include <KUrlRequester>
21 #include <KDebug>
22 #include <KStandardDirs>
23
24 #include "dvdwizardvob.h"
25
26 DvdWizardVob::DvdWizardVob(QWidget *parent): QWizardPage(parent) {
27     m_view.setupUi(this);
28     m_view.intro_vob->setEnabled(false);
29     m_view.vob_1->setFilter("video/mpeg");
30     m_view.intro_vob->setFilter("video/mpeg");
31     connect(m_view.use_intro, SIGNAL(toggled(bool)), m_view.intro_vob, SLOT(setEnabled(bool)));
32     connect(m_view.vob_1, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
33     if (KStandardDirs::findExe("dvdauthor").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 is required for the dvd wizard.", i18n("dvdauthor")));
34     if (KStandardDirs::findExe("mkisofs").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 is required for the dvd wizard.", i18n("mkisofs")));
35     if (m_errorMessage.isEmpty()) m_view.error_message->setVisible(false);
36     else m_view.error_message->setText(m_errorMessage);
37 }
38
39 DvdWizardVob::~DvdWizardVob() {
40     QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
41     qDeleteAll(allUrls);
42 }
43
44 // virtual
45
46 bool DvdWizardVob::isComplete() const {
47     if (!m_view.error_message->text().isEmpty()) return false;
48     if (m_view.vob_1->url().path().isEmpty()) return false;
49     if (QFile::exists(m_view.vob_1->url().path())) return true;
50     return false;
51 }
52
53 void DvdWizardVob::setUrl(const QString &url) {
54     m_view.vob_1->setPath(url);
55 }
56
57 QStringList DvdWizardVob::selectedUrls() const {
58     QStringList result;
59     QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
60     for (int i = 0; i < allUrls.count(); i++) {
61         if (!allUrls.at(i)->url().path().isEmpty()) {
62             result.append(allUrls.at(i)->url().path());
63         }
64     }
65     return result;
66 }
67
68 QString DvdWizardVob::introMovie() const {
69     if (!m_view.use_intro->isChecked()) return QString();
70     return m_view.intro_vob->url().path();
71 }
72
73 void DvdWizardVob::slotCheckVobList(const QString &text) {
74     emit completeChanged();
75     QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
76     int count = allUrls.count();
77     kDebug() << "// FOUND " << count << " URLS";
78     if (count == 1) {
79         if (text.isEmpty()) return;
80         // insert second urlrequester
81         KUrlRequester *vob = new KUrlRequester(this);
82         vob->setFilter("video/mpeg");
83         m_view.vob_list->layout()->addWidget(vob);
84         connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
85     } else if (text.isEmpty()) {
86         if (allUrls.at(count - 1)->url().path().isEmpty() && allUrls.at(count - 2)->url().path().isEmpty()) {
87             // The last 2 urlrequesters are empty, remove last one
88             KUrlRequester *vob = allUrls.takeLast();
89             delete vob;
90         }
91     } else {
92         if (allUrls.at(count - 1)->url().path().isEmpty()) return;
93         KUrlRequester *vob = new KUrlRequester(this);
94         vob->setFilter("video/mpeg");
95         m_view.vob_list->layout()->addWidget(vob);
96         connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
97     }
98 }
99