@@ -14,13 +14,61 @@
#include <QString>
#include <QVBoxLayout>
-ControlFrame::ControlFrame(const libcamera::ControlId *control, QWidget *parent)
- : QFrame(parent), control_(control)
+using namespace libcamera;
+
+ControlFrame::ControlFrame(const libcamera::ControlId *control,
+ const libcamera::ControlInfo &controlInfo,
+ QWidget *parent)
+ : QFrame(parent), control_(control), controlInfo_(controlInfo)
{
/* Main layout for the frame */
QVBoxLayout *frameVLayout = new QVBoxLayout(this);
frameVLayout->addWidget(new QLabel(QString::fromStdString(control_->name())));
+ /*
+ * No need to pass parents to widgets,
+ * as QVBoxLayout transfers ownership to
+ * its parent widget.
+ */
+ frameVLayout->addWidget(defaultValueLabel());
+
setFrameStyle(QFrame::StyledPanel);
}
+
+/* -----------------------------------------------------------------------------
+ * Widgets
+ */
+
+QLabel *ControlFrame::defaultValueLabel(QWidget *parent)
+{
+ QLabel *defaultValLabel = new QLabel(parent);
+
+ defaultValLabel->setText("Default Value: " + getDefaultValueQStr());
+
+ return defaultValLabel;
+}
+
+/* -----------------------------------------------------------------------------
+ * Helpers
+ */
+
+QString ControlFrame::getDefaultValueQStr()
+{
+ switch (control_->type()) {
+ case ControlTypeBool:
+ if (controlInfo_.def().get<bool>()) {
+ return QString("True");
+ } else {
+ return QString("False");
+ }
+ case ControlTypeInteger32:
+ return QString::number(controlInfo_.def().get<int32_t>());
+ case ControlTypeInteger64:
+ return QString::number(controlInfo_.def().get<int64_t>());
+ case ControlTypeFloat:
+ return QString::number(controlInfo_.def().get<float>());
+ default:
+ return QString("Unavailable");
+ }
+}
@@ -9,6 +9,7 @@
#include <libcamera/controls.h>
+#include <QLabel>
#include <QFrame>
#include <QWidget>
@@ -18,9 +19,17 @@ class ControlFrame : public QFrame
public:
ControlFrame(const libcamera::ControlId *control,
+ const libcamera::ControlInfo &controlInfo,
QWidget *parent);
~ControlFrame() = default;
private:
const libcamera::ControlId *control_;
+ const libcamera::ControlInfo &controlInfo_;
+
+ /* Widgets */
+ QLabel *defaultValueLabel(QWidget *parent = nullptr);
+
+ /* Helper Hunctions */
+ QString getDefaultValueQStr();
};
@@ -26,7 +26,7 @@ ControlsTab::ControlsTab(std::shared_ptr<libcamera::Camera> camera_,
int controlCount = 0;
for (auto &[control, info] : camera_->controls()) {
- ControlFrame *controlFrame = new ControlFrame(control, this);
+ ControlFrame *controlFrame = new ControlFrame(control, info, this);
controlGLayout->addWidget(controlFrame, controlCount / 2,
controlCount % 2);
Display a QLabel below the Control Name showing the default value for the controls. This adds support to Display defualt value for the control types : ControlTypeBool ControlTypeInteger32 ControlTypeInteger64 ControlTypeFloat Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> --- src/qcam/settings/control_frame.cpp | 52 +++++++++++++++++++++++++++-- src/qcam/settings/control_frame.h | 9 +++++ src/qcam/settings/controls_tab.cpp | 2 +- 3 files changed, 60 insertions(+), 3 deletions(-)