]> git.sesse.net Git - kdenlive/blob - plugins/sampleplugin/sampleplugin.cpp
Comment out names of unused parameters [PATCH by Ray Lehtiniemi]
[kdenlive] / plugins / sampleplugin / sampleplugin.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
21 #include "sampleplugin.h"
22 #include "ui_countdown_ui.h"
23
24 #include <KUrlRequester>
25 #include <KIntSpinBox>
26 #include <KDebug>
27 #include <KMessageBox>
28
29 #include <QDialog>
30 #include <QDomDocument>
31 #include <QInputDialog>
32
33 QStringList SamplePlugin::generators() const {
34     return QStringList() << i18n("Countdown") << i18n("Noise");
35 }
36
37
38 KUrl SamplePlugin::generatedClip(const QString &generator, const KUrl &projectFolder, const QStringList &/*lumaNames*/, const QStringList &/*lumaFiles*/, const double fps, const int /*width*/, const int /*height*/) {
39     QString prePath;
40     if (generator == i18n("Noise")) {
41         prePath = projectFolder.path() + "/noise";
42     } else prePath = projectFolder.path() + "/counter";
43     int ct = 0;
44     QString counter = QString::number(ct).rightJustified(5, '0', false);
45     while (QFile::exists(prePath + counter + ".westley")) {
46         ct++;
47         counter = QString::number(ct).rightJustified(5, '0', false);
48     }
49     QDialog d;
50     if (generator == i18n("Noise")) d.setWindowTitle(tr("Create Noise Clip"));
51     else d.setWindowTitle(tr("Create Countdown Clip"));
52     Ui::CountDown_UI view;
53     view.setupUi(&d);
54     QString clipFile = prePath + counter + ".westley";
55     view.path->setPath(clipFile);
56     if (d.exec() == QDialog::Accepted) {
57         QDomDocument doc;
58         QDomElement westley = doc.createElement("westley");
59         QDomElement playlist = doc.createElement("playlist");
60         if (generator == i18n("Noise")) {
61             QDomElement prod = doc.createElement("producer");
62             prod.setAttribute("mlt_service", "noise");
63             prod.setAttribute("in", "0");
64             prod.setAttribute("out", QString::number((int) fps * view.duration->value()));
65             playlist.appendChild(prod);
66         } else {
67             for (int i = 0; i < view.duration->value(); i++) {
68                 // Create the producers
69                 QDomElement prod = doc.createElement("producer");
70                 prod.setAttribute("mlt_service", "pango");
71                 prod.setAttribute("in", "0");
72                 prod.setAttribute("out", QString::number((int) fps));
73                 prod.setAttribute("markup", QString::number(view.duration->value() - i));
74                 playlist.appendChild(prod);
75             }
76         }
77         westley.appendChild(playlist);
78         doc.appendChild(westley);
79         QFile file(view.path->url().path());
80         if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
81             kWarning() << "//////  ERROR writing to file: " << view.path->url().path();
82             KMessageBox::error(0, i18n("Cannot write to file %1", view.path->url().path()));
83             return KUrl();
84         }
85         QTextStream out(&file);
86         out << doc.toString();
87         file.close();
88         return view.path->url();
89     }
90     return KUrl();
91 }
92
93 Q_EXPORT_PLUGIN2(kdenlive_sampleplugin, SamplePlugin)