@@ -35,6 +35,7 @@ qcam_moc_headers = files([
'settings/control_frame.h',
'settings/controls_tab.h',
'settings/settings_dialog.h',
+ 'settings/slider.h',
'viewfinder_qt.h',
])
new file mode 100644
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>
+ *
+ * slider.h - qcam - Slider
+ */
+
+#pragma once
+
+#include <QSlider>
+#include <QWidget>
+
+class FloatSlider : public QSlider
+{
+ Q_OBJECT
+
+ const float INT_TO_FLOAT = 100.0;
+
+public:
+ FloatSlider(QWidget *parent)
+ : QSlider(parent)
+ {
+ connect(this, &QSlider::valueChanged,
+ this, &FloatSlider::notifyValueChanged);
+ }
+
+ ~FloatSlider() = default;
+
+ void setValue(float value)
+ {
+ QSlider::setValue(value * INT_TO_FLOAT);
+ }
+
+ void setRange(float min, float max)
+ {
+ QSlider::setRange(min * INT_TO_FLOAT, max * INT_TO_FLOAT);
+ }
+
+ float minimum()
+ {
+ return QSlider::minimum() / INT_TO_FLOAT;
+ }
+
+ float maximum()
+ {
+ return QSlider::maximum() / INT_TO_FLOAT;
+ }
+
+ float value()
+ {
+ return QSlider::value() / INT_TO_FLOAT;
+ }
+
+Q_SIGNALS:
+ void valueChanged(float value);
+
+public Q_SLOTS:
+ void notifyValueChanged(int value)
+ {
+ float floatVal = value / INT_TO_FLOAT;
+ Q_EMIT valueChanged(floatVal);
+ }
+};
Qt doesn't support float value sliders. Implement a float slider to help implementing intereactive controls GUI for ControlTypeFloat Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> --- src/qcam/meson.build | 1 + src/qcam/settings/slider.h | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/qcam/settings/slider.h