From patchwork Fri Aug 12 12:46:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17097 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 01179BE173 for ; Fri, 12 Aug 2022 12:47:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AC1726332E; Fri, 12 Aug 2022 14:47:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660308427; bh=Sh+PbJ25NGs5XtqHcyTP5/e6EJXtbdiJeMXGsUegKo8=; 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=LyUTI1481ONyMmu4NmhEEBHGg9IaMQq2v6FZTpnxc1+TFY/lr8lCf+MtZA9m9CAfT AhmFX5nntFy2PvjPBCeOB3LHQAZ4Xl4Td7Cqk8UwbCvwd4hYx3d+m1EgAg9vXW7iqy QY/mBshDGzV7fRLW89ZrGYF3wn2Ml2QZDutUGVYFErxEUfzJ9A6I3tc+veGsR87Rmz bad2UZguO3lfB4bBinsNJKCF199gx2XMdj4P5XKT64VZgKD61HvTdUUcneUs+ynPK1 ytJbJbf9b9F2vob7h9C8VcdGpHYvJV4vwc8B2qoxA8Kb8h/BUgsKrdg5tUv1x6WfP+ NnvQPJ5a9hW1w== Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3DDF461FAB for ; Fri, 12 Aug 2022 14:47:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bm7+LoY9"; dkim-atps=neutral Received: by mail-pf1-x435.google.com with SMTP id p125so875940pfp.2 for ; Fri, 12 Aug 2022 05:47:06 -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=eeJ4uOdVqbzxkSFHFCXGMxTFRLSE3n1n+dHzSj9VE/E=; b=Bm7+LoY9c1lUNU/1vkojGV0aUrgRnwJnriny5NEuE4mgaXuTrW2S+5wNv5+v4kOOK9 jPcP8HMHFTXMZT73ZpugyeguQReZm7bcEpnabT7HqwVemrg+bvxJkADR8Pdlxjvn7FaW 6wbgN+PDJzwFKa0H/shUTck8FbuBmrcIUYVvpZGP4EplIEJd2W4I37iDMwhT5PAVVBtg ddjo/w4kiErzJxpsahLxDqn9QUud2mVvIrKb7yLp1B7ekQA28aKdaV6iZOVFGJDi468d jhJe9lfnEpkzOujyqAhLuopG8LIe/1MnegKbsCFpX80xv0GS5a384QFQCEgXFt9Z6Aus s08A== 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=eeJ4uOdVqbzxkSFHFCXGMxTFRLSE3n1n+dHzSj9VE/E=; b=UqHKj1r+K6IAFz2X3sDhLhs0+ub74U45gqoU0Rb9DVPn2H5aF0Sh8TqfUrhVC+xWuM 0EP7J3S8CjivsaX8LLranTtzHEME5cKyiyvriStaJLnHoyxa5LcTPmkq/Gzs1os92RTz MQ1SXvdPfNnWymPZNezBiTBfrycpHRENGshwfluwcwuDwv1NvAMEpU8k74APwcVQL4q+ tioReBl1mS2JdwdnOdr2bR3+R7dHWA9tEaB7f5X3fqnANEOmZBKW2BgFipI5a1HG0CwW wPds3Z6XrcAQgze5ifHi66BoeprzYre4KgXO4MQUXloYB/BcPOItt3u9iUAC3Nud1UZ9 avbQ== X-Gm-Message-State: ACgBeo0ab2ZXdT63lYK6qU7ghhNkBLiKkQOveGz2PmL+3L8XhUCcMny2 2B5OSmP2q1jt7HHdNhmzn9iAX3Iqjuo= X-Google-Smtp-Source: AA6agR58QvAdVytHfSsb79qeBK8yWxTdX04YMSM0V0xj/oEVSJPxBIxVHhVNM1j/ituuZkAlV1k17g== X-Received: by 2002:a63:4d1a:0:b0:41b:d319:d8ad with SMTP id a26-20020a634d1a000000b0041bd319d8admr2959828pgb.613.1660308424431; Fri, 12 Aug 2022 05:47:04 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 05:47:04 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 12 Aug 2022 18:16:41 +0530 Message-Id: <20220812124651.27496-2-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 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. We check its existence with QPointer. 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 --- Difference from v1: 1. Settings dialog now primarily uses QIcon::fromTheme("preferences-system") 2. using namespace libcamera; added in ControlFrame src/qcam/assets/feathericons/feathericons.qrc | 1 + src/qcam/main_window.cpp | 17 ++++++++ src/qcam/main_window.h | 5 +++ src/qcam/meson.build | 5 +++ src/qcam/settings/control_frame.cpp | 28 +++++++++++++ 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, 183 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 c5302040..3078c26f 100644 --- a/src/qcam/assets/feathericons/feathericons.qrc +++ b/src/qcam/assets/feathericons/feathericons.qrc @@ -5,6 +5,7 @@ camera-off.svg play-circle.svg save.svg + settings.svg stop-circle.svg x-circle.svg diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index ce70cc02..7861c34b 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -239,6 +239,12 @@ int MainWindow::createToolbars() saveRaw_ = action; #endif + /* Settings Dialog open action */ + action = toolbar_->addAction(QIcon::fromTheme("preferences-system", + QIcon(":settings.svg")), + "Open Settings Window"); + connect(action, &QAction::triggered, this, &MainWindow::openSettingsDialog); + return 0; } @@ -262,6 +268,17 @@ void MainWindow::updateTitle() setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps"); } +void MainWindow::openSettingsDialog() +{ + if (settingsDialog_) { + settingsDialog_->show(); + return; + } + + settingsDialog_ = new SettingsDialog(camera_, this); + settingsDialog_->show(); +} + /* ----------------------------------------------------------------------------- * Camera Selection */ diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index c7cba5e9..856a71b1 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -23,12 +23,14 @@ #include #include #include +#include #include #include #include #include "../cam/capture_script.h" #include "../cam/stream_options.h" +#include "settings/settings_dialog.h" #include "cam_select_dialog.h" #include "viewfinder.h" @@ -94,6 +96,8 @@ private: void loadCaptureScript(); void stopCaptureScript(); + void openSettingsDialog(); + /* UI elements */ QToolBar *toolbar_; QAction *startStopAction_; @@ -108,6 +112,7 @@ private: QTimer titleTimer_; CameraSelectorDialog *cameraSelectorDialog_; + QPointer settingsDialog_; /* Options */ const OptionsParser::Options &options_; diff --git a/src/qcam/meson.build b/src/qcam/meson.build index 70a18d7e..7a785fd0 100644 --- a/src/qcam/meson.build +++ b/src/qcam/meson.build @@ -24,12 +24,17 @@ 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([ 'cam_select_dialog.h', '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..8b1162db --- /dev/null +++ b/src/qcam/settings/control_frame.cpp @@ -0,0 +1,28 @@ +/* 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 + +using namespace libcamera; + +ControlFrame::ControlFrame(const 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; +};