From patchwork Fri Aug 12 12:46:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17098 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 71B1CBE173 for ; Fri, 12 Aug 2022 12:47:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2C75061FAB; Fri, 12 Aug 2022 14:47:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660308430; bh=PBNtZh/GBCMXZFNxvU/c9S6wR55Oyh3d5ac/jw5ZbN4=; 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=4ZgAV29+5abmpsFjA1NvbLsOOrOUTizaQFNmuyExHsRuC2Kuj5dV1JjypFeZha2T7 gzgnqMzxGfn+iWrqCMTmdZyzOAUr+LdactAT9gHxbQhLFFCNi5kNTn8hv42W7LtXui g+TaHYNmWHo/kRLv45+GTvs8iU50bwBWHmX1yFC+2YUjXB296o+9UdwpkhPTpTJyZc 4ry3DlGMrquHLr25IQV7ZjubQ4FVblh1LTVBPKhez3QGiMG6tfoDd4IlZ6q43ihd3N AUBaGrcjAU7AwTfNf9Z/b245RSRi0+eeMINEhWKiKJIUb3qPLJo/enM+zBjqq1qNQC 1vNKZGX2pDTdA== Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 39F9B603EA for ; Fri, 12 Aug 2022 14:47:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="C//4Of9B"; dkim-atps=neutral Received: by mail-pf1-x429.google.com with SMTP id h28so850203pfq.11 for ; Fri, 12 Aug 2022 05:47:08 -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=ghblknVhGijt/nmW4rVKt6Xyc1ourgY6xruFoCTihac=; b=C//4Of9BNxWEhvbgQaRSpOISVthlOUDG+Wm3J8AZk8AsfSZZlT1+YHVmvLfLsAkL/p K6la3IMHI8YwwWI6mW9jvwZ41pILa4OhyeZFZf3zT5xsahSGG+Y7kugSEhhhMeH5xpAN psJEjsJpHuXboaCzn5P4vM/Rnls2t0zxRpM7ZEBDXqRWaQhG4QauxRe/+x0OKF8XUecT ILikiRMKxzg72Zlrj2hPHwod4Jdye3eFLFLiLRyFRgiY7ZZ5NtCZtzO+1v7OO/WyQlyU IRpF7EU/VKm5BcWAHrr2GFnjuFl07na30fIrhOIvZEm6Xftm4/R0nKz3O6lm+jGCbRPS el0Q== 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=ghblknVhGijt/nmW4rVKt6Xyc1ourgY6xruFoCTihac=; b=Wrt6kAXt4gfwA+cxNW0GZeUsOSCklkXZxf9m958/O1Y1oUdjakbCleDr32UUwuAgge VyfQs7gf5V55nfpzeAnVbYXIgjm/uxoIfUL2F9wwpzj1+VNzmDZ16Edgl18RAcw1yqae ObROnGeY4l98Pj4rQ5dLu74bwyMyavYxRqXjx1I7OelCVn0URRHQNPg226cYrBVVvyHW uwtdpsrHZ2Hy4sIkpituH4tORZ5+GLPWQmyw4bNnYumgwbD4GvCFtvJ9FiCY3E5uwOQI Gydsf2PpU8AAU8sG0gHHS/TXV+lwX8nmYq9rcnMWtX8CwCnE3oGft1W5l1A0VhLx9Hce 90ng== X-Gm-Message-State: ACgBeo2U2EyQvQAFjUF6gexJv3niwyLbU8grVgXT61D9Acrr92XB0ipQ O8m/zf7CCUTg8KUQ4yEl4nlWo8eObh8= X-Google-Smtp-Source: AA6agR40EPJkbX2Phwc1hCLO/0kuzY0HOKXnSUA5XOrNwU1FFg3qAjMX0yG/1fnwXhmoZDOjLBdCnw== X-Received: by 2002:a63:14c:0:b0:41d:c975:1ed6 with SMTP id 73-20020a63014c000000b0041dc9751ed6mr3032099pgb.39.1660308426473; Fri, 12 Aug 2022 05:47:06 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 05:47:06 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 12 Aug 2022 18:16:42 +0530 Message-Id: <20220812124651.27496-3-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 02/11] qcam: ControlFrame: Display defualt value of controls 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" 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 --- Difference from v1: 1. Fix comment styling 2. Now parameters can drop libcamera:: as effect from 1/11 src/qcam/settings/control_frame.cpp | 48 +++++++++++++++++++++++++++-- src/qcam/settings/control_frame.h | 9 ++++++ src/qcam/settings/controls_tab.cpp | 2 +- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/qcam/settings/control_frame.cpp b/src/qcam/settings/control_frame.cpp index 8b1162db..79cf67eb 100644 --- a/src/qcam/settings/control_frame.cpp +++ b/src/qcam/settings/control_frame.cpp @@ -16,13 +16,57 @@ using namespace libcamera; -ControlFrame::ControlFrame(const ControlId *control, QWidget *parent) - : QFrame(parent), control_(control) +ControlFrame::ControlFrame(const ControlId *control, + const 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()) { + return QString("True"); + } else { + return QString("False"); + } + case ControlTypeInteger32: + return QString::number(controlInfo_.def().get()); + case ControlTypeInteger64: + return QString::number(controlInfo_.def().get()); + case ControlTypeFloat: + return QString::number(controlInfo_.def().get()); + default: + return QString("Unavailable"); + } +} diff --git a/src/qcam/settings/control_frame.h b/src/qcam/settings/control_frame.h index 10690674..280f07e0 100644 --- a/src/qcam/settings/control_frame.h +++ b/src/qcam/settings/control_frame.h @@ -10,6 +10,7 @@ #include #include +#include #include class ControlFrame : public QFrame @@ -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(); }; diff --git a/src/qcam/settings/controls_tab.cpp b/src/qcam/settings/controls_tab.cpp index 33ed9332..adc24326 100644 --- a/src/qcam/settings/controls_tab.cpp +++ b/src/qcam/settings/controls_tab.cpp @@ -26,7 +26,7 @@ ControlsTab::ControlsTab(std::shared_ptr 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);