From patchwork Tue Aug 9 20:50:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17056 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 46CFBBE173 for ; Tue, 9 Aug 2022 20:51:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0530863330; Tue, 9 Aug 2022 22:51:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660078266; bh=Bfo3MNw2X87wUqYkn7yZ5Z7KL5aO6MgRuLdiAKhIk+c=; 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=robKugGc1Ars3j0jGtZBIBS1S6r2ggETt6eyUtFT+6abxOLqfUziklB6KJuzJuVjZ MyMQrrmMk+AdIhsDNob7cxvxnCx4KDbXzMlVSGrwab2GnbmjhDTvt1/cgRQcnw7inX 0OgZ0NnNnpL59m87kmBES17EdzU9a44C1DihAqxWBToEIQD/Lx7ORzhhbjsNsY0BrX TxG+2QVppqPLGmAQC4h3k1XnhcngwYQbyLaWce5/KltzJ2e80ASuxL1aQwltH1De7c N2MTSg6X+6UFovVRlfe8Mx7SXUhNStSmugwe+E1GJpbBsA7gvY6kqP6ZI9aor4Cyt2 vs0XcKApWeeZQ== Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F3E2E6332F for ; Tue, 9 Aug 2022 22:51:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Nxt562N+"; dkim-atps=neutral Received: by mail-pj1-x1030.google.com with SMTP id pm17so12830956pjb.3 for ; Tue, 09 Aug 2022 13:51:04 -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=8FNAgahM9w38jWDF6h/O2SKek+RtA3Cc8HkrQLIP6LM=; b=Nxt562N+VZh51IxuMOndZRLBo1a+qm7B/5ERFEvZ/2bD9EE3+H7Xv/DhmjnKCtdtnt upD9zeFZ0Oel+G5yIj2kvfaZIfUAQDPxf6LrlVyUZsDeAyI/O2iiUm0J50Kh2EYxUL3l hK/X1DKVjV3kW0d3CgMUgNpOE993Q7XOmffKZ/G9CO5Jk8YCXahUyGOJWMcpmB2ur3SS 5EyjVraWjYkuhst0CUkSCS4nzSFHJ2wRGF7P24XCwyrpO5VRa6K8VuNIBL+Oel1Nefo+ 0n7JdgYl82eko2nNGgJwRtT2anpvNUz2bTMZr1/xkLDCsNynYmcwhI2Q2LQPUri5NNnk X7DA== 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=8FNAgahM9w38jWDF6h/O2SKek+RtA3Cc8HkrQLIP6LM=; b=jUB1rgKnCivP4zNgZIBHB28wIUuq3UXizgh7ifgIl9AQwFmjLZaZV0bC6YV/Vyjw6k k7ovY0DPVmR92mwSV2dUHXLdGNDh6MgTTmq21SIaq+JsfW6zKFM5MrINW1ebjY4vrlWN 5L0S9xAJmXS1DLk5gp5aGK0glR7jkvHfWIhIT58SfxUxLFwOTZBc0GmL9/OCpfIhqHrV +iJbNfM4BGKuMWduBqe1VU7uguMbdT67bnzYd0tesE0ZKVGj4HFlX32PlF2elDzhdRp6 c3Uvyl2z4pzPVbZ5CtjF4cm1VjelAIRQ0fFmI+3M9trxEQNiGvFmMOCWworG8B5DUGav pUNw== X-Gm-Message-State: ACgBeo34Kq3QeZU/W/cZmauhP7FawD7vrMMasaFQ/sM861Wo/QGFSdAo SR1Yl/RuLtrMclVLXkDEapHDlogLXs8= X-Google-Smtp-Source: AA6agR5+N9dgNTrq5lWo5ZGMZ9RLZ35MicT9B+aCi3IeGrGinUlbEj9Sv9kqayYEfJMkPLoiz0Mlgw== X-Received: by 2002:a17:90b:1b08:b0:1f5:b65:9654 with SMTP id nu8-20020a17090b1b0800b001f50b659654mr292169pjb.77.1660078263357; Tue, 09 Aug 2022 13:51:03 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:2358:3bcd:fb4f:cbb7]) by smtp.gmail.com with ESMTPSA id d3-20020a623603000000b0052d981e7842sm301936pfa.208.2022.08.09.13.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 13:51:03 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Aug 2022 02:20:38 +0530 Message-Id: <20220809205042.344923-5-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220809205042.344923-1-utkarsh02t@gmail.com> References: <20220809205042.344923-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 4/8] 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 Reviewed-by: Kieran Bingham --- Difference : 1. Now use value_or for optional 2. Not use lambda and make a private member function src/qcam/cam_select_dialog.cpp | 52 ++++++++++++++++++++++++++++++++++ src/qcam/cam_select_dialog.h | 10 +++++++ 2 files changed, 62 insertions(+) diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp index d8982800..f97ad6eb 100644 --- a/src/qcam/cam_select_dialog.cpp +++ b/src/qcam/cam_select_dialog.cpp @@ -7,6 +7,7 @@ #include "cam_select_dialog.h" +#include #include #include @@ -30,6 +31,14 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag for (const auto &cam : cm_->cameras()) cameraIdComboBox_->addItem(QString::fromStdString(cam->id())); + /* Set camera information labels. */ + cameraLocation_ = new QLabel; + cameraModel_ = new QLabel; + + handleCameraChange(); + connect(cameraIdComboBox_, &QComboBox::currentTextChanged, + this, &CameraSelectorDialog::handleCameraChange); + /* Setup the QDialogButton Box */ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | @@ -41,7 +50,10 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag this, &QDialog::reject); /* Set the layout. */ + layout->addRow("Camera:", cameraIdComboBox_); + layout->addRow("Location:", cameraLocation_); + layout->addRow("Model:", cameraModel_); layout->addWidget(buttonBox); } @@ -63,3 +75,43 @@ void CameraSelectorDialog::cameraRemoved(libcamera::Camera *camera) cameraIdComboBox_->removeItem(cameraIndex); } + +/* Camera Information */ +void CameraSelectorDialog::handleCameraChange() +{ + updateCamInfo(cm_->get(getCameraId())); +} + +void CameraSelectorDialog::updateCamInfo(const std::shared_ptr &camera) +{ + if (!camera) + 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("Unknown"); + } + } else { + cameraLocation_->setText("Unknown"); + } + + const auto &model = cameraProperties + .get(libcamera::properties::Model) + .value_or("Unknown"); + + cameraModel_->setText(QString::fromStdString(model)); +} diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index 567083ae..359df811 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -11,11 +11,14 @@ #include #include +#include +#include #include #include #include #include +#include #include class CameraSelectorDialog : public QDialog @@ -33,9 +36,16 @@ public: void cameraAdded(libcamera::Camera *camera); void cameraRemoved(libcamera::Camera *camera); + + /* Camera Information */ + void updateCamInfo(const std::shared_ptr &camera); + void handleCameraChange(); + private: libcamera::CameraManager *cm_; /* UI elements. */ QComboBox *cameraIdComboBox_; + QLabel *cameraLocation_; + QLabel *cameraModel_; };