From patchwork Fri Aug 12 12:46:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17103 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 74659BE173 for ; Fri, 12 Aug 2022 12:47:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4163C63337; Fri, 12 Aug 2022 14:47:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660308440; 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=U2gvreRBQ6Y3TpofvZHoVL2AVMbNIm93sJfyyfrirxF5CpXR6469dmCaCNVCBzauo B4U8JxXYddDExmMOC5nMVYrG4jOcBlDmP1CC1JfpyDnn/XYTybhQ+/XI3epDb0zSAK LM5SBkjLZrEY77DYyJgBnvX2FnM1c/F3TYF/UX/dHmeUtsoPtZx7bHjYcn8sYr/Rro +lwwquo4scLG+GAl7D8dIP2KOWUy2zOlnFHek/shckE4+VTBz9gYAsm0thh0FrP7yF 5YVT+UHaIBDk9mifc7M2dJUoxX1r5TKXzklyKdcWx+N/3RLrAss+KgW0gojY04oyDs BUK6lenkQrkEw== Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 82B976333C for ; Fri, 12 Aug 2022 14:47:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Cy1uBZPG"; dkim-atps=neutral Received: by mail-pg1-x52e.google.com with SMTP id bh13so713459pgb.4 for ; Fri, 12 Aug 2022 05:47:18 -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=H6Q3a3MyWxu+j9oPQ0Vx1yJWr4fzvLodrhiRMAc7T4c=; b=Cy1uBZPGf7GqR7jCdBjyRsvw79AoSRWSaq3vK6udm8+PsF7euz4ia/m8GfCLyxSVzl WYdAo8YPt1oYvv6NV+ODvO7P3V/1W/Xn3rPE0Wto2hAOWytZQvBeNe6dq+CYeRIoyDaq tHKWRMRqykoyS1MHhUBgIzEmX9n1uijHT7cYfGINMUiENFfFJHQaDTQL4vref6+Q/QS3 jMBy6OIZqhu6vHGu2qAPRa/lRUZbp/D2u7zvFdYBaT/hyCDF8SojfioccTE2bELq86D7 DeB3LOWM9udupEMHTQO2SUbCAEQnZGGNn/kkVSBdIOKbKm/NIu0adVY2I8xUBlpPnur3 RxKw== 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=H6Q3a3MyWxu+j9oPQ0Vx1yJWr4fzvLodrhiRMAc7T4c=; b=BRoRrLpzowcYVfwdF6miJdkKYPs1Az/MAJqGAaieWgxcycjuifNnCB3pghwBaTRgZh i1mJV/x7VkE00xEkNfC8EKE6c3OUokYoN3jy8WIFjPJ4MK3coj48bGhjAlFNVcfKYqws QLNg3p9EangnFsfgLae+3LiufYeeYY4HmArPmzXppIYcKsQmIzMKhPF6mAyyPRAHEETC 3u3p9sVu1garRHgLmhfTfilHgdM1rXvX/XetVV5JYoJfCfFx7mFMwGh8xPghN6j+X9fa Np3nDaZ+xkAe9hjkgaRlpKlKFp179Y0f0QaJceH4h4aZc0xSczJuzs5cVzyqLMNVjFea rrEQ== X-Gm-Message-State: ACgBeo3Atr0yol/xpRbgm1AIQN2uypSfcdv18TdYDgPTLcwgfndGmY5D GwpUFs3KAm7pcZnoEAu62znncM/RRNU= X-Google-Smtp-Source: AA6agR7ca+fNGYa2rr9F2X5qwRaQ1jeN4B0Fp9R4jCD1OlCkSi3vAqkz5ve27pZn7C8ubJA349gb+w== X-Received: by 2002:a63:a4f:0:b0:41d:e435:c857 with SMTP id z15-20020a630a4f000000b0041de435c857mr2994658pgk.433.1660308436940; Fri, 12 Aug 2022 05:47:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 05:47:16 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 12 Aug 2022 18:16:47 +0530 Message-Id: <20220812124651.27496-8-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 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); + } +};