]> git.sesse.net Git - kdenlive/commitdiff
Cleanup effectstack source.
authorTill Theato <root@ttill.de>
Sun, 22 Aug 2010 08:11:51 +0000 (08:11 +0000)
committerTill Theato <root@ttill.de>
Sun, 22 Aug 2010 08:11:51 +0000 (08:11 +0000)
svn path=/trunk/kdenlive/; revision=4744

src/CMakeLists.txt
src/doubleparameterwidget.cpp [new file with mode: 0644]
src/doubleparameterwidget.h [new file with mode: 0644]
src/effectstackedit.cpp
src/effectstackedit.h

index 8b41476d8ec5d71eead200382f4e7acff52a58b5..e107925decf7eb65cae98dcac2d631656aa7350c 100644 (file)
@@ -217,6 +217,7 @@ set(kdenlive_SRCS
   choosecolorwidget.cpp
   monitorscene.cpp
   geometrywidget.cpp
+  doubleparameterwidget.cpp
 )
 
 
diff --git a/src/doubleparameterwidget.cpp b/src/doubleparameterwidget.cpp
new file mode 100644 (file)
index 0000000..28d32f1
--- /dev/null
@@ -0,0 +1,79 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
+ *                                                                         *
+ *   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 "doubleparameterwidget.h"
+
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QSlider>
+#include <QSpinBox>
+
+
+DoubleParameterWidget::DoubleParameterWidget(const QString &name, int value, int min, int max, const QString suffix, QWidget *parent) :
+        QWidget(parent)
+{
+    QHBoxLayout *layout = new QHBoxLayout(this);
+
+    m_name = new QLabel(name, this);
+    layout->addWidget(m_name);
+
+    m_slider = new QSlider(Qt::Horizontal, this);
+    m_slider->setRange(min, max);
+    //m_slider->setPageStep((max - min) / 10);
+    layout->addWidget(m_slider);
+
+    m_spinBox = new QSpinBox(this);
+    m_spinBox->setRange(min, max);
+    if (!suffix.isEmpty())
+        m_spinBox->setSuffix(suffix);
+    layout->addWidget(m_spinBox);
+
+    connect(m_slider,  SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
+    connect(m_spinBox, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
+
+    m_spinBox->setValue(value);
+}
+
+void DoubleParameterWidget::setValue(int value)
+{
+    m_slider->blockSignals(true);
+    m_spinBox->blockSignals(true);
+
+    m_slider->setValue(value);
+    m_spinBox->setValue(value);
+
+    m_slider->blockSignals(false);
+    m_spinBox->blockSignals(false);
+
+    emit valueChanged(value);
+}
+
+int DoubleParameterWidget::getValue()
+{
+    return m_spinBox->value();
+}
+
+
+void DoubleParameterWidget::setName(const QString& name)
+{
+    m_name->setText(name);
+}
+
+#include "doubleparameterwidget.moc"
\ No newline at end of file
diff --git a/src/doubleparameterwidget.h b/src/doubleparameterwidget.h
new file mode 100644 (file)
index 0000000..448bbc8
--- /dev/null
@@ -0,0 +1,68 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
+ *                                                                         *
+ *   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 DOUBLEPARAMETERWIDGET_H
+#define DOUBLEPARAMETERWIDGET_H
+
+#include <QWidget>
+
+class QLabel;
+class QSlider;
+class QSpinBox;
+
+/**
+ * @class DoubleParameterWidget
+ * @brief Widget to choose a double parameter (for a effect) with the help of a slider and a spinbox.
+ * @author Till Theato
+ *
+ * The widget does only handle integers, so the parameter has to be converted into the proper double range afterwards.
+ */
+
+class DoubleParameterWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    /** @brief Sets up the parameter's GUI.
+    * @param name Name of the parameter
+    * @param value Value of the parameter
+    * @param min Minimum value
+    * @param max maximum value
+    * @param suffix (optional) Suffix to display in spinbox
+    * @param parent (optional) Parent Widget */
+    DoubleParameterWidget(const QString &name, int value, int min, int max, const QString suffix = QString(), QWidget* parent = 0);
+    /** @brief Updates the label to display @param name. */
+    void setName(const QString &name);
+    /** @brief Gets the parameter's value. */
+    int getValue();
+
+public slots:
+    /** @brief Sets the value to @param value. */
+    void setValue(int value);
+
+private:
+    QLabel *m_name;
+    QSlider *m_slider;
+    QSpinBox *m_spinBox;
+    
+signals:
+    void valueChanged(int);
+};
+
+#endif
index a95bcf6dc0987da24d25ca3201d77744be191bd7..4bf8b97152245c6a1c7ea015e6572736665de801 100644 (file)
@@ -16,7 +16,6 @@
  ***************************************************************************/
 
 #include "effectstackedit.h"
-#include "ui_constval_ui.h"
 #include "ui_listval_ui.h"
 #include "ui_boolval_ui.h"
 #include "ui_wipeval_ui.h"
 #include "choosecolorwidget.h"
 #include "geometrywidget.h"
 #include "colortools.h"
+#include "doubleparameterwidget.h"
 
 #include <KDebug>
 #include <KLocale>
 #include <KFileDialog>
 
 #include <QVBoxLayout>
-#include <QSlider>
 #include <QLabel>
 #include <QPushButton>
 #include <QCheckBox>
@@ -50,10 +49,6 @@ class Boolval: public QWidget, public Ui::Boolval_UI
 {
 };
 
-class Constval: public QWidget, public Ui::Constval_UI
-{
-};
-
 class Listval: public QWidget, public Ui::Listval_UI
 {
 };
@@ -118,6 +113,7 @@ void EffectStackEdit::updateTimecodeFormat()
 {
     if (m_keyframeEditor)
         m_keyframeEditor->updateTimecodeFormat();
+
     QDomNodeList namenode = m_params.elementsByTagName("parameter");
     for (int i = 0; i < namenode.count() ; i++) {
         QDomNode pa = namenode.item(i);
@@ -181,10 +177,6 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
         return;
     }
 
-    /*QDomDocument doc;
-    doc.appendChild(doc.importNode(m_params, true));
-    kDebug() << "IMPORTED TRANS: " << doc.toString();*/
-
     QDomNodeList namenode = m_params.elementsByTagName("parameter");
     QDomElement e = m_params.toElement();
     const int minFrame = e.attribute("start").toInt();
@@ -224,9 +216,11 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
                 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
             else
                 max = pa.attribute("max").toInt();
-            createSliderItem(paramName, (int)(value.toDouble() + 0.5) , min, max, pa.attribute("suffix", QString()));
-            delete toFillin;
-            toFillin = NULL;
+
+            DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max, pa.attribute("suffix", QString()), this);
+            m_vbox->addWidget(doubleparam);
+            m_valueItems[paramName] = doubleparam;
+            connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
         } else if (type == "list") {
             Listval *lsval = new Listval;
             lsval->setupUi(toFillin);
@@ -260,19 +254,6 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
             connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
             m_uiItems.append(bval);
         } else if (type == "complex") {
-            /*QStringList names=nodeAtts.namedItem("name").nodeValue().split(';');
-            QStringList max=nodeAtts.namedItem("max").nodeValue().split(';');
-            QStringList min=nodeAtts.namedItem("min").nodeValue().split(';');
-            QStringList val=value.split(';');
-            kDebug() << "in complex"<<names.size() << " " << max.size() << " " << min.size() << " " << val.size()  ;
-            if ( (names.size() == max.size() ) &&
-                 (names.size()== min.size()) &&
-                 (names.size()== val.size()) )
-            {
-             for (int i=0;i< names.size();i++){
-              createSliderItem(names[i],val[i].toInt(),min[i].toInt(),max[i].toInt());
-             };
-            }*/
             ComplexParameter *pl = new ComplexParameter;
             pl->setupParam(d, pa.attribute("name"), 0, 100);
             m_vbox->addWidget(pl);
@@ -559,8 +540,8 @@ void EffectStackEdit::collectAllParameters()
 
         QString setValue;
         if (type == "double" || type == "constant") {
-            QSlider* slider = ((Constval*)m_valueItems.value(paramName))->horizontalSlider;
-            setValue = QString::number(slider->value());
+            DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
+            setValue = QString::number(doubleparam->getValue());
         } else if (type == "list") {
             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
             setValue = box->itemData(box->currentIndex()).toString();
@@ -673,30 +654,6 @@ void EffectStackEdit::collectAllParameters()
     emit parameterChanged(oldparam, newparam);
 }
 
-void EffectStackEdit::createSliderItem(const QString& name, int val , int min, int max, const QString suffix)
-{
-    QWidget* toFillin = new QWidget(m_baseWidget);
-    Constval *ctval = new Constval;
-    ctval->setupUi(toFillin);
-    ctval->horizontalSlider->setMinimum(min);
-    ctval->horizontalSlider->setMaximum(max);
-    if (!suffix.isEmpty()) ctval->spinBox->setSuffix(suffix);
-    ctval->spinBox->setMinimum(min);
-    ctval->spinBox->setMaximum(max);
-    ctval->horizontalSlider->setPageStep((int)(max - min) / 10);
-    ctval->horizontalSlider->setValue(val);
-    ctval->label->setText(name);
-    m_valueItems[name] = ctval;
-    m_uiItems.append(ctval);
-    connect(ctval->horizontalSlider, SIGNAL(valueChanged(int)) , this, SLOT(collectAllParameters()));
-    m_vbox->addWidget(toFillin);
-}
-
-void EffectStackEdit::slotSliderMoved(int)
-{
-    collectAllParameters();
-}
-
 void EffectStackEdit::clearAllItems()
 {
     blockSignals(true);
index a737616cf2515d0dce6d062816b78eef41991837..e450c9f31767c1d7c1a659baf8ede50faaa023fb 100644 (file)
@@ -49,13 +49,17 @@ public:
     ~EffectStackEdit();
     void updateProjectFormat(MltVideoProfile profile, Timecode t);
     static QMap<QString, QImage> iconCache;
+    /** @brief Sets attribute @param name to @param value. 
+    *
+    * Used to disable the effect, by setting disabled="1" */
     void updateParameter(const QString &name, const QString &value);
     void setFrameSize(QPoint p);
+    /** @brief Tells the parameters to update their timecode format according to KdenliveSettings. */
     void updateTimecodeFormat();
 
 private:
+    /** @brief Deletes all parameter widgets. */
     void clearAllItems();
-    void createSliderItem(const QString& name, int val , int min, int max, const QString);
     wipeInfo getWipeInfo(QString value);
     QString getWipeString(wipeInfo info);
     /** @brief Updates parameter @param name according to new value of dependency.
@@ -78,10 +82,9 @@ private:
     Monitor *m_monitor;
 
 public slots:
-    /** \brief Called when an effect is selected, builds the UI for this effect */
+    /** @brief Called when an effect is selected, builds the UI for this effect. */
     void transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect = true);
-    void slotSliderMoved(int);
-    /** \brief Called whenever(?) some parameter is changed in the gui.
+    /** @brief Called whenever(?) some parameter is changed in the gui.
      *
      * Transfers all Dynamic gui parameter settings into m_params(??) */
     void collectAllParameters();