1 /**************************************************************************
2 * Copyright (C) 2010 by Till Theato (root@ttill.de) *
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. *
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. *
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 ***************************************************************************/
21 #include "doubleparameterwidget.h"
22 #include "dragvalue.h"
24 #include <QGridLayout>
27 #include <QToolButton>
30 #include <KLocalizedString>
33 DoubleParameterWidget::DoubleParameterWidget(const QString &name, int value, int min, int max, int defaultValue, const QString &comment, int id, const QString suffix, QWidget *parent) :
37 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
38 QGridLayout *layout = new QGridLayout(this);
39 layout->setContentsMargins(0, 0, 0, 0);
40 layout->setSpacing(0);
42 m_dragVal = new DragValue(name, defaultValue, 0, id, suffix, this);
43 m_dragVal->setRange(min, max);
44 m_dragVal->setPrecision(0);
45 layout->addWidget(m_dragVal, 0, 1);
47 if (!comment.isEmpty()) {
48 m_commentLabel = new QLabel(comment, this);
49 m_commentLabel->setWordWrap(true);
50 m_commentLabel->setTextFormat(Qt::RichText);
51 m_commentLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
52 m_commentLabel->setFrameShape(QFrame::StyledPanel);
53 m_commentLabel->setFrameShadow(QFrame::Raised);
54 m_commentLabel->setHidden(true);
55 layout->addWidget(m_commentLabel, 1, 0, 1, -1);
57 m_dragVal->setValue(value);
58 connect(m_dragVal, SIGNAL(valueChanged(int, bool)), this, SLOT(slotSetValue(int, bool)));
59 connect(m_dragVal, SIGNAL(inTimeline(int)), this, SIGNAL(setInTimeline(int)));
62 int DoubleParameterWidget::spinSize()
64 return m_dragVal->spinSize();
67 void DoubleParameterWidget::setSpinSize(int width)
69 m_dragVal->setSpinSize(width);
72 void DoubleParameterWidget::setValue(int value)
74 m_dragVal->blockSignals(true);
75 m_dragVal->setValue(value);
76 m_dragVal->blockSignals(false);
79 void DoubleParameterWidget::slotSetValue(int value, bool final)
82 emit valueChanged(value);
86 int DoubleParameterWidget::getValue()
88 return m_dragVal->value();
91 void DoubleParameterWidget::slotReset()
93 m_dragVal->slotReset();
96 void DoubleParameterWidget::setInTimelineProperty(bool intimeline)
98 m_dragVal->setInTimelineProperty(intimeline);
101 void DoubleParameterWidget::slotShowComment( bool show)
103 if (m_commentLabel) {
104 m_commentLabel->setVisible(show);
106 layout()->setContentsMargins(0, 0, 0, 15);
108 layout()->setContentsMargins(0, 0, 0, 0);
112 #include "doubleparameterwidget.moc"