]> git.sesse.net Git - kdenlive/blob - src/doubleparameterwidget.cpp
Cleanup effectstack source.
[kdenlive] / src / doubleparameterwidget.cpp
1 /***************************************************************************
2  *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
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 "doubleparameterwidget.h"
22
23 #include <QHBoxLayout>
24 #include <QLabel>
25 #include <QSlider>
26 #include <QSpinBox>
27
28
29 DoubleParameterWidget::DoubleParameterWidget(const QString &name, int value, int min, int max, const QString suffix, QWidget *parent) :
30         QWidget(parent)
31 {
32     QHBoxLayout *layout = new QHBoxLayout(this);
33
34     m_name = new QLabel(name, this);
35     layout->addWidget(m_name);
36
37     m_slider = new QSlider(Qt::Horizontal, this);
38     m_slider->setRange(min, max);
39     //m_slider->setPageStep((max - min) / 10);
40     layout->addWidget(m_slider);
41
42     m_spinBox = new QSpinBox(this);
43     m_spinBox->setRange(min, max);
44     if (!suffix.isEmpty())
45         m_spinBox->setSuffix(suffix);
46     layout->addWidget(m_spinBox);
47
48     connect(m_slider,  SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
49     connect(m_spinBox, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
50
51     m_spinBox->setValue(value);
52 }
53
54 void DoubleParameterWidget::setValue(int value)
55 {
56     m_slider->blockSignals(true);
57     m_spinBox->blockSignals(true);
58
59     m_slider->setValue(value);
60     m_spinBox->setValue(value);
61
62     m_slider->blockSignals(false);
63     m_spinBox->blockSignals(false);
64
65     emit valueChanged(value);
66 }
67
68 int DoubleParameterWidget::getValue()
69 {
70     return m_spinBox->value();
71 }
72
73
74 void DoubleParameterWidget::setName(const QString& name)
75 {
76     m_name->setText(name);
77 }
78
79 #include "doubleparameterwidget.moc"