]> git.sesse.net Git - kdenlive/blobdiff - src/doubleparameterwidget.cpp
Const'ref
[kdenlive] / src / doubleparameterwidget.cpp
index 28d32f161855f8da8813de9a485061ec3c2501b5..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 "doubleparameterwidget.h"
+#include "dragvalue.h"
 
-#include <QHBoxLayout>
+#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, 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);
+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);
+
+    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)));
+}
 
-    connect(m_slider,  SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
-    connect(m_spinBox, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
+DoubleParameterWidget::~DoubleParameterWidget()
+{
+    delete m_dragVal;
+}
 
-    m_spinBox->setValue(value);
+int DoubleParameterWidget::spinSize()
+{
+    return m_dragVal->spinSize();
 }
 
-void DoubleParameterWidget::setValue(int value)
+void DoubleParameterWidget::setSpinSize(int width)
 {
-    m_slider->blockSignals(true);
-    m_spinBox->blockSignals(true);
+    m_dragVal->setSpinSize(width);
+}
 
-    m_slider->setValue(value);
-    m_spinBox->setValue(value);
+void DoubleParameterWidget::setValue(double value)
+{
+    m_dragVal->blockSignals(true);
+    m_dragVal->setValue(value);
+    m_dragVal->blockSignals(false);
+}
 
-    m_slider->blockSignals(false);
-    m_spinBox->blockSignals(false);
+void DoubleParameterWidget::slotSetValue(double value, bool final)
+{
+    if (final) {
+        emit valueChanged(value);
+    }
+}
 
-    emit valueChanged(value);
+double DoubleParameterWidget::getValue()
+{
+    return m_dragVal->value();
 }
 
-int DoubleParameterWidget::getValue()
+void DoubleParameterWidget::slotReset()
 {
-    return m_spinBox->value();
+    m_dragVal->slotReset();
 }
 
+void DoubleParameterWidget::setInTimelineProperty(bool intimeline)
+{
+    m_dragVal->setInTimelineProperty(intimeline);
+}
 
-void DoubleParameterWidget::setName(const QString& name)
+void DoubleParameterWidget::slotShowComment( bool show)
 {
-    m_name->setText(name);
 }
 
-#include "doubleparameterwidget.moc"
\ No newline at end of file
+#include "doubleparameterwidget.moc"