From patchwork Sat Aug 6 19:04:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16994 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 919E9C3275 for ; Sat, 6 Aug 2022 19:04:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4BE5763313; Sat, 6 Aug 2022 21:04:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659812694; bh=7d4DgRBK36XXC05mClFv2k3rijGpz/Zg/AJ+NsNoglI=; 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=oo7V1vXaXSOygJ6lWfPmqBGIf7S2YN/hkxkvdWqFNFkdn5vtqTWVFnZ0n63esffVM Z8KoUxiccg6QPU93QcRUw4UC1qzFBKVd7qWV3mYXORjE3PJv46d+IG/oHy5ovyvM0g VVjY/F6PCStOgM1PlvMRhD1N4Vz4GuSY8v6cxuBdXIDpgyzRTXePxBPd+q8llumkug P3xlku6wwVX6tetsuW/DpB04lpWVZvL2WzP6UQYgFHlKKGEjVTA1EOWvcCVAXZDBLl lCmG+qFzH3c85LJbo7QGWWyBtj3AlA2ZDqDMVeyA/mRKg2P6RA1rJjjWI9eJuOoy50 ikNyZ9JL47ODQ== 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 2AE516332B for ; Sat, 6 Aug 2022 21:04:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q2RmZ1MG"; dkim-atps=neutral Received: by mail-pl1-x631.google.com with SMTP id t2so5331249ply.2 for ; Sat, 06 Aug 2022 12:04:52 -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=dpfpf09IEIUwxuA/C+IBy9n5tZOTeXXc4N1nwXYN5jg=; b=Q2RmZ1MG3gBHxsvA/RbsAQfDfHq5ij7vdID9W42Rp3T0i/qWOXQclFxDRJG9v00Ozz YlcmgEIclR+fvE8WTrSdw5uZORKD7Qf8S8135rv9/bGemggVYihhyE0hBnFbJdD8Fcsn /Y7j9f/Obg+FsemIRugIpTqFKjHuhu3Bcip9b1cQV/gx16LrN7bih0t+laWm9J/VI9Bm jmbsHrhyYuuDfhMTAlm6E7bRe8Q05IIjjvQOUmsyX/xYE94xAerRlf7CXZtn81ZN3TMu r3rpkccO8P2r92myHuuLmzk6e4NJ9pLKNV7LzqMAvWk9wtA3eau+7279+T/UW0JX+2GA T0NA== 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=dpfpf09IEIUwxuA/C+IBy9n5tZOTeXXc4N1nwXYN5jg=; b=7Z2nFoU4L87nA+Vgdur3vlBirMESH9OQMdoTtU5/fBaf6Rvg/hwYSGXFLgqESXzdNm 2GAlL0LBhR4cP7PQSaiJ2CXmRxum19OQSSgYLhBjJWiC9AXEFFDAgJVCZe36enyGY7eS bztqAG/ROfhqhhc4b+PlvlsQWw3L3eHkG4yq44jITf592046bOb/S0Y6KfXp+udByqoc gnGK60KL66Kxyjok08NoB7ecFTiL7exsxQLgNDe6OahCz+xdMWEkT0fJQ8h/tdS74Yh6 9tBxpPYWhTpcKxmjPBaOq2RmxwUh5aJjVJCS1zZsQuGEpgY7V4PYjhbiZwRwrqHhuwmP bpyg== X-Gm-Message-State: ACgBeo1Dy2daVEVvldy63r439fF0PmjY8JV6jcv+3Ete7i8BiG3Qx1YG nyGp+QR28YA3+KQMV61UO0vhcb/Y+dY= X-Google-Smtp-Source: AA6agR4gs+zwEsdxxWaNrp2ihus4LHrf1UYX/2/VzAgqNSUR+TtA0n6Hv9cFNvfFqJkkfYUnFvBkgw== X-Received: by 2002:a17:90a:fc2:b0:1f3:20d0:2e47 with SMTP id 60-20020a17090a0fc200b001f320d02e47mr13368102pjz.117.1659812690296; Sat, 06 Aug 2022 12:04:50 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:daa9:adf3:a099:1bff:e55]) by smtp.gmail.com with ESMTPSA id z17-20020aa79911000000b0052f20d70845sm406025pff.150.2022.08.06.12.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Aug 2022 12:04:49 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 00:34:30 +0530 Message-Id: <20220806190433.59128-2-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220806190433.59128-1-utkarsh02t@gmail.com> References: <20220806190433.59128-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/4] qcam: Use QDialog for selection of cameras at startup 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" Currently we use QInputDialog convenience dialogs to allow the user to select a camera. This doesn't allow adding of more information (such as camera location, model etc). Create a QDialog with a QFormLayout that shows a QComboBox with camera Ids. Use a QDialogButtonBox to provide buttons for accepting and cancelling the action. Signed-off-by: Utkarsh Tiwari --- Difference from V1: The biggest change here is the introduction of class, inside of the class the layout remains same. src/qcam/cam_select_dialog.h | 64 ++++++++++++++++++++++++++++++++++++ src/qcam/main_window.cpp | 22 +++---------- src/qcam/main_window.h | 4 +++ src/qcam/meson.build | 1 + 4 files changed, 74 insertions(+), 17 deletions(-) create mode 100644 src/qcam/cam_select_dialog.h diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h new file mode 100644 index 00000000..c23bad59 --- /dev/null +++ b/src/qcam/cam_select_dialog.h @@ -0,0 +1,64 @@ + +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * cam_select_dialog.h - qcam - Camera Selection dialog + */ + +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include +#include + +class CamSelectDialog : public QDialog +{ + Q_OBJECT +public: + CamSelectDialog(libcamera::CameraManager *cameraManager, QWidget *parent) + : QDialog(parent), cm_(cameraManager) + { + /* Use a QFormLayout for the dialog. */ + QFormLayout *camSelectDialogLayout = new QFormLayout(this); + + /* Setup the camera id combo-box. */ + cameraIdComboBox_ = new QComboBox; + for (const auto &cam : cm_->cameras()) + cameraIdComboBox_->addItem(QString::fromStdString(cam->id())); + + /* Setup the QDialogButton Box */ + QDialogButtonBox *dialogButtonBox = + new QDialogButtonBox(QDialogButtonBox::Ok | + QDialogButtonBox::Cancel); + + connect(dialogButtonBox, &QDialogButtonBox::accepted, + this, &QDialog::accept); + connect(dialogButtonBox, &QDialogButtonBox::rejected, + this, &QDialog::reject); + + /* Set the layout. */ + camSelectDialogLayout->addRow("Camera: ", cameraIdComboBox_); + camSelectDialogLayout->addWidget(dialogButtonBox); + } + + ~CamSelectDialog() = default; + + std::string getCameraId() + { + return cameraIdComboBox_->currentText().toStdString(); + } + +private: + libcamera::CameraManager *cm_; + + /* UI elements. */ + QComboBox *cameraIdComboBox_; +}; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 7433d647..758e2c94 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #include "../cam/image.h" +#include "cam_select_dialog.h" #include "dng_writer.h" #ifndef QT_NO_OPENGL #include "viewfinder_gl.h" @@ -290,24 +290,12 @@ void MainWindow::switchCamera(int index) std::string MainWindow::chooseCamera() { - QStringList cameras; - bool result; + camSelectDialog_ = new CamSelectDialog(cm_, this); - /* If only one camera is available, use it automatically. */ - if (cm_->cameras().size() == 1) - return cm_->cameras()[0]->id(); - - /* Present a dialog box to pick a camera. */ - for (const std::shared_ptr &cam : cm_->cameras()) - cameras.append(QString::fromStdString(cam->id())); - - QString id = QInputDialog::getItem(this, "Select Camera", - "Camera:", cameras, 0, - false, &result); - if (!result) + if (camSelectDialog_->exec() == QDialog::Accepted) + return camSelectDialog_->getCameraId(); + else return std::string(); - - return id.toStdString(); } int MainWindow::openCamera() diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index fc70920f..6d80b5be 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -23,11 +23,13 @@ #include #include #include +#include #include #include #include "../cam/stream_options.h" +#include "cam_select_dialog.h" #include "viewfinder.h" class QAction; @@ -99,6 +101,8 @@ private: QString title_; QTimer titleTimer_; + QPointer camSelectDialog_; + /* Options */ const OptionsParser::Options &options_; diff --git a/src/qcam/meson.build b/src/qcam/meson.build index c46f4631..70615e92 100644 --- a/src/qcam/meson.build +++ b/src/qcam/meson.build @@ -26,6 +26,7 @@ qcam_sources = files([ ]) qcam_moc_headers = files([ + 'cam_select_dialog.h', 'main_window.h', 'viewfinder_qt.h', ]) From patchwork Sat Aug 6 19:04:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16995 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 157DBBE173 for ; Sat, 6 Aug 2022 19:04:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BFA166332B; Sat, 6 Aug 2022 21:04:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659812696; bh=5iS60UGDecVEyrrgT3lKElBN6R9iQM81Khz3N/3B3JI=; 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=jRePL41aKyB3J2esUHzBgrqkYx3skdDjSuwwzL7NAs4Vd8JkbpQMWf9IfiWiThOCO gDulYZRqvA7ENot8VLlLc1AMzX/lDskF6aoWI5PUfnWN17NAKMT0VwVfKSZeOXAbGO brjwBOI5E+jXXnLEOo7FrxB5NhO0vMZVMmD0mK7nXpLjcqMgE51nXdZ4wDLugBmPJn jrJHVcQtiOjFWBRVDmPGsKVL2LSfT7rOfyOA6r5lboE2il68DZ7oLyp5ewNFs8d5Hm K+ByS06Y/SDrXre37tDcTgU1zB9Gq+3x32/DWaiJWsrJIPD3yMGPWp9MNjsmH2kzRQ jOF4cqdlu67xw== Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C5FDC61FAC for ; Sat, 6 Aug 2022 21:04:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="F4lDk+3v"; dkim-atps=neutral Received: by mail-pj1-x1036.google.com with SMTP id 15-20020a17090a098f00b001f305b453feso11082375pjo.1 for ; Sat, 06 Aug 2022 12:04:54 -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=/g1b3Wfsbg0FDtmfKPifPvuYv+phjnLqZvK2o34f6LA=; b=F4lDk+3vS9o+WD0z4H5OnPwMx1o1+45KzjlZp6U/frzKC9eBilsRMRpATH57YxZJjl Jp3PIhwLJg4LWtb+Sn0TTqlFWXWOPcngwghUnDi516IMs2y8bI80trOXJNNRh1BG3OFR X9NZzuru2T/H6FOOcmmjuX0OciJ8/wYpzyIgZA8rMZBmdnEEJaBgnWTNFuZWbug9cDEu 3hUFmPwaqlb33s8klAc/13mm1ZGyS0cafqX/jHg/z1ALLHrnOpTf4v5C/zqjq4nmCknK K6MgcZzjnvLpVFTiuRjcidn3bd+YbikU+9x3zvJmOP42klLuXYQS84xkzBzTzkiYepUL KcKg== 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=/g1b3Wfsbg0FDtmfKPifPvuYv+phjnLqZvK2o34f6LA=; b=FPE1AlAQ7G+aPT8yAWvipada0fhuhP5KuM7anyWzH72R+IyOU1XYo51r4QMZm1/EPI 5/kE93z3g+nHwa/oo3Oe57HT7LgVGirtZspJrIBRDzRX8qTnB4XCRSUi9mYIGOSM+Nec 06r3uRBjTpN5/DAOY7ZEk66VQ1vdcmMT8E3yJpUmxJeZn14JOuX4p60vqp9YQea1Lk44 zIHWugQFe+/O2OQADjOiyF1SMdRRtdaPimy2/+PPQPuuXGj5KWgnOe8tuxTKBn6h+pmH /HzP8fleqpou/hfkCj/4ZrVN3KZM2Mtqe+j5Z4aZZo8urDAwa6kAU/ofUlW7nwAEunv+ QIiA== X-Gm-Message-State: ACgBeo1i5wkrw+MaFb8VcAc7QjTLVqULFs6PCIXI0rPIB32oYeTqex4b J9AVrNakuWNEmGMYQudoTgQQ2qvhD6M= X-Google-Smtp-Source: AA6agR44/EhYbKguoMY90cGXe96vJU2nhhlOqM3VzciWJQ2uhiXMW3Ilf3NxXuJW1z0R/dIejrB0BA== X-Received: by 2002:a17:90b:1b07:b0:1f5:115c:79a4 with SMTP id nu7-20020a17090b1b0700b001f5115c79a4mr13504441pjb.166.1659812692848; Sat, 06 Aug 2022 12:04:52 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:daa9:adf3:a099:1bff:e55]) by smtp.gmail.com with ESMTPSA id z17-20020aa79911000000b0052f20d70845sm406025pff.150.2022.08.06.12.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Aug 2022 12:04:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 00:34:31 +0530 Message-Id: <20220806190433.59128-3-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220806190433.59128-1-utkarsh02t@gmail.com> References: <20220806190433.59128-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] qcam: Support Hotplug for Camera Selection Dialog 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" Currently if there is HotPlug event when the user is on the Camera selection dialog, the QComboBox didn't update to reflect the change. If the QDialog exists then alert it for the Hotplug event. The check for QDialog existance is done by QPointer. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- src/qcam/cam_select_dialog.h | 14 ++++++++++++++ src/qcam/main_window.cpp | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index c23bad59..ee65eb88 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -56,6 +56,20 @@ public: return cameraIdComboBox_->currentText().toStdString(); } + /* Hotplug / Unplug Support. */ + void cameraAdded(libcamera::Camera *camera) + { + cameraIdComboBox_->addItem(QString::fromStdString(camera->id())); + } + + void cameraRemoved(libcamera::Camera *camera) + { + int cameraIndex = cameraIdComboBox_->findText( + QString::fromStdString(camera->id())); + + cameraIdComboBox_->removeItem(cameraIndex); + } + private: libcamera::CameraManager *cm_; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 758e2c94..dd30817d 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -594,6 +594,9 @@ void MainWindow::processHotplug(HotplugEvent *e) if (event == HotplugEvent::HotPlug) { cameraCombo_->addItem(QString::fromStdString(camera->id())); + + if (camSelectDialog_) + camSelectDialog_->cameraAdded(camera); } else if (event == HotplugEvent::HotUnplug) { /* Check if the currently-streaming camera is removed. */ if (camera == camera_.get()) { @@ -605,6 +608,9 @@ void MainWindow::processHotplug(HotplugEvent *e) int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id())); cameraCombo_->removeItem(camIndex); + + if (camSelectDialog_) + camSelectDialog_->cameraRemoved(camera); } } From patchwork Sat Aug 6 19:04:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16996 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 7E58DC3275 for ; Sat, 6 Aug 2022 19:04:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3722B63334; Sat, 6 Aug 2022 21:04:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659812698; bh=1b7MXtW5af+YTtPbczKoGvLv5lK9dyRdeyIxNcHbMF8=; 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=kPho5X8sdDSqPKLzI/4DuQm/2WSYfCQLEfezJHmOcAi2Bhw1us2YYWHq3PVHXCAQK ZpMADuowG1UJTOEij6JZ1b0NiW1GZktAGSRIbyPLaddenqyagxdiY/M6/H4R1qN27V 8Go5BhKUcvfVwliXRNpVpXSOyy7XAlP83Z8D0kUnX+QU2PzAFIJDVg/m3BXinPd3dR 3Qde28aKziXKuhe8z2uf/AmIgPKZ16jks7PkZ3FmOlfF4zmLpApyXC0kYoGCHmpDXm ezNLwdpVXIOa3WTjaoY8R76P5RajyXZ9PoRDPbguVUA7SuY/skR//HyjCmbYkj3sN5 v2B70ZqZsNfYw== Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 019EC63332 for ; Sat, 6 Aug 2022 21:04:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eRfHG5D9"; dkim-atps=neutral Received: by mail-pf1-x433.google.com with SMTP id g12so4939202pfb.3 for ; Sat, 06 Aug 2022 12:04:56 -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=IorJXIXuqkipodRbivrzwNMOGa86T9Mi2AbdLW61dK4=; b=eRfHG5D99ikmBAeneHBsF8AMeC/BzF9btSdZZMwEPpyH2YoJUVGosp7iXfadk3MXfE XDZAH2MnEN0rwEZQulzYuNPDnFp0wLqnc2OIXIfAyv9iTSeCY5eJuffI97dE0b3d7KBh 827T8A0I21GdEDY4S7nZU4WJobLUzuglBsYfuFHWPXknODaR+5TRxGjpaePHcbtuA6Xs uvVm0umUxLGTl9IINSbhDFRVpiDAfRiw5Y3XccD2jZ/KrrWU8ByT7JDfg64IDbnfQkSl 4paK0paRdFv/EruB5y89TgLpb29JhAYwL9HNNcy/GIiLUf5FPEWqa1ba78G3vjCX07X+ 9nGQ== 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=IorJXIXuqkipodRbivrzwNMOGa86T9Mi2AbdLW61dK4=; b=XJH5NaZPV9cse85QHOAGif8heaURuh/GfCzuiIfN18NzFiEafA8kVyGYPfgqutNGHm AmTi37mu0tJ+tn3UX8hmUXBqfxjEYEcte4c0ldLU0FyBbUQv6y1SOJoe6ysGr7Vje3Nw Xti86z0ekT7fq9OJAbbRMznXdzInDD3k2sF5bJPak0lG+ImTkLcQ+6P2gSJqQtbiJEYK rOMu9M+NfeN1igDHt2honfTKVFRIUZrnxvlTO2ZYmYZBvUR7UdWsc7y4j6UH3FNIRT0v vNMbrlZPQZ/Sz4sFf4hIchS/ksakxOycxmQCm8jnBU5TPN9reX+bJwL4Nekisy/fnzEg aDqg== X-Gm-Message-State: ACgBeo0Gfn3tFmFun7G2VDYiyTfOGCohGmkUb/PN/U5QWegPa6H3rMOC fFyplPL9tjUYbFWVxCt4GtQdRQjTDh4= X-Google-Smtp-Source: AA6agR5unG3EzC8Za68zqSMs1ZotbqwApRBG+VqiMNf6+IbjMLP57q/oI0oYv+K/+jvUpHcXkL930A== X-Received: by 2002:aa7:87d8:0:b0:52e:ba7a:7fc0 with SMTP id i24-20020aa787d8000000b0052eba7a7fc0mr8489716pfo.46.1659812695371; Sat, 06 Aug 2022 12:04:55 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:daa9:adf3:a099:1bff:e55]) by smtp.gmail.com with ESMTPSA id z17-20020aa79911000000b0052f20d70845sm406025pff.150.2022.08.06.12.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Aug 2022 12:04:55 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 00:34:32 +0530 Message-Id: <20220806190433.59128-4-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220806190433.59128-1-utkarsh02t@gmail.com> References: <20220806190433.59128-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/4] qcam: MainWindow: Replace cameraCombo_ with camSelectDialog 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" Replace the cameraCombo_ on the toolbar with a QPushButton which displays the camSelectDialog. This would allow the user to view information about the camera when switching. The QPushButton text is set to the camera Id currently in use. Signed-off-by: Utkarsh Tiwari --- src/qcam/cam_select_dialog.h | 5 +++++ src/qcam/main_window.cpp | 41 ++++++++++++++++++------------------ src/qcam/main_window.h | 5 +++-- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index ee65eb88..a5189ec3 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -56,6 +56,11 @@ public: return cameraIdComboBox_->currentText().toStdString(); } + std::string getCurrentCamera() + { + return cameraIdComboBox_->currentText().toStdString(); + } + /* Hotplug / Unplug Support. */ void cameraAdded(libcamera::Camera *camera) { diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index dd30817d..98c22b71 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -193,14 +193,11 @@ int MainWindow::createToolbars() connect(action, &QAction::triggered, this, &MainWindow::quit); /* Camera selector. */ - cameraCombo_ = new QComboBox(); - connect(cameraCombo_, QOverload::of(&QComboBox::activated), + cameraSwitchButton_ = new QPushButton; + connect(cameraSwitchButton_, &QPushButton::clicked, this, &MainWindow::switchCamera); - for (const std::shared_ptr &cam : cm_->cameras()) - cameraCombo_->addItem(QString::fromStdString(cam->id())); - - toolbar_->addWidget(cameraCombo_); + toolbar_->addWidget(cameraSwitchButton_); toolbar_->addSeparator(); @@ -260,14 +257,19 @@ void MainWindow::updateTitle() * Camera Selection */ -void MainWindow::switchCamera(int index) +void MainWindow::switchCamera() { /* Get and acquire the new camera. */ - const auto &cameras = cm_->cameras(); - if (static_cast(index) >= cameras.size()) + std::string newCameraId = chooseCamera(); + + if (newCameraId.empty()) return; - const std::shared_ptr &cam = cameras[index]; + if (camera_) { + if (newCameraId == camera_->id()) + return; + } + const std::shared_ptr &cam = cm_->get(newCameraId); if (cam->acquire()) { qInfo() << "Failed to acquire camera" << cam->id().c_str(); @@ -292,9 +294,12 @@ std::string MainWindow::chooseCamera() { camSelectDialog_ = new CamSelectDialog(cm_, this); - if (camSelectDialog_->exec() == QDialog::Accepted) - return camSelectDialog_->getCameraId(); - else + if (camSelectDialog_->exec() == QDialog::Accepted) { + std::string cameraId = camSelectDialog_->getCameraId(); + cameraSwitchButton_->setText(QString::fromStdString(cameraId)); + + return cameraId; + } else return std::string(); } @@ -327,8 +332,8 @@ int MainWindow::openCamera() return -EBUSY; } - /* Set the combo-box entry with the currently selected Camera. */ - cameraCombo_->setCurrentText(QString::fromStdString(cameraName)); + /* Set the camera switch button with the currently selected Camera id. */ + cameraSwitchButton_->setText(QString::fromStdString(cameraName)); return 0; } @@ -593,8 +598,6 @@ void MainWindow::processHotplug(HotplugEvent *e) HotplugEvent::PlugEvent event = e->hotplugEvent(); if (event == HotplugEvent::HotPlug) { - cameraCombo_->addItem(QString::fromStdString(camera->id())); - if (camSelectDialog_) camSelectDialog_->cameraAdded(camera); } else if (event == HotplugEvent::HotUnplug) { @@ -603,12 +606,8 @@ void MainWindow::processHotplug(HotplugEvent *e) toggleCapture(false); camera_->release(); camera_.reset(); - cameraCombo_->setCurrentIndex(0); } - int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id())); - cameraCombo_->removeItem(camIndex); - if (camSelectDialog_) camSelectDialog_->cameraRemoved(camera); } diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 6d80b5be..fe0f5938 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -61,7 +62,7 @@ private Q_SLOTS: void quit(); void updateTitle(); - void switchCamera(int index); + void switchCamera(); void toggleCapture(bool start); void saveImageAs(); @@ -91,7 +92,7 @@ private: /* UI elements */ QToolBar *toolbar_; QAction *startStopAction_; - QComboBox *cameraCombo_; + QPushButton *cameraSwitchButton_; QAction *saveRaw_; ViewFinder *viewfinder_; From patchwork Sat Aug 6 19:04:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16997 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 2B781BE173 for ; Sat, 6 Aug 2022 19:05:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CB6B363337; Sat, 6 Aug 2022 21:05:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659812701; bh=MyUpLSLEtM5kTr87vZBJ+qzN24xO8h0IJIlJOXFOTdE=; 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=yIucVNlDwzGR4k5/k8ta9i0TiQ1XZxDEOEoHpw/duMk7iE8RHno7zWQ1Dho3zouKy 4jXWdAKckdBsRGawt3hTtcIlEWJsyj2MU6WFItI6p0AxO014IHPnIJEsTOKEgC/0wd P45NrdcZyg0QyfmKcU1Ghopqq6R2S+jLKoXAjKSiDHR4usVqKq8mqViSjlIDhtgw6R eOhCckRLisVzXP3Qp2+543zGThNwmG9yvxM6L72CdAsVned+cIXlFKODRc2ddtkNjr 62Qoi4F0u2ezI7qZvbVw5dFg/BHbf/ZBl/JaSpMsdYNGK6ieMGHPA/ur3Pv+0MpuZ2 TNfLsBa3KvF4w== Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A70A163330 for ; Sat, 6 Aug 2022 21:04:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MOITIItx"; dkim-atps=neutral Received: by mail-pf1-x434.google.com with SMTP id f28so4945857pfk.1 for ; Sat, 06 Aug 2022 12:04:59 -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=YrgsQJ2JjVrN6lqcP3OJCWFTFg1HvBD3vVFd1HXpkVk=; b=MOITIItxBzjS5VFUdHHyq+BvcKcuuQKpGo3barI6Ah+4KayxVoPeh+FzG2zBdPKAUA m5ENr1pEFEOV/NNmaS2ft8cXAIhzZAcP5NnKde86pImOKpap6WNQBNSjgSswNsfxVE3t rQ5t6cYvxocbp8vD6cBnb3myM/Cqv/KjdlurBjWL7rRNieMeTG2i10MswFsFoRwg+qn8 4ini34u7A2oyp3nXH76pYFeTqSSQfRSV0kLRNOhqwDMWltICDFZlTpzlalXTB/yEZvnH PGPGDklIzmUTrQ2q5PwA9Y9vz+GlHMHs6yONwVNNKSzFC/+Ylj93PbRUQRUPx53qMn49 LP4w== 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=YrgsQJ2JjVrN6lqcP3OJCWFTFg1HvBD3vVFd1HXpkVk=; b=QhjeCJ+j2VlJWXznj0dG9Kxay/nfJT8rVjKOEiuW1vG47ajCnzlOo3iPy/7xvxLegO Upc5JN21oU8XxXJOZ5X7++2f/cMeHdxLXeaAfaaDiPZXiOc77Kb24l2aF8Zb1wbeqcp5 qq1WkPAGgLEpyu9EvQXXzNc0H27DF2APpfrqWJwXi/9jBKsZmYrFjU0KB5dVin0EGwX+ odY2esJrrcBsgRKL/MOS8f2JnFvsXPEnMZd82Cv6dLOMogD1qh9WdlhE4WLgl9MEXuPD agZkuhf2GKlJAMqD+Hju/MxfVOkIzlw70mVmcwLc7zyZq6r1ohpdHsyusj+qrJT2XJaN CmsQ== X-Gm-Message-State: ACgBeo0ExOo5wEjKncUdo1ectmSapOlOyma5wPq29UVRyui3/+t5RRj4 0EsaJFnW75rDlM13gUD2z+M73Tpf/8A= X-Google-Smtp-Source: AA6agR74dMUBdjdPIsxP8R3GJ99RbTxnMNJyEiPwQMzksxToP4kxf0uyhZ9kgro6mtziD1RID7ewow== X-Received: by 2002:a63:2254:0:b0:41c:4b26:863d with SMTP id t20-20020a632254000000b0041c4b26863dmr10045659pgm.4.1659812697933; Sat, 06 Aug 2022 12:04:57 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:daa9:adf3:a099:1bff:e55]) by smtp.gmail.com with ESMTPSA id z17-20020aa79911000000b0052f20d70845sm406025pff.150.2022.08.06.12.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Aug 2022 12:04:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 00:34:33 +0530 Message-Id: <20220806190433.59128-5-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220806190433.59128-1-utkarsh02t@gmail.com> References: <20220806190433.59128-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/4] qcam: CamSelectDialog: Display Location and Model propety of camera 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" The camera selection dialog currently only displays the camera Id. Display the camera location and camera model if available. Signed-off-by: Utkarsh Tiwari --- src/qcam/cam_select_dialog.h | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index a5189ec3..0200d374 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -12,11 +12,14 @@ #include #include +#include +#include #include #include #include #include +#include #include class CamSelectDialog : public QDialog @@ -34,6 +37,17 @@ public: for (const auto &cam : cm_->cameras()) cameraIdComboBox_->addItem(QString::fromStdString(cam->id())); + /* Set camera information labels. */ + cameraLocation_ = new QLabel; + cameraModel_ = new QLabel; + + updateCamInfo(cm_->get(getCurrentCamera())); + connect(cameraIdComboBox_, &QComboBox::currentTextChanged, + this, [&]() { + updateCamInfo(cm_->get( + cameraIdComboBox_->currentText().toStdString())); + }); + /* Setup the QDialogButton Box */ QDialogButtonBox *dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | @@ -46,6 +60,8 @@ public: /* Set the layout. */ camSelectDialogLayout->addRow("Camera: ", cameraIdComboBox_); + camSelectDialogLayout->addRow("Location: ", cameraLocation_); + camSelectDialogLayout->addRow("Model: ", cameraModel_); camSelectDialogLayout->addWidget(dialogButtonBox); } @@ -75,9 +91,47 @@ public: cameraIdComboBox_->removeItem(cameraIndex); } + /* Camera Information */ + void updateCamInfo(const std::shared_ptr &camera) + { + if (camera == nullptr) + return; + + const libcamera::ControlList &cameraProperties = camera->properties(); + + const auto &location = + cameraProperties.get(libcamera::properties::Location); + if (location) { + switch (*location) { + case libcamera::properties::CameraLocationFront: + cameraLocation_->setText("Internal front camera "); + break; + case libcamera::properties::CameraLocationBack: + cameraLocation_->setText("Internal back camera "); + break; + case libcamera::properties::CameraLocationExternal: + cameraLocation_->setText("External camera "); + break; + default: + cameraLocation_->setText(QString()); + } + } else { + cameraLocation_->setText(QString()); + } + + const auto &model = cameraProperties.get(libcamera::properties::Model); + + if (model) + cameraModel_->setText(QString::fromStdString(*model)); + else + cameraModel_->setText(QString()); + } + private: libcamera::CameraManager *cm_; /* UI elements. */ QComboBox *cameraIdComboBox_; + QLabel *cameraLocation_; + QLabel *cameraModel_; };