[libcamera-devel] [PATCH 09/11] qcam: ControlFrame: Add GUI interaction to float controls
Utkarsh Tiwari
utkarsh02t at gmail.com
Fri Jul 15 21:13:58 CEST 2022
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 at gmail.com>
---
src/qcam/settings/control_frame.cpp | 21 +++++++++++++++++++++
src/qcam/settings/control_frame.h | 3 +++
2 files changed, 24 insertions(+)
diff --git a/src/qcam/settings/control_frame.cpp b/src/qcam/settings/control_frame.cpp
index 3ab9fdb4..10dcd05a 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 libcamera::ControlId *control,
@@ -79,6 +81,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"));
}
@@ -114,6 +129,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;
}
@@ -141,6 +159,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();
--
2.25.1
More information about the libcamera-devel
mailing list