From patchwork Fri Jul 15 19:13:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16662 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 7A27DBE173 for ; Fri, 15 Jul 2022 19:14:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2A3A963322; Fri, 15 Jul 2022 21:14:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657912461; bh=ElMvh5HqKigp+v0NP59wRUksIO/4XokrGNUsbl0dO7U=; 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=TP1KdlYFyr8FV+p00FJ8TUElIX5CWtzCOJtXD5Y7aPur8ZU1WI+oDdzU4TQlcNKdb ERCqSVLs9OR6ws3pY85jfeDmwpGNLH3BHQlKtw3eDqJ5J8MUf2C2sM1PjKPTVDp+IE ShqT7ia6aBkoUqCj2fmp+ypOhttZ/fXCFq7aSC8HmisJBRqnZdMj0FgkUUAK3+WWcz 2wE+A2ANL66pDaGeLziaQeofcvRooPsYZpKdIfopYrGXId2GcQ0vhm64B366Xgctvw jcM+M2L7jA7BHhCvnLPawzQnceT0BlEGJYmvKN3RJjA0xQKiFlBw0eNjvgwsdpuSxN tUDOdCu/wmtaQ== Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 27F246331B for ; Fri, 15 Jul 2022 21:14:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kS3uw4GZ"; dkim-atps=neutral Received: by mail-pj1-x1030.google.com with SMTP id o5-20020a17090a3d4500b001ef76490983so7020861pjf.2 for ; Fri, 15 Jul 2022 12:14:19 -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=H6Q3a3MyWxu+j9oPQ0Vx1yJWr4fzvLodrhiRMAc7T4c=; b=kS3uw4GZYWL9laWZ3f8tdkQ/RtKOY2Rox2am7CIsJzdV22UcB5wf4pPZD0WRMHJc5p O4leo2S1qUEcoi32HCj94p7RGwgkwkGXUgmWuxBtC9lJg90wp4l+K+Z8ZRo7iwFwm9xL 6rZBozu1QF2ZDiI9O1Be2BFZ/vVrnu732y5qRfC61JSd1Rp5pJVxsbvHlRRAeIZfUt7z 8hy/hwz9LRAgyRXF2AL0b+u3c7xxHG47tgEV4OtANBzPCtbiZdTYbQS1896xux6xgPUn fyNt5xhZT+VFl7WQ+ZJb2uCeLbSsruQgvPhnU1+WqPEwNfYfDBHMKNmcKIEKwM5TiQJ2 zH9A== 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=H6Q3a3MyWxu+j9oPQ0Vx1yJWr4fzvLodrhiRMAc7T4c=; b=lxezBLcxja0uqkYe1NNflEnM/9kPHXyUmK8lTL5EUWCPBSFe86OrxTF1u+6fXMxbTp 5fOUd4tj8uffyBzBylHlqimSEINH1sOzJRh613wnAzbDSGQ/sDMmR0ximvfHf+gt3Fw6 jkNERuSTReZIp7LRfB4Cmsdc2IP81vEvyljoMYfmGLy9JBmhDdEHAjgd3kIZ3WtdhVXx Pi/dq5+cJBtTbYa6XPlkHfNUUc/2IcVq+nDfAFzYe6Ieeo+bEEs953xi6UnMaFc8x2wO 0n5s7IDJpFQQevyzEarwFpbdvMznSQK004Pn1zvlfywBefnvAKajLgkvgcO3D5L30vLl xzzg== X-Gm-Message-State: AJIora/IvcvPSlmeiRyL9kRprLNddBOwjQ2lZjSj5+FEUxTVkAyN10Kl LdLtv9SnTqcCv2Cuwztvl+bDmk5Bhk5ugw== X-Google-Smtp-Source: AGRyM1srF8wBGx6y07Soqn5dwzWy1jugISSr3Ltb1SKajJ8qVREQMBdLjGGrw37NmQgVNZq658V3uw== X-Received: by 2002:a17:903:120e:b0:16b:8167:e39e with SMTP id l14-20020a170903120e00b0016b8167e39emr14925490plh.165.1657912457431; Fri, 15 Jul 2022 12:14:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 12:14:17 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sat, 16 Jul 2022 03:13:56 +0800 Message-Id: <20220715191400.890976-8-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 07/11] qcam: Slider: Add SliderLayout to display value 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" Implement SliderLayout which displays minimum Value, maximum Value, currentValue of the slider. The currentValue may not reflect the immediate current value of the control. The SliderLayout is inherits the Slider type so it can support both floatSlider and integer sliders. Signed-off-by: Utkarsh Tiwari --- src/qcam/settings/slider.h | 81 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/src/qcam/settings/slider.h b/src/qcam/settings/slider.h index f4a4825c..008c746c 100644 --- a/src/qcam/settings/slider.h +++ b/src/qcam/settings/slider.h @@ -7,18 +7,46 @@ #pragma once +#include +#include #include +#include #include -class FloatSlider : public QSlider +class Slider : public QSlider +{ + Q_OBJECT + +public: + Slider(QWidget *parent = nullptr) + : QSlider(parent){}; + ~Slider() = default; + + virtual QString maximumValueStr() + { + return QString::number(maximum()); + } + + virtual QString minimumValueStr() + { + return QString::number(minimum()); + } + + virtual QString currValueStr() + { + return QString::number(value()); + } +}; + +class FloatSlider : public Slider { Q_OBJECT const float INT_TO_FLOAT = 100.0; public: - FloatSlider(QWidget *parent) - : QSlider(parent) + FloatSlider(QWidget *parent = nullptr) + : Slider(parent) { connect(this, &QSlider::valueChanged, this, &FloatSlider::notifyValueChanged); @@ -51,6 +79,21 @@ public: return QSlider::value() / INT_TO_FLOAT; } + QString maximumValueStr() override + { + return QString::number(maximum()); + } + + QString minimumValueStr() override + { + return QString::number(minimum()); + } + + QString currValueStr() override + { + return QString::number(value()); + } + Q_SIGNALS: void valueChanged(float value); @@ -61,3 +104,35 @@ public Q_SLOTS: Q_EMIT valueChanged(floatVal); } }; + +class SliderLayout : public QWidget +{ + Q_OBJECT + +public: + SliderLayout(Slider *slider, QWidget *parent = nullptr) + : QWidget(parent) + { + QVBoxLayout *mainVLayout = new QVBoxLayout(this); + + QHBoxLayout *labelHLayout = new QHBoxLayout; + + QLabel *minLabel = new QLabel(slider->minimumValueStr()); + QLabel *currValueLabel = new QLabel(slider->currValueStr()); + QLabel *maxLabel = new QLabel(slider->maximumValueStr()); + + connect(slider, &Slider::valueChanged, + this, [currValueLabel, slider]() { + currValueLabel->setText(slider->currValueStr()); + }); + + labelHLayout->addWidget(minLabel); + labelHLayout->addStretch(); + labelHLayout->addWidget(currValueLabel); + labelHLayout->addStretch(); + labelHLayout->addWidget(maxLabel); + + mainVLayout->addLayout(labelHLayout); + mainVLayout->addWidget(slider); + } +};