From patchwork Fri Aug 12 12:46:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17102 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 8811FBE173 for ; Fri, 12 Aug 2022 12:47:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4F3DD63331; Fri, 12 Aug 2022 14:47:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660308438; bh=Dg1bN0aVojFT65CgMPCx4UraJV3WkHZfYJ2upR8GNsQ=; 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=tECgrrqG0hI7r0uCpxHCYqm+qO0cwmah8jUi2sJeikcmZMl+Z5BRlpFW3s8Ek8nlj 1f3ZnZplQG6QzE2M/dlvGg+oxQT7znqMVH8wUEVTEd954zFnar8/IClF5ONLVswIZe ky0gVl6U63Jza2ypC83FOKafYNHAj9MLMfgtwvxfZgeOQ1PzdPcqt8N8Nmi8i39bEE VYqAsblm9csSOVMCWfXuGLAtEThkZO/tTChQ93v/AAkefa9VhVTVqSxJkauWnBuuBZ 0FT5nUwQ9zxvZSxGjzLvxigoSIu/NS5kGpmA7+lUFpk50H4IPH2SmyWAfPUTdgmxMc V4rlnzu4+3cLw== Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE7A9603EA for ; Fri, 12 Aug 2022 14:47:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="R7/TEk7r"; dkim-atps=neutral Received: by mail-pg1-x52c.google.com with SMTP id r69so720830pgr.2 for ; Fri, 12 Aug 2022 05:47:16 -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=ZLojxJ7wxvVcqWW9k6jj8xlp7O+dZGH6BiHKkMD5lIQ=; b=R7/TEk7r9elpG0fQzKisv9KMAdC2pHefBM1QLbCXXABo+EjAHEcVR1Riem0N1Nvekr QR5hHcD9IkBPeNDo33c/MnSdH2mxwu6NFNn0dgYKYDzvMiGb8sWIA5059y8pIr5plMN8 65esmEPs/Q5BiwNPIB4fnpR/nKK9gQadmsCNJYHv0hBe/4vqLAoRNcxBqsfPT53o6tAj /RANi7QtO1i1iDgXhuVLAMai23mS2rpBO4vTn7edhoCiiTYkrnnQuneXMW+RrXmY724A C7foperKjUEZcVdnU26VVKqTqpRjngZBJLUNQtXJ7VetjrJmN5N/kSkDWriyxVAu1vyd RZyQ== 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=ZLojxJ7wxvVcqWW9k6jj8xlp7O+dZGH6BiHKkMD5lIQ=; b=QHEGT2+0tkjNkPz4imfQd5RrywxzVlIt4lFXBN4Td2eBaJ/INYJwLPvHq1fTRkf18J fbP1Kd4A79lZu1s8o6ZVAzCLfWM1ALuR5Kd09hrgHFKBzkKpRAI4tba1c2/Fk82/RJhg Qly0PHDxTCJ5LyrXneQNx4AJyLUZPl1X5rRsH3s6+qLW1QHDDjoUm4XB/RS4d2ekwnUK Bu+6bipGp7+GMBYcRZYSJ7o6Rja6xNqtM8NdoV5jGcpCu0fkQttj4qVrAX4RdQQMZL2/ zrK8Fmu0HVQXo4NgYIHfPPS7qPNju+jw0sbFEh8/cLYVLTzJQ/J3D8jUvb3YRFLeLBbJ pQXQ== X-Gm-Message-State: ACgBeo0aS/pI/ze4H4QvJaUPqfzX80CGnj0KGwVE+dX2OL65+PWserG0 iN+cYw5HkiRetlpdU0EbfdcRnZb+zRY= X-Google-Smtp-Source: AA6agR4/gsZjcxiJi6Y25n8d7wTjm/0hjPLIw237g3ApsZhm1zGX6bHB2J/fU0Jdr0rlT0iJzd8U6A== X-Received: by 2002:a65:6384:0:b0:41c:5f9b:881c with SMTP id h4-20020a656384000000b0041c5f9b881cmr2958208pgv.513.1660308434966; Fri, 12 Aug 2022 05:47:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 05:47:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 12 Aug 2022 18:16:46 +0530 Message-Id: <20220812124651.27496-7-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 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 7a785fd0..b6a09c87 100644 --- a/src/qcam/meson.build +++ b/src/qcam/meson.build @@ -35,6 +35,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); + } +};