]> git.sesse.net Git - kdenlive/blobdiff - src/doubleparameterwidget.cpp
Fix indent
[kdenlive] / src / doubleparameterwidget.cpp
index 96a80c0d37ab168982c8b4436dd609d3a3de325b..ec2af5137f8ed18148e414be4e4d2ebf12a753a0 100644 (file)
@@ -1,4 +1,4 @@
-/***************************************************************************
+/**************************************************************************
  *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 
 #include <QGridLayout>
 #include <QLabel>
-#include <QSlider>
 #include <QSpinBox>
 #include <QToolButton>
 
+#include <KDebug>
 #include <KIcon>
 #include <KLocalizedString>
 
 
-DoubleParameterWidget::DoubleParameterWidget(const QString &name, int value, int min, int max, int defaultValue, const QString &comment, const QString suffix, QWidget *parent) :
-        QWidget(parent),
-        m_default(defaultValue)
+DoubleParameterWidget::DoubleParameterWidget(const QString &name, double value, double min, double max, double defaultValue, const QString &comment, int id, const QString &suffix, int decimals, QWidget *parent) :
+    QWidget(parent)
 {
+    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
     QGridLayout *layout = new QGridLayout(this);
     layout->setContentsMargins(0, 0, 0, 0);
     layout->setSpacing(0);
+    
+    m_dragVal = new DragValue(name, defaultValue, decimals, min, max, id, suffix, this);
+    layout->addWidget(m_dragVal, 0, 1);
 
-    m_name = new QLabel(name, this);
-    layout->addWidget(m_name, 0, 0);
-
-    m_slider = new QSlider(Qt::Horizontal, this);
-    m_slider->setRange(min, max);
-    //m_slider->setPageStep((max - min) / 10);
-    layout->addWidget(m_slider, 0, 1);
-
-    m_dragVal = new DragValue(this);
-    m_dragVal->setRange(min, max);
-    m_dragVal->setPrecision(0);
-    layout->addWidget(m_dragVal, 0, 2);
-
-    m_spinBox = new QSpinBox(this);
-    m_spinBox->setRange(min, max);
-    m_spinBox->setKeyboardTracking(false);
-    if (!suffix.isEmpty())
-        m_spinBox->setSuffix(suffix);
-    //layout->addWidget(m_spinBox, 0, 2);
-    m_spinBox->setHidden(true);
-
-    QToolButton *reset = new QToolButton(this);
-    reset->setAutoRaise(true);
-    reset->setIcon(KIcon("edit-undo"));
-    reset->setToolTip(i18n("Reset to default value"));
-    layout->addWidget(reset, 0, 3);
-
-    m_commentLabel = new QLabel(comment, this);
-    m_commentLabel->setWordWrap(true);
-    m_commentLabel->setTextFormat(Qt::RichText);
-    m_commentLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
-    m_commentLabel->setFrameShape(QFrame::StyledPanel);
-    m_commentLabel->setFrameShadow(QFrame::Raised);
-    m_commentLabel->setHidden(true);
-    layout->addWidget(m_commentLabel, 1, 0, 1, -1);
-
-    connect(m_slider,  SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
-    connect(m_dragVal, SIGNAL(valueChanged(qreal, bool)), this, SLOT(slotSetValue(qreal, bool)));
-    connect(m_spinBox, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
-    connect(reset,     SIGNAL(clicked(bool)),     this, SLOT(slotReset()));
-
-    //m_spinBox->setValue(value);
-    m_dragVal->setValue(value);
+    if (!comment.isEmpty()) {
+        setToolTip(comment);
+    }
+    m_dragVal->setValue(value, false);
+    connect(m_dragVal, SIGNAL(valueChanged(double,bool)), this, SLOT(slotSetValue(double,bool)));
+    connect(m_dragVal, SIGNAL(inTimeline(int)), this, SIGNAL(setInTimeline(int)));
 }
 
-void DoubleParameterWidget::setValue(int value)
+DoubleParameterWidget::~DoubleParameterWidget()
 {
-    m_slider->blockSignals(true);
-    m_spinBox->blockSignals(true);
-    m_dragVal->blockSignals(true);
-
-    m_slider->setValue(value);
-    m_spinBox->setValue(value);
-    m_dragVal->setValue(value);
+    delete m_dragVal;
+}
 
-    m_slider->blockSignals(false);
-    m_spinBox->blockSignals(false);
-    m_dragVal->blockSignals(false);
+int DoubleParameterWidget::spinSize()
+{
+    return m_dragVal->spinSize();
+}
 
-    emit valueChanged(value);
+void DoubleParameterWidget::setSpinSize(int width)
+{
+    m_dragVal->setSpinSize(width);
 }
 
-void DoubleParameterWidget::slotSetValue(qreal value, bool final)
+void DoubleParameterWidget::setValue(double value)
 {
-    if (final)
-        setValue((int)value);
+    m_dragVal->blockSignals(true);
+    m_dragVal->setValue(value);
+    m_dragVal->blockSignals(false);
 }
 
-int DoubleParameterWidget::getValue()
+void DoubleParameterWidget::slotSetValue(double value, bool final)
 {
-    return m_spinBox->value();
+    if (final) {
+        emit valueChanged(value);
+    }
 }
 
-void DoubleParameterWidget::setName(const QString& name)
+double DoubleParameterWidget::getValue()
 {
-    m_name->setText(name);
+    return m_dragVal->value();
 }
 
 void DoubleParameterWidget::slotReset()
 {
-    setValue(m_default);
+    m_dragVal->slotReset();
+}
+
+void DoubleParameterWidget::setInTimelineProperty(bool intimeline)
+{
+    m_dragVal->setInTimelineProperty(intimeline);
 }
 
 void DoubleParameterWidget::slotShowComment( bool show)
 {
-    if (m_commentLabel->text() != QString()) {
-        m_commentLabel->setVisible(show);
-        if (show)
-            layout()->setContentsMargins(0, 0, 0, 15);
-        else
-            layout()->setContentsMargins(0, 0, 0, 0);
-    }
 }
 
 #include "doubleparameterwidget.moc"