From patchwork Fri Jul 15 19:13:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16656 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 F09DFBE173 for ; Fri, 15 Jul 2022 19:14:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7CDA763316; Fri, 15 Jul 2022 21:14:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657912451; bh=FoKUz+FkkiUIWht5IENjaIF1emvhatvEXA9CQBxsjCM=; 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=yrloO2J2DpJU61T3hF6NGi48wEjj/VUAyxD9DljE8Je0xh5wHT42eiCQ9nKn8UF6r 9zFOBiCfIsjKTqhtyr/hZ69QdTaxbkvJXrimxfyTlXj+At8zbhRU9H8qULXTmS29XN zorOd5OBfCIa2xuihUXaXLpIBjnwcEIaSfWmcuh8DIAa2dj6E9XfcePGcJz0jN09+5 BPZc3cZwbEOSIO4ktapWM8/kaam+miPyEZnGbPsx8RXqEd67WPDNbh+QBPZ7UWbcnR 6Jh8U9tIVQPsIVAddSZTHyh6qZV0w5j/azBMdW5yhL1fmM5mWW9+LWKilpp1n8aiEC JmyMZsl/iF7wg== Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 859F96330E for ; Fri, 15 Jul 2022 21:14:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CAuyIvm2"; dkim-atps=neutral Received: by mail-pg1-x536.google.com with SMTP id e132so5217480pgc.5 for ; Fri, 15 Jul 2022 12:14:09 -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=anyKfc289I3CWaA7uesC5+ilg1UNAagPjTMM2PRc++0=; b=CAuyIvm2H9SA/NNxLDBj2TkddMhHilOJqC4Uhpn9vm0pWZFTZFC7IeuThaw7dDSQTE BGqEvI6sBByj5M9JHPyyRivRLoacibvN8oUjhl88c8BBPXHe/AZ/7y7fjKDvTqBp1tWc 6c0Nrva74lR7Sj9tLHuSBhcstkbXSjveKeQkDxcnpEJLBNC/y4vKqVGn2MF4tl8oddh4 sBGKal5dVagL67kxkivN420r/DtocdisMArBQB6cdDuq886JQ1PW5wJGX8IedkEOA1xR XvUjb1hezQbZrHqzBDa/WYEsqOJ6aWlHa+talrZAFHM8hDDcmse+SuvCXNaodIJOX7pK zImw== 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=anyKfc289I3CWaA7uesC5+ilg1UNAagPjTMM2PRc++0=; b=j2JNpZ9mtjARZFnThoewKJBcu8GYye0amfff7UPJzL7nVw3Ylx5b0Cy8FCLkPLGvth EtlDbgFgaCcU6dkHSFtFtXty1UrLMHc9JzpfMf1CHiZHipU1bX1pRfWq6+Ea71/3hMrt GACxfzXbiFnr0xBilVZbksAy/FoJazZzYVN3LKIEkJFTDTOA9QEFXcM5fSVKhvitMhui uyg1SoTZwnaH72HKqWuOTdjY4jeLpghmO9tfHk7G875jttG8kRKAYw/cxUV7VBk1nsuX zIeZl2+zLlFQ2AIBwbkn/Ez492SBmMTuWbXX4PxjhgDqbBO8A/VhbC9GOP31Vj1lt+5O KUGw== X-Gm-Message-State: AJIora8S1Pu11fgfGl6/ogzE/2+wYrqZXDrwhjPmAsg639PnnxyO5DiB V6HockUZn9w024ra3aH2quY+8dNKGMivhw== X-Google-Smtp-Source: AGRyM1vGgWrtytlofyYBmBopCg/Q4oSWsfRM4PsoMcXXctl//rJ0PiyCPrG+z6ICKY8eJYT54aHQqg== X-Received: by 2002:a63:8341:0:b0:415:c973:18b1 with SMTP id h62-20020a638341000000b00415c97318b1mr13882885pge.292.1657912447875; Fri, 15 Jul 2022 12:14:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 12:14:07 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sat, 16 Jul 2022 03:13:50 +0800 Message-Id: <20220715191400.890976-2-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 01/11] qcam: Add settings Dialog with Control tab 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 a Settings QDialog and add its buttonon the toolbar. We only create one instance of the SettingsWindow and its created the first time user clicks on the button. This Setting Dialog implements a QTabWidget which resides in a QVBoxLayout so that it spans the whole QDialog. The QTabWidget currently only holds the control tab. This Tab lays out the respective ControlFrames in a QGridLayout listing two controls in each row. ControlFrames handles the UI for each respective controls. It also implements the QVBoxLayout as for future when we want to add more information in each frame. Signed-off-by: Utkarsh Tiwari --- src/qcam/assets/feathericons/feathericons.qrc | 1 + src/qcam/main_window.cpp | 15 +++++++ src/qcam/main_window.h | 4 ++ src/qcam/meson.build | 5 +++ src/qcam/settings/control_frame.cpp | 26 +++++++++++++ src/qcam/settings/control_frame.h | 26 +++++++++++++ src/qcam/settings/controls_tab.cpp | 38 ++++++++++++++++++ src/qcam/settings/controls_tab.h | 24 ++++++++++++ src/qcam/settings/settings_dialog.h | 39 +++++++++++++++++++ 9 files changed, 178 insertions(+) create mode 100644 src/qcam/settings/control_frame.cpp create mode 100644 src/qcam/settings/control_frame.h create mode 100644 src/qcam/settings/controls_tab.cpp create mode 100644 src/qcam/settings/controls_tab.h create mode 100644 src/qcam/settings/settings_dialog.h diff --git a/src/qcam/assets/feathericons/feathericons.qrc b/src/qcam/assets/feathericons/feathericons.qrc index 6b08395a..9dc179bb 100644 --- a/src/qcam/assets/feathericons/feathericons.qrc +++ b/src/qcam/assets/feathericons/feathericons.qrc @@ -6,6 +6,7 @@ file.svg play-circle.svg save.svg + settings.svg stop-circle.svg x-circle.svg x-square.svg diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index d4b3d629..f0916b8e 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -255,6 +255,10 @@ int MainWindow::createToolbars() /* Do not operate directly call toggleScriptAction */ scriptExecAction_ = action; + /* Settings Dialog open action */ + action = toolbar_->addAction(QIcon(":settings.svg"), "Open Settings Window"); + connect(action, &QAction::triggered, this, &MainWindow::openSettingsDialog); + return 0; } @@ -341,6 +345,17 @@ void MainWindow::toggleScriptAction(bool showAvailable) } } +void MainWindow::openSettingsDialog() +{ + if (settingsDialog_) { + settingsDialog_->show(); + return; + } + + settingsDialog_ = std::make_unique(camera_, this); + settingsDialog_->show(); +} + /* ----------------------------------------------------------------------------- * Camera Selection */ diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 6f131b17..e35f9029 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -28,6 +28,7 @@ #include "../cam/capture_script.h" #include "../cam/stream_options.h" +#include "settings/settings_dialog.h" #include "viewfinder.h" class QAction; @@ -89,6 +90,7 @@ private: void processViewfinder(libcamera::FrameBuffer *buffer); void chooseScript(); + void openSettingsDialog(); void toggleScriptAction(bool showAvailable); @@ -106,6 +108,8 @@ private: QString title_; QTimer titleTimer_; + std::unique_ptr settingsDialog_; + /* Options */ const OptionsParser::Options &options_; diff --git a/src/qcam/meson.build b/src/qcam/meson.build index 67074252..b02b216c 100644 --- a/src/qcam/meson.build +++ b/src/qcam/meson.build @@ -23,11 +23,16 @@ qcam_sources = files([ 'main.cpp', 'main_window.cpp', 'message_handler.cpp', + 'settings/control_frame.cpp', + 'settings/controls_tab.cpp', 'viewfinder_qt.cpp', ]) qcam_moc_headers = files([ 'main_window.h', + 'settings/control_frame.h', + 'settings/controls_tab.h', + 'settings/settings_dialog.h', 'viewfinder_qt.h', ]) diff --git a/src/qcam/settings/control_frame.cpp b/src/qcam/settings/control_frame.cpp new file mode 100644 index 00000000..6f5cba6d --- /dev/null +++ b/src/qcam/settings/control_frame.cpp @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Utkarsh Tiwari + * + * control_frame.cpp - qcam - Control frame + */ + +#include "control_frame.h" + +#include + +#include +#include +#include +#include + +ControlFrame::ControlFrame(const libcamera::ControlId *control, QWidget *parent) + : QFrame(parent), control_(control) +{ + /* Main layout for the frame */ + QVBoxLayout *frameVLayout = new QVBoxLayout(this); + + frameVLayout->addWidget(new QLabel(QString::fromStdString(control_->name()))); + + setFrameStyle(QFrame::StyledPanel); +} diff --git a/src/qcam/settings/control_frame.h b/src/qcam/settings/control_frame.h new file mode 100644 index 00000000..10690674 --- /dev/null +++ b/src/qcam/settings/control_frame.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Utkarsh Tiwari + * + * control_frame.h - qcam - Control frame + */ + +#pragma once + +#include + +#include +#include + +class ControlFrame : public QFrame +{ + Q_OBJECT + +public: + ControlFrame(const libcamera::ControlId *control, + QWidget *parent); + ~ControlFrame() = default; + +private: + const libcamera::ControlId *control_; +}; diff --git a/src/qcam/settings/controls_tab.cpp b/src/qcam/settings/controls_tab.cpp new file mode 100644 index 00000000..33ed9332 --- /dev/null +++ b/src/qcam/settings/controls_tab.cpp @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Utkarsh Tiwari + * + * controls_tab.cpp - qcam - Controls Tab + */ + +#include "controls_tab.h" + +#include + +#include + +#include +#include +#include + +#include "control_frame.h" + +ControlsTab::ControlsTab(std::shared_ptr camera_, + QWidget *parent) + : QWidget(parent) +{ + /* Main Layout for the tab */ + QGridLayout *controlGLayout = new QGridLayout(this); + + int controlCount = 0; + for (auto &[control, info] : camera_->controls()) { + ControlFrame *controlFrame = new ControlFrame(control, this); + + controlGLayout->addWidget(controlFrame, controlCount / 2, + controlCount % 2); + controlCount++; + } + + if (controlCount == 0) + controlGLayout->addWidget(new QLabel("No controls available")); +} diff --git a/src/qcam/settings/controls_tab.h b/src/qcam/settings/controls_tab.h new file mode 100644 index 00000000..6a63f334 --- /dev/null +++ b/src/qcam/settings/controls_tab.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Utkarsh Tiwari + * + * controls_tab.h - qcam - Controls Tab + */ + +#pragma once + +#include + +#include + +#include +#include + +class ControlsTab : public QWidget +{ + Q_OBJECT + +public: + ControlsTab(std::shared_ptr camera_, QWidget *parent); + ~ControlsTab() = default; +}; diff --git a/src/qcam/settings/settings_dialog.h b/src/qcam/settings/settings_dialog.h new file mode 100644 index 00000000..c2fa61ea --- /dev/null +++ b/src/qcam/settings/settings_dialog.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Utkarsh Tiwari + * + * settings_dialog.h - qcam - Settings Dialog + */ + +#pragma once + +#include + +#include +#include +#include +#include + +#include "controls_tab.h" +class SettingsDialog : public QDialog +{ + Q_OBJECT + +public: + SettingsDialog(std::shared_ptr camera, QWidget *parent) + : QDialog(parent) + { + /*Main layout for dialog */ + QVBoxLayout *settingVLayout = new QVBoxLayout(this); + + /* Main TabWidget which would hold other tabs */ + QTabWidget *settingTabWidget = new QTabWidget; + settingVLayout->addWidget(settingTabWidget); + + ControlsTab *controlsTab = new ControlsTab(camera, this); + settingTabWidget->addTab(controlsTab, "Controls"); + + setWindowTitle("Settings"); + } + ~SettingsDialog() = default; +};