[libcamera-devel,v2,09/11] qcam: ControlFrame: Add GUI interaction to float controls
diff mbox series

Message ID 20220812124651.27496-10-utkarsh02t@gmail.com
State New
Headers show
Series
  • Introduce control interaction to qcam
Related show

Commit Message

Utkarsh Tiwari Aug. 12, 2022, 12:46 p.m. UTC
Add the float slider for the float controls to be able to control its
value. Also display the current values for the float controls.

Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>
---
 src/qcam/settings/control_frame.cpp | 21 +++++++++++++++++++++
 src/qcam/settings/control_frame.h   |  3 +++
 2 files changed, 24 insertions(+)

Patch
diff mbox series

diff --git a/src/qcam/settings/control_frame.cpp b/src/qcam/settings/control_frame.cpp
index 2554f70d..9e38da37 100644
--- a/src/qcam/settings/control_frame.cpp
+++ b/src/qcam/settings/control_frame.cpp
@@ -16,6 +16,8 @@ 
 #include <QString>
 #include <QVBoxLayout>
 
+#include "slider.h"
+
 using namespace libcamera;
 
 ControlFrame::ControlFrame(const ControlId *control,
@@ -78,6 +80,19 @@  QWidget *ControlFrame::controlInteraction(QWidget *parent)
 		HCheckBoxLayout->setMargin(0);
 		return containerWidget;
 	}
+	case ControlTypeFloat: {
+		floatSlider_ = new FloatSlider;
+		floatSlider_->setRange(controlInfo_.min().get<float>(),
+				       controlInfo_.max().get<float>());
+		floatSlider_->setValue(controlInfo_.def().get<float>());
+		floatSlider_->setOrientation(Qt::Orientation::Horizontal);
+
+		connect(floatSlider_, &FloatSlider::valueChanged,
+			this, &ControlFrame::notifyControlChange);
+
+		SliderLayout *fSliderLayout = new SliderLayout(floatSlider_, this);
+		return fSliderLayout;
+	}
 	default:
 		return (new QLabel("Currently Unavailable"));
 	}
@@ -113,6 +128,9 @@  void ControlFrame::setCurrentValue(const libcamera::ControlValue controlValue)
 		else
 			currentValue_->setText("False");
 		break;
+	case ControlTypeFloat:
+		currentValue_->setText(QString::number(controlValue.get<float>()));
+		break;
 	default:
 		break;
 	}
@@ -140,6 +158,9 @@  void ControlFrame::notifyControlChange()
 		else
 			controlValue.set<bool>(false);
 
+		break;
+	case ControlTypeFloat:
+		controlValue.set<float>(floatSlider_->value());
 		break;
 	default:
 		/* Nothing to emit so return */
diff --git a/src/qcam/settings/control_frame.h b/src/qcam/settings/control_frame.h
index 9c3b059b..e9e256aa 100644
--- a/src/qcam/settings/control_frame.h
+++ b/src/qcam/settings/control_frame.h
@@ -15,6 +15,8 @@ 
 #include <QString>
 #include <QWidget>
 
+#include "slider.h"
+
 class ControlFrame : public QFrame
 {
 	Q_OBJECT
@@ -44,6 +46,7 @@  private:
 
 	QCheckBox *controlCheckBox_;
 	QLabel *currentValue_;
+	FloatSlider *floatSlider_;
 
 	/* Helper Hunctions */
 	QString getDefaultValueQStr();