]> git.sesse.net Git - kdenlive/commitdiff
Add new clip generator: noise
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 6 Jan 2009 22:52:47 +0000 (22:52 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 6 Jan 2009 22:52:47 +0000 (22:52 +0000)
svn path=/branches/KDE4/; revision=2880

plugins/sampleplugin/sampleplugin.cpp
plugins/sampleplugin/sampleplugin.h
src/mainwindow.cpp
src/mainwindow.h

index a816322a2d6082c1009c91b97fe35bafad69cbbd..486f681f570f0625fa892c6db0a03d67310a35ad 100644 (file)
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
- ***************************************************************************/ 
+ ***************************************************************************/
+
 
 #include <QtGui>
 #include <QDialog>
 #include <QDomDocument>
+#include <QInputDialog>
 
 #include <KUrlRequester>
 #include <KIntSpinBox>
 #include "sampleplugin.h"
 #include "ui_countdown_ui.h"
 
- QStringList SamplePlugin::generators() const
- {
-     return QStringList() << tr("Countdown");
- }
+QStringList SamplePlugin::generators() const {
+    return QStringList() << i18n("Countdown") << i18n("Noise");
+}
 
 
 KUrl SamplePlugin::generatedClip(const QString &generator, const KUrl &projectFolder, const QStringList &lumaNames, const QStringList &lumaFiles, const double fps, const int width, const int height) {
+    QString prePath;
+    if (generator == i18n("Noise")) {
+        prePath = projectFolder.path() + "/noise";
+    } else prePath = projectFolder.path() + "/counter";
     int ct = 0;
     QString counter = QString::number(ct).rightJustified(5, '0', false);
-    while (QFile::exists(projectFolder.path() + "/counter" + counter + ".westley")) {
+    while (QFile::exists(prePath + counter + ".westley")) {
         ct++;
         counter = QString::number(ct).rightJustified(5, '0', false);
     }
     QDialog d;
-    d.setWindowTitle(tr("Create Countdown Clip"));
+    if (generator == i18n("Noise")) d.setWindowTitle(tr("Create Noise Clip"));
+    else d.setWindowTitle(tr("Create Countdown Clip"));
     Ui::CountDown_UI view;
     view.setupUi(&d);
-    QString clipFile = projectFolder.path() + "/counter" + counter + ".westley";
+    QString clipFile = prePath + counter + ".westley";
     view.path->setPath(clipFile);
     if (d.exec() == QDialog::Accepted) {
-       QDomDocument doc;
-       QDomElement westley = doc.createElement("westley");
-       QDomElement playlist = doc.createElement("playlist");
-       for (int i = 0; i < view.duration->value(); i++) {
-           // Create the producers
-           QDomElement prod = doc.createElement("producer");
-           prod.setAttribute("mlt_service", "pango");
-           prod.setAttribute("in", "0");
-           prod.setAttribute("out", QString::number((int) fps));
-           prod.setAttribute("markup", QString::number(view.duration->value() - i));
-           playlist.appendChild(prod);
-       }
-       westley.appendChild(playlist);
-       doc.appendChild(westley);
-       QFile file(view.path->url().path());
-       if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
-           kWarning() << "//////  ERROR writing to file: " << view.path->url().path();
-           KMessageBox::error(0, i18n("Cannot write to file %1", view.path->url().path()));
-           return KUrl();
-       }
-       QTextStream out(&file);
-       out << doc.toString();
-       file.close();
-       return view.path->url();
+        QDomDocument doc;
+        QDomElement westley = doc.createElement("westley");
+        QDomElement playlist = doc.createElement("playlist");
+        if (generator == i18n("Noise")) {
+            QDomElement prod = doc.createElement("producer");
+            prod.setAttribute("mlt_service", "noise");
+            prod.setAttribute("in", "0");
+            prod.setAttribute("out", QString::number((int) fps * view.duration->value()));
+            playlist.appendChild(prod);
+        } else {
+            for (int i = 0; i < view.duration->value(); i++) {
+                // Create the producers
+                QDomElement prod = doc.createElement("producer");
+                prod.setAttribute("mlt_service", "pango");
+                prod.setAttribute("in", "0");
+                prod.setAttribute("out", QString::number((int) fps));
+                prod.setAttribute("markup", QString::number(view.duration->value() - i));
+                playlist.appendChild(prod);
+            }
+        }
+        westley.appendChild(playlist);
+        doc.appendChild(westley);
+        QFile file(view.path->url().path());
+        if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+            kWarning() << "//////  ERROR writing to file: " << view.path->url().path();
+            KMessageBox::error(0, i18n("Cannot write to file %1", view.path->url().path()));
+            return KUrl();
+        }
+        QTextStream out(&file);
+        out << doc.toString();
+        file.close();
+        return view.path->url();
     }
     return KUrl();
 }
index 50abc9d4fd65a92850f03a9fcafa0be31a9de808..c25d8ac4e2e48dba651ab3fe0ce62477b619ba38 100644 (file)
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
- ***************************************************************************/ 
+ ***************************************************************************/
+
 
 #ifndef SAMPLEPLUGIN_H
 #define SAMPLEPLUGIN_H
 
 #include <QObject>
 #include <QStringList>
+
 #include <KUrl>
 
 #include "interfaces.h"
 
-class SamplePlugin : public QObject, public ClipGenerator
-{
+class SamplePlugin : public QObject, public ClipGenerator {
     Q_OBJECT
     Q_INTERFACES(ClipGenerator)
 
- public:
-     QStringList generators() const;
-     KUrl generatedClip(const QString &generator, const KUrl &projectFolder, const QStringList &lumaNames, const QStringList &lumaFiles, const double fps, const int width, const int height);
- };
+public:
+    QStringList generators() const;
+    KUrl generatedClip(const QString &generator, const KUrl &projectFolder, const QStringList &lumaNames, const QStringList &lumaFiles, const double fps, const int width, const int height);
+};
 
 
- #endif
\ No newline at end of file
+#endif
\ No newline at end of file
index 7ae740d668e6b0d1578445cdcffba4741de425b4..912faa9d0c9071e6471de4c060329892390f2ced 100644 (file)
@@ -405,11 +405,8 @@ void MainWindow::loadPlugins() {
 }
 
 void MainWindow::populateMenus(QObject *plugin) {
-    kDebug() << "// POP MENU";
     QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
     ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
-    kDebug() << "// POP MENU 2";
-    if (addMenu) kDebug() << "// POP MENU 3";
     if (iGenerator)
         addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()),
                   NULL);
@@ -421,6 +418,7 @@ void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
     kDebug() << "// ADD to MENU" << texts;
     foreach(QString text, texts) {
         QAction *action = new QAction(text, plugin);
+        action->setData(text);
         connect(action, SIGNAL(triggered()), this, member);
         menu->addAction(action);
 
@@ -441,7 +439,7 @@ void MainWindow::generateClip() {
     QAction *action = qobject_cast<QAction *>(sender());
     ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
 
-    KUrl clipUrl = iGenerator->generatedClip(action->text(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
+    KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
     if (!clipUrl.isEmpty()) {
         m_projectList->slotAddClip(clipUrl);
     }
@@ -1618,6 +1616,7 @@ void MainWindow::slotPreferences(int page, int option) {
     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
     connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
+    //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
     dialog->show();
     if (page != -1) dialog->showPage(page, option);
 }
@@ -1638,6 +1637,12 @@ void MainWindow::updateConfiguration() {
 
 }
 
+void MainWindow::slotUpdatePreviewSettings() {
+    //TODO: perform operation on all open documents
+    m_activeDocument->clipManager()->updatePreviewSettings();
+}
+
+
 void MainWindow::slotSwitchVideoThumbs() {
     KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
     if (m_activeTimeline) {
index c0c47c6ff5f7d34d3201688d7558e3c8f32662a7..afc4b1679c9fc8e999aaa696e1604143b3dbbceb 100644 (file)
@@ -283,6 +283,7 @@ private slots:
     void slotRunWizard();
     void generateClip();
     void slotZoneMoved(int start, int end);
+    void slotUpdatePreviewSettings();
 };