From patchwork Fri Jul 15 19:13:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16661 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 F0153BE173 for ; Fri, 15 Jul 2022 19:14:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 830CD63325; Fri, 15 Jul 2022 21:14:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657912459; bh=8QNVASaiFR/bPAyGn5OpZsRUR8WjnFbq4S4G/LhKEoU=; 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=Ov6w+cfQzkUkU3EBB29seRVctpLJtuEiNpYxJ8VDIMQ/2AOkkSbVtPXUZDfw0aewR xU3HX9SVKqn+kI3kZ61h+HteJOxitMsxludylu4TzaCmkpL6KxTynh+UdrHGnuGKA1 6c/aat7Kqda4cDTQj5tFlVYeWxoinN+KDQ+f18qqy6iB1O9qALzeA/QbYMjeB4XjwK en4PVtW0AfQiNVFdEGTdJsYta9q2oiFz93M3o/lsMxlbGe1oCUZKqPSWAPfYh/3mbD oAeNDasLpwztKTXvxZOAZZFXnmaqVsi0y73o/1jWMDBDaug3xiutslO1cgMr56Myoo mhhI22DZxGtIg== Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 95A7063312 for ; Fri, 15 Jul 2022 21:14:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B+1sTFTx"; dkim-atps=neutral Received: by mail-pl1-x631.google.com with SMTP id b2so3959994plx.7 for ; Fri, 15 Jul 2022 12:14:17 -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=bI6WmK2jLSNOYBVCWyPjEwrk9dOF4rDXl614lJRsC6g=; b=B+1sTFTxZKoO6OAOHr0+PCyqqRDim8dl6iehqunUv6iyINWxKKA9qnKkQDfbNdFBNH yJ+qOsLTO7FDthoKhlnsErHGTKF8LS/zxXkYNyfzDe+P9X9KgSEs2MLdnRAog7OozGUw varx74lOybBwC7qVvfLcAezOYQ6cxPIBZ8zah2V1+2orHFLqFu72e5lqBLIHNa6qdLPP LZH/W33u6PRjDRGAZ4pSwwm+9QboNK5YEhlTq20nLUHzpWJDUrp0dw94v8jcI5Ua1ipA axUiqrlI9L7WjyiNYuHLsKYEmcdscduC57gVuKMN1pOrIosG1G70zYXHZLm8F+hcDlLT El9A== 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=bI6WmK2jLSNOYBVCWyPjEwrk9dOF4rDXl614lJRsC6g=; b=YKAhvSZwqwO4AMjWy8mOomVgACeA/PISXMD5E7P4SAZG8lITOH1edOVsQT3XUTcFpt 2envR4F2qtDUaxRwQCkT0NXxhc0Gc6WhmlJkVXKHGmult3peSEG8cN/mefARN6kebDy3 8ZSmaxlgAtA4JGhmPcmv4vnhNALlz/huLGqL+emYXPx9I8/UzYEo6DEAPt77bTNwgr9e E5WTBP8YEgaMkG49MUb9ry6JmAiu4pz487z3HopEYSHaPb1bDaVLUxw2AT3eUPgk3OB9 SZuizVToAWBH0D1zdKpSH/VElsuEWTuV8X52DsSCAz5osQVm0A8NiGbXfCBAEz3LJCmH dHqA== X-Gm-Message-State: AJIora+xwM9+HnMdZ/PC3srSkcR8vnE6ll6Ppt1JLMxtl/1vKO8u6MYY mBfHlH+QWdWL/ateA6XuqG4Ah2YegwFJcg== X-Google-Smtp-Source: AGRyM1udEBuwkq1ylpBULagSCPRy4T82gKpFx3jXyzbowMUgUlglO5rUKya9MDa7rn3W50UZeR44lQ== X-Received: by 2002:a17:902:ee42:b0:16b:e518:d894 with SMTP id 2-20020a170902ee4200b0016be518d894mr15017871plo.5.1657912455933; Fri, 15 Jul 2022 12:14:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 12:14:15 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sat, 16 Jul 2022 03:13:55 +0800 Message-Id: <20220715191400.890976-7-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 06/11] qcam: Add Float Slider 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" Qt doesn't support float value sliders. Implement a float slider to help implementing intereactive controls GUI for ControlTypeFloat Signed-off-by: Utkarsh Tiwari --- src/qcam/meson.build | 1 + src/qcam/settings/slider.h | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/qcam/settings/slider.h diff --git a/src/qcam/meson.build b/src/qcam/meson.build index b02b216c..5c4f0552 100644 --- a/src/qcam/meson.build +++ b/src/qcam/meson.build @@ -33,6 +33,7 @@ qcam_moc_headers = files([ 'settings/control_frame.h', 'settings/controls_tab.h', 'settings/settings_dialog.h', + 'settings/slider.h', 'viewfinder_qt.h', ]) diff --git a/src/qcam/settings/slider.h b/src/qcam/settings/slider.h new file mode 100644 index 00000000..f4a4825c --- /dev/null +++ b/src/qcam/settings/slider.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Utkarsh Tiwari + * + * slider.h - qcam - Slider + */ + +#pragma once + +#include +#include + +class FloatSlider : public QSlider +{ + Q_OBJECT + + const float INT_TO_FLOAT = 100.0; + +public: + FloatSlider(QWidget *parent) + : QSlider(parent) + { + connect(this, &QSlider::valueChanged, + this, &FloatSlider::notifyValueChanged); + } + + ~FloatSlider() = default; + + void setValue(float value) + { + QSlider::setValue(value * INT_TO_FLOAT); + } + + void setRange(float min, float max) + { + QSlider::setRange(min * INT_TO_FLOAT, max * INT_TO_FLOAT); + } + + float minimum() + { + return QSlider::minimum() / INT_TO_FLOAT; + } + + float maximum() + { + return QSlider::maximum() / INT_TO_FLOAT; + } + + float value() + { + return QSlider::value() / INT_TO_FLOAT; + } + +Q_SIGNALS: + void valueChanged(float value); + +public Q_SLOTS: + void notifyValueChanged(int value) + { + float floatVal = value / INT_TO_FLOAT; + Q_EMIT valueChanged(floatVal); + } +};