@@ -355,6 +355,8 @@ void MainWindow::openSettingsDialog()
settingsDialog_ = std::make_unique<SettingsDialog>(camera_, this);
connect(settingsDialog_.get(), &SettingsDialog::controlListChanged,
this, &MainWindow::controlListLatch);
+ connect(this, &MainWindow::processControls,
+ settingsDialog_.get(), &SettingsDialog::processControls);
settingsDialog_->show();
}
@@ -823,6 +825,14 @@ void MainWindow::processCapture()
request = doneQueue_.dequeue();
}
+ /* Process controlList for current values. */
+ if (settingsDialog_) {
+ if (settingsDialog_->isVisible()) {
+ controlListShared_ = std::make_shared<const libcamera::ControlList>(request->controls());
+ Q_EMIT processControls(controlListShared_);
+ }
+ }
+
/* Process buffers. */
if (request->buffers().count(vfStream_))
processViewfinder(request->buffers().at(vfStream_));
@@ -57,6 +57,9 @@ public:
bool event(QEvent *e) override;
+Q_SIGNALS:
+ void processControls(std::shared_ptr<const libcamera::ControlList>);
+
private Q_SLOTS:
void quit();
void updateTitle();
@@ -143,4 +146,5 @@ private:
std::unique_ptr<CaptureScript> script_;
libcamera::ControlList controlList_;
+ std::shared_ptr<const libcamera::ControlList> controlListShared_;
};
@@ -33,6 +33,7 @@ ControlFrame::ControlFrame(const libcamera::ControlId *control,
* ownership to its parent widget.
*/
frameVLayout->addWidget(defaultValueLabel());
+ frameVLayout->addWidget(currentValueLabel());
frameVLayout->addWidget(controlInteraction());
setFrameStyle(QFrame::StyledPanel);
@@ -83,10 +84,41 @@ QWidget *ControlFrame::controlInteraction(QWidget *parent)
}
}
+QWidget *ControlFrame::currentValueLabel(QWidget *parent)
+{
+ QWidget *containerWidget = new QWidget(parent);
+
+ QHBoxLayout *HCurrentValueLayout = new QHBoxLayout(containerWidget);
+
+ currentValue_ = new QLabel;
+
+ HCurrentValueLayout->addWidget(new QLabel("Current Value: "));
+ HCurrentValueLayout->addWidget(currentValue_);
+
+ /* Align with ControlName. */
+ HCurrentValueLayout->setAlignment(Qt::AlignLeft);
+ HCurrentValueLayout->setMargin(0);
+
+ return containerWidget;
+}
/* -----------------------------------------------------------------------------
* Qt Slots
*/
+void ControlFrame::setCurrentValue(const libcamera::ControlValue controlValue)
+{
+ switch (control_->type()) {
+ case ControlTypeBool:
+ if (controlValue.get<bool>())
+ currentValue_->setText("True");
+ else
+ currentValue_->setText("False");
+ break;
+ default:
+ break;
+ }
+}
+
void ControlFrame::notifyControlChange()
{
ControlValue controlValue = ControlValue();
@@ -12,6 +12,7 @@
#include <QCheckBox>
#include <QFrame>
#include <QLabel>
+#include <QString>
#include <QWidget>
class ControlFrame : public QFrame
@@ -24,6 +25,7 @@ public:
QWidget *parent);
~ControlFrame() = default;
+ void setCurrentValue(const libcamera::ControlValue controlValue);
Q_SIGNALS:
void controlChanged(const libcamera::ControlId *controlId,
const libcamera::ControlValue);
@@ -37,9 +39,11 @@ private:
/* Widgets */
QWidget *controlInteraction(QWidget *parent = nullptr);
+ QWidget *currentValueLabel(QWidget *parent = nullptr);
QLabel *defaultValueLabel(QWidget *parent = nullptr);
QCheckBox *controlCheckBox_;
+ QLabel *currentValue_;
/* Helper Hunctions */
QString getDefaultValueQStr();
@@ -31,6 +31,7 @@ ControlsTab::ControlsTab(std::shared_ptr<libcamera::Camera> camera_,
int controlCount = 0;
for (auto &[control, info] : camera_->controls()) {
ControlFrame *controlFrame = new ControlFrame(control, info, this);
+ controlFrameMap_[control->id()] = controlFrame;
connect(controlFrame, &ControlFrame::controlChanged,
this, &ControlsTab::controlChanged);
@@ -50,6 +51,12 @@ ControlsTab::ControlsTab(std::shared_ptr<libcamera::Camera> camera_,
* Qt Slots
*/
+void ControlsTab::notifyControlFrame(std::shared_ptr<const libcamera::ControlList> controlList)
+{
+ for (auto &[id, controlValue] : *(controlList))
+ controlFrameMap_[id]->setCurrentValue(controlValue);
+}
+
void ControlsTab::controlChanged(const libcamera::ControlId *controlId,
const libcamera::ControlValue controlValue)
{
@@ -7,6 +7,7 @@
#pragma once
+#include <map>
#include <memory>
#include <libcamera/camera.h>
@@ -15,6 +16,8 @@
#include <QVBoxLayout>
#include <QWidget>
+#include "control_frame.h"
+
class ControlsTab : public QScrollArea
{
Q_OBJECT
@@ -29,7 +32,9 @@ Q_SIGNALS:
public Q_SLOTS:
void controlChanged(const libcamera::ControlId *controlId,
const libcamera::ControlValue controlValue);
+ void notifyControlFrame(std::shared_ptr<const libcamera::ControlList> controlList);
private:
std::shared_ptr<libcamera::ControlList> controlList_;
+ std::map<const unsigned int, ControlFrame *> controlFrameMap_;
};
@@ -34,6 +34,8 @@ public:
settingTabWidget->addTab(controlsTab, "Controls");
connect(controlsTab, &ControlsTab::controlListChanged,
this, &SettingsDialog::controlListChanged);
+ connect(this, &SettingsDialog::processControls,
+ controlsTab, &ControlsTab::notifyControlFrame);
setWindowTitle("Settings");
}
@@ -41,4 +43,5 @@ public:
Q_SIGNALS:
void controlListChanged(std::shared_ptr<const libcamera::ControlList>);
+ void processControls(std::shared_ptr<const libcamera::ControlList>);
};
Add a QLabel which displays the Current value of the control. Currently this only supports ControlTypeBool. At start do not display any Current value as we cannot be sure of the starting conditions and the controls that have been applied. When a request completes succesfully completes, we use its ControlList to update the currentValue. The current model for sending the controlValue is : MainWindow -> Settings -> Control Tab -> Control Frame Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> --- src/qcam/main_window.cpp | 10 +++++++++ src/qcam/main_window.h | 4 ++++ src/qcam/settings/control_frame.cpp | 32 +++++++++++++++++++++++++++++ src/qcam/settings/control_frame.h | 4 ++++ src/qcam/settings/controls_tab.cpp | 7 +++++++ src/qcam/settings/controls_tab.h | 5 +++++ src/qcam/settings/settings_dialog.h | 3 +++ 7 files changed, 65 insertions(+)