From patchwork Fri Jul 15 19:13:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16657 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 D23DBC3274 for ; Fri, 15 Jul 2022 19:14:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0D24363317; Fri, 15 Jul 2022 21:14:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657912452; bh=/qKLkWUUn1tNProfmPvTMn//dPD1XB0Co6XOj+4bWuI=; 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=NRxawFfWv6Pkcio7CEaE4+isT+0jH7tHIR2Y9rPHAUBnR5ZmOj7U4+x1OFz0NyLAR Ea04pAUcpSpnTVrolJ4nJFH5zt5y4puwg9Tv1udS3L6FSatVj1gRhimthaEhDclcLR 010eff3c16nQeJwG1CcddqZcaOImfuNHzNUXC7NvDuSkA8GQJFRdc1issU1BbGRH15 teMDSKuE0/anin5u4vPA/W4+y0P4hrLFiHSjfmKdBrE9TfBNBXWbIbGjjmR7Q5eRd6 FGmiMMPv2D+yT/8wpeWnNoB77tG58W0nMYXS4GktRoPP+T/US3QdCKrCznoaNm0dOr ZbbLLcv7bO9ag== Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 022FA6330F for ; Fri, 15 Jul 2022 21:14:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EwYXvBjM"; dkim-atps=neutral Received: by mail-pj1-x102f.google.com with SMTP id o3-20020a17090a744300b001ef8f7f3dddso7000043pjk.3 for ; Fri, 15 Jul 2022 12:14:10 -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=Uz+u8kCOf37oqVbQNCDdLgtf+EpJ0K3cuUXKTKqQAg0=; b=EwYXvBjMBSKobG77FetoGGWKn5VxcjLK5gYjv2Kdy5tPEk2V+C1QoMzCQNZT2NG5KO Ixvo+FQvQ/IqUUVwpEcRp52h8ynGeXdguOIBbRZRq6gYxO9evO3e8xrsGQwmfrlQlFQg ApUX/QjchhhFB6tgmdgY7VKpQ9j5oFBvv4afa+b9k+ro7Mk5X0Gh6HeKqKnc3hmVPp59 h26pX7SEDuJKnsh/Vbx/s+Iynw/X0bqadF2w6+6cNj7OYEDkcE6ZMapyhwZxcFeeIiI2 UJIxC8j8ATYqGFNlqWptyJWrKiZ8kRQIdpaHH4ggia1gaDIywXWOANiWLauZVTfsw+CD 2AUA== 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=Uz+u8kCOf37oqVbQNCDdLgtf+EpJ0K3cuUXKTKqQAg0=; b=OxFzxfUUq5PAaIjKnkpbFbCRxs/7uA7WFle7Jn29BgUeSCOAO8aRoRnKFcUSRJtI+W KacDjYdo1wb5E0L0y1pZiFzc7KppQLSIJ49siWeVfbairjHuhHjU7K3zk8Sz6ikZbsRG ondsWNoWDQkU7iJXz1eYQsSvLW3JK02z0E/jmjGy98ZuwbCLPOTsI3yzuOQ3n5FSWDnv 2Ztm8H7zxm6Mimz5bfgsedPZzZ3YohDCh43SywbHuJulVZL/SPyYQ/TsIpO7Bcih+Lhq BUOlJIoI3KxWmK7VfU+udRdZgT63fpv+F2w9z/AgLlOPXfoAtklHCWNok11LI7UI4oho +mMg== X-Gm-Message-State: AJIora9ykUud4BO7azS/csMPf6kfDFD5ZJxfxkFC4E/BNrqRsiBx+LmP tfyg7zkuGQ9WLd9614oofsGRS0NuNOk5Og== X-Google-Smtp-Source: AGRyM1u0nrS+1Dj6Sjk7Y48oMRL0pVC8mMzNlYEkwzrXydDB92RheVb5MWVbm2xgaQ/l0v/slpe5rg== X-Received: by 2002:a17:90b:4c48:b0:1ef:c839:c68c with SMTP id np8-20020a17090b4c4800b001efc839c68cmr17232832pjb.233.1657912449285; Fri, 15 Jul 2022 12:14:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 12:14:09 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sat, 16 Jul 2022 03:13:51 +0800 Message-Id: <20220715191400.890976-3-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 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 --- 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(-) diff --git a/src/qcam/settings/control_frame.cpp b/src/qcam/settings/control_frame.cpp index 6f5cba6d..785e4040 100644 --- a/src/qcam/settings/control_frame.cpp +++ b/src/qcam/settings/control_frame.cpp @@ -14,13 +14,61 @@ #include #include -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()) { + 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..884feb6b 100644 --- a/src/qcam/settings/control_frame.h +++ b/src/qcam/settings/control_frame.h @@ -9,6 +9,7 @@ #include +#include #include #include @@ -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);