From patchwork Fri Jul 15 19:13:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16660 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 33F3BBE173 for ; Fri, 15 Jul 2022 19:14:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D12A663323; Fri, 15 Jul 2022 21:14:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657912458; bh=64RGzpjifWEuiuyqgxIJ9ekMYjRUd4lZwAYHLgeqNFA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Lmou+qHTXkeMkSdteH9OoNTBsDVpGMU9oTdsrou43tGrR+YeNllbmmdAOy1SPwBqb eF2sfZc9hW2PuqI2lkxJ6A3vlR1APQ5/I32OVd0u+YLjYHhjGL/7d3Ue/u1i175El8 cKnhd4RPqfYbfACiu9TRBWz633Ol8fUYXuyeeUOd2zqkuWlg8I54fKlqhUX8wf/cG+ LepFoU1oIuah4XcQeUApqBacizzgqdXVANbdnEO9Y4Tx6KsZmby+v2KXFnGw2ER/6Y dKMFJsknBcHZ8NMMBv4jwzAlPY8k2OvMzclV5+ffwMItrt12eyhgyx6u6gc6jxL14f F9bBOvAkqNpgw== Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B0F36331B for ; Fri, 15 Jul 2022 21:14:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="M55oUzei"; dkim-atps=neutral Received: by mail-pj1-x1034.google.com with SMTP id 89-20020a17090a09e200b001ef7638e536so12403808pjo.3 for ; Fri, 15 Jul 2022 12:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3lwUKm2bjTO3FJ8fuxAP9NamN7+Q/GTWJKHWvQehhm4=; b=M55oUzei/NUGXvb45cuubQiLunJOzk1temixX8aOf1RREHj0rPk0hZkDMGQTuWyTus wbtvz+PjKlvqhDZopZIcN7D8w8m6un4QDRbHhuT37bQBXL/IwfKHRaZcV48iu6FdRAKY O3XdPSldv3ToleACdn0VvBML/r+5/RveWGCR41a4EO/DcrlXCRRJIiLK0t0aLbCWDn4A 6qfq24xUw0Pa6xSl5eucLo5SeRE9OwuNRCdt8GxBKbR92BxhStEQq4mm7p2KA9aYvTAR dIs6lsYqzKw9pfjou7rWwLRtT+GRsz+Ed76YH9pzvHkYvI3/IRWxw/Maeu2FYXVq8WMD /FJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3lwUKm2bjTO3FJ8fuxAP9NamN7+Q/GTWJKHWvQehhm4=; b=cVkCkgnR2/uZyFJHzIrF6fJbg9efZTiDuO/Cu3UfhUxXP+Dlf2RIoUFM9mIx6B65Hs 0cxuonX3SGo1FmhIf8O+LUZN4XBc8iqmm8inbu/pq2fchB/ccUEwy1ZqUXW88da+aoxq KSGmDrXqec3oDSxZHIFdIOZtKhLod47vtziWmKpDz5v5+6OC+mBZviL69JC7obEuKS5P OavQUOIbJle2ZCfuhSfu7tQ26ZvDD8fwfOtz5yslsbn1VVTJIIc00Zb9piLX3fAP2Y/N Z1ovPfTmm53SWjuBdIR3tCUtXQh+f1ZB2vAPWqo2NOgaMZ8+s1ReWfKsb2dG/Bs9TDov 5OGg== X-Gm-Message-State: AJIora9I+ixS6p6dbe28HsRjDBPBlnTgeg5IoV94B87Un5RVxlk3oetW 3Vxv91yHu7iEFpMK9G15OARGBJt6s2Brlg== X-Google-Smtp-Source: AGRyM1uF7YzO3R/xyOEF6TNgDy8IM3W4Immj8YOVoE/2RGHyyFwnO5IEtVgV6zfKdZmEjziMG8cmuw== X-Received: by 2002:a17:902:dac1:b0:16c:6988:d226 with SMTP id q1-20020a170902dac100b0016c6988d226mr14958252plx.39.1657912454182; Fri, 15 Jul 2022 12:14:14 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1c27:d8e8:f9ac:919c:9ac8]) by smtp.gmail.com with ESMTPSA id s10-20020a170903214a00b0016be834d544sm3834315ple.237.2022.07.15.12.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 12:14:13 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sat, 16 Jul 2022 03:13:54 +0800 Message-Id: <20220715191400.890976-6-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220715191400.890976-1-utkarsh02t@gmail.com> References: <20220715191400.890976-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 05/11] qcam: ControlFrame: Add Current Value label X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Utkarsh Tiwari via libcamera-devel From: Utkarsh Tiwari Reply-To: Utkarsh Tiwari Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- 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(+) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 5d11ef98..0dc72f3c 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -355,6 +355,8 @@ void MainWindow::openSettingsDialog() settingsDialog_ = std::make_unique(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(request->controls()); + Q_EMIT processControls(controlListShared_); + } + } + /* Process buffers. */ if (request->buffers().count(vfStream_)) processViewfinder(request->buffers().at(vfStream_)); diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 05207023..97234d2e 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -57,6 +57,9 @@ public: bool event(QEvent *e) override; +Q_SIGNALS: + void processControls(std::shared_ptr); + private Q_SLOTS: void quit(); void updateTitle(); @@ -143,4 +146,5 @@ private: std::unique_ptr script_; libcamera::ControlList controlList_; + std::shared_ptr controlListShared_; }; diff --git a/src/qcam/settings/control_frame.cpp b/src/qcam/settings/control_frame.cpp index e335d373..3ab9fdb4 100644 --- a/src/qcam/settings/control_frame.cpp +++ b/src/qcam/settings/control_frame.cpp @@ -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()) + currentValue_->setText("True"); + else + currentValue_->setText("False"); + break; + default: + break; + } +} + void ControlFrame::notifyControlChange() { ControlValue controlValue = ControlValue(); diff --git a/src/qcam/settings/control_frame.h b/src/qcam/settings/control_frame.h index 61005ea5..9c3b059b 100644 --- a/src/qcam/settings/control_frame.h +++ b/src/qcam/settings/control_frame.h @@ -12,6 +12,7 @@ #include #include #include +#include #include 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(); diff --git a/src/qcam/settings/controls_tab.cpp b/src/qcam/settings/controls_tab.cpp index 30899783..496b5d3b 100644 --- a/src/qcam/settings/controls_tab.cpp +++ b/src/qcam/settings/controls_tab.cpp @@ -31,6 +31,7 @@ ControlsTab::ControlsTab(std::shared_ptr 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 camera_, * Qt Slots */ +void ControlsTab::notifyControlFrame(std::shared_ptr controlList) +{ + for (auto &[id, controlValue] : *(controlList)) + controlFrameMap_[id]->setCurrentValue(controlValue); +} + void ControlsTab::controlChanged(const libcamera::ControlId *controlId, const libcamera::ControlValue controlValue) { diff --git a/src/qcam/settings/controls_tab.h b/src/qcam/settings/controls_tab.h index 28efd35e..215c41fd 100644 --- a/src/qcam/settings/controls_tab.h +++ b/src/qcam/settings/controls_tab.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -15,6 +16,8 @@ #include #include +#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 controlList); private: std::shared_ptr controlList_; + std::map controlFrameMap_; }; diff --git a/src/qcam/settings/settings_dialog.h b/src/qcam/settings/settings_dialog.h index e6efd876..f0462d89 100644 --- a/src/qcam/settings/settings_dialog.h +++ b/src/qcam/settings/settings_dialog.h @@ -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); + void processControls(std::shared_ptr); };