From patchwork Fri Aug 12 12:46:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17101 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 02A3BBE173 for ; Fri, 12 Aug 2022 12:47:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C243563339; Fri, 12 Aug 2022 14:47:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660308436; bh=EZyEcQ7PKeKc2DfvktgRpWMlok6oAGxXGjUsMD/mOH4=; 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=bNghF/TAY6ikWBjdYRPCzI1yMp2szceyrnSm+o3YJqmSqYfiyQIxkvfpmXPvteSDQ iwpSZciI5zoYMISX/Qv53nEkM2FTsuy+btZEKxHfYIoOdfODq1cBQPVJ4jZL8a+42r P27NyNiQtjof7Kp1u+buX4rFi2TjbZGLrdLCDC+roUD8SpTcb1g895NZsV/x3fLBJK k+6hSCLdxOLImjEFZLgvpkfJDBI4gUEDbk+/8rBhyqqVLNcK79nJKrMHi9goCZ3KAL grJqfELK76mWqt9jfs1Nz8MQpnFYcdL8qTkjFbwSeTnyKoo8I4iyLpZCy0J99isTNv m0B4NQjczWvew== Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BD4763339 for ; Fri, 12 Aug 2022 14:47:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AC8dmI6e"; dkim-atps=neutral Received: by mail-pj1-x1029.google.com with SMTP id d65-20020a17090a6f4700b001f303a97b14so827913pjk.1 for ; Fri, 12 Aug 2022 05:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=X9GlEOeBAytrLDIMS7fbF23OZRtclahma2t8K369wZo=; b=AC8dmI6enb0rmyTCO2kn8Ioxl8aKL5k4/QbcdfiNQ+XGUH6UdIEgqIi6xQaS++X3M3 GxmKBAsOT3CV1x9+O3eBQC1fDI2uPo986biP63LOAtauTcfgb9XL8ywqjd8ozCXQGBxm 1/st+T/VHqPWpj2KyNY98V0ftPpxv9h5+NjqIw6CY8b4izXttRx8q9KP7t/1hbRvESD3 Y2u4Cpl5esgxSFzZEbX2nYgXtby9XJT8TRkckeB1VGT6gUIS1KbdILiMQqRAZPBz7UzZ +aHDvIF/WWLexLWjJKa3/M29ectOgOBXY26UGq7iTYv8DoKv1eFhJNlly+7C8c6CpoeI RGLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=X9GlEOeBAytrLDIMS7fbF23OZRtclahma2t8K369wZo=; b=O78gnesJwE6Te1jvcVXWwAFy0E3Pwfl8uZVePSTSt172jM8NZXD1p+EINsM1yTnt0O m1xlXGl+yZdlFBGL8JwbrrIkfTxZJ9J0FHHjzUHqdrD+zQGbYfFSE2uqvNSgo+yxaEZ0 BDHg4+9YydfZnnCh0nY+8P5F6tC3XdlqjlhKAzsMmM7/hHsRRWQZGZT8fQREww69NOJB AhluqlhV/KuCt7Nhxj4nEE3XBv0TR1XQEtt/bZT0UfBweisgxt0r+nqRI1+mg5mXtUNn p1M64upHivQR+MI02TwcHuqv8zKKv5pxxLFbZo23zaNe2vOJ8WV7hruAaUD73AKzjo4p /GbA== X-Gm-Message-State: ACgBeo17/Y0g9XxmkY2wz5Ab3LdJHiTQblS9MdLqDLnisBYXtxCwbtEv txQXvzMiMxKeVY3qKPfF1ftJ7y1VYZ0= X-Google-Smtp-Source: AA6agR5TO1pxnD4HDV+xgR5t6q5vkkTg+w0zt29LUJPnkIV97skdrWD1+61aDzkQbSX1N9XJFdpoAw== X-Received: by 2002:a17:90b:4a07:b0:1f5:1aff:4af with SMTP id kk7-20020a17090b4a0700b001f51aff04afmr3980374pjb.124.1660308432787; Fri, 12 Aug 2022 05:47:12 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:dc0d:d8e:96a2:2dbe:5a83]) by smtp.gmail.com with ESMTPSA id e6-20020a17090a728600b001f069352d73sm1431785pjg.25.2022.08.12.05.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 05:47:12 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 12 Aug 2022 18:16:45 +0530 Message-Id: <20220812124651.27496-6-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220812124651.27496-1-utkarsh02t@gmail.com> References: <20220812124651.27496-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 87cdad82..4ee3a013 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -278,6 +278,8 @@ void MainWindow::openSettingsDialog() settingsDialog_ = new SettingsDialog(camera_, this); connect(settingsDialog_, &SettingsDialog::controlListChanged, this, &MainWindow::controlListLatch); + connect(this, &MainWindow::processControls, + settingsDialog_, &SettingsDialog::processControls); settingsDialog_->show(); } @@ -795,6 +797,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 8137e736..8615d22c 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -61,6 +61,9 @@ public: bool event(QEvent *e) override; +Q_SIGNALS: + void processControls(std::shared_ptr); + private Q_SLOTS: void quit(); void updateTitle(); @@ -148,4 +151,5 @@ private: std::unique_ptr script_; std::string scriptPath_; libcamera::ControlList controlList_; + std::shared_ptr controlListShared_; }; diff --git a/src/qcam/settings/control_frame.cpp b/src/qcam/settings/control_frame.cpp index 273ce79b..2554f70d 100644 --- a/src/qcam/settings/control_frame.cpp +++ b/src/qcam/settings/control_frame.cpp @@ -32,6 +32,7 @@ ControlFrame::ControlFrame(const ControlId *control, * ownership to its parent widget. */ frameVLayout->addWidget(defaultValueLabel()); + frameVLayout->addWidget(currentValueLabel()); frameVLayout->addWidget(controlInteraction()); setFrameStyle(QFrame::StyledPanel); @@ -82,10 +83,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); };