]> git.sesse.net Git - kdenlive/blob - src/effectstackedit.cpp
use first simple sliders for parameter setup
[kdenlive] / src / effectstackedit.cpp
1 /***************************************************************************
2                           effecstackview.cpp  -  description
3                              -------------------
4     begin                : Feb 15 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #include <KDebug>
19 #include <KLocale>
20 #include "effectstackedit.h"
21 #include <QVBoxLayout>
22 #include <QSlider>
23 #include <QLabel>
24 #include "ui_constval_ui.h"
25
26 EffectStackEdit::EffectStackEdit(QGroupBox* gbox,QWidget *parent): QWidget(parent)
27 {
28         
29         vbox=new QVBoxLayout;
30         gbox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
31         QVBoxLayout *tmpvbox=new QVBoxLayout;
32         tmpvbox->addLayout(vbox);
33         tmpvbox->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Expanding));
34         gbox->setLayout(tmpvbox);
35         
36 }
37 void EffectStackEdit::transferParamDesc(const QDomElement& d,int ,int){
38         params=d;
39         QDomNodeList namenode = params.elementsByTagName("parameter");
40         
41         clearAllItems();
42                 QString outstr;
43                 QTextStream str(&outstr);
44                 d.save(str,2);
45                 kDebug() << outstr;
46         for (int i=0;i< namenode.count() ;i++){
47                 QDomNode pa=namenode.item(i);
48                 QDomNode na=pa.firstChildElement("name");
49                 QString type=pa.attributes().namedItem("type").nodeValue();
50                 QWidget * toFillin=NULL,*labelToFillIn=NULL;
51                 if (type=="double" || type=="constant"){
52                         toFillin=new QWidget;
53                         Ui::Constval_UI *ctval=new Ui::Constval_UI;
54                         ctval->setupUi(toFillin);
55                         
56                         ctval->horizontalSlider->setMinimum(pa.attributes().namedItem("min").nodeValue().toInt());
57                         ctval->horizontalSlider->setMaximum(pa.attributes().namedItem("max").nodeValue().toInt());
58                         ctval->spinBox->setMinimum(ctval->horizontalSlider->minimum());
59                         ctval->spinBox->setMaximum(ctval->horizontalSlider->maximum());
60                         ctval->horizontalSlider->setValue(pa.attributes().namedItem("default").nodeValue().toInt());
61                         ctval->title->setText(na.toElement().text() );
62                         valueItems[na.toElement().text()]=ctval;
63                         connect (ctval->horizontalSlider, SIGNAL(valueChanged(int)) , this, SLOT (slotSliderMoved(int)));
64                         
65                 
66                 }
67
68                 if (toFillin){
69                         items.append(toFillin);
70                         vbox->addWidget(toFillin);
71                 }       
72         }
73 }
74 void EffectStackEdit::collectAllParameters(){
75         QDomNodeList namenode = params.elementsByTagName("parameter");
76
77         for (int i=0;i< namenode.count() ;i++){
78                 QDomNode pa=namenode.item(i);
79                 QDomNode na=pa.firstChildElement("name");
80                 QString type=pa.attributes().namedItem("type").nodeValue();
81                 if (type=="double" || type=="constant"){
82                         QSlider* slider=((Ui::Constval_UI*)valueItems[na.toElement().text()])->horizontalSlider;
83                         pa.attributes().namedItem("value").setNodeValue(QString::number(slider->value()));
84                 }
85         }
86         emit parameterChanged(params);
87 }
88 void EffectStackEdit::slotSliderMoved(int){
89         collectAllParameters();
90 }
91
92 void EffectStackEdit::clearAllItems(){
93         foreach (QWidget* w,items){
94                 kDebug() << "delete" << w;
95                 vbox->removeWidget(w);
96                 delete w;
97         }
98         items.clear();
99         valueItems.clear();
100 }