From patchwork Wed Aug 31 05:49:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17268 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 CAE51C3272 for ; Wed, 31 Aug 2022 05:50:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A48261FC4; Wed, 31 Aug 2022 07:50:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1661925004; bh=YvZ727gfLjtvWMXWh3ahMRI3I+UkZdTkjnh9L2o62rk=; 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=XNeUVGyZv5JyIq9UYg1rLkmsqTMSvI/QE3CrUj0VE5/jYFXzeNp07Rt7ckwPDjEn6 XWQC2U3YHOtMWOQ/d3h4WwiHkBJXtqxygeoQnb9raBDY0z+fXyJJl74AsqwlmVXxkE eY9lm8W75xZp+dFo7E/Uib3sz04ezC85zAkiOc+nYveuylCenOWmpqYyvwYPr6T1B7 TQRyHaqZcKHFhaAnFOw7cbMqsCwHZ9QcjYCadPrJRIAo08WidULR5//9iwFJThD3u/ cz+bIxDyl+Ij4A0URi49sQp6BuI2mMQcGq7U+UgU/Coj1u8v8YNQol/xqPy5cQ6W69 NjUy2WkdXgn+Q== Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B9AF361F9B for ; Wed, 31 Aug 2022 07:50:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dfGPshDH"; dkim-atps=neutral Received: by mail-pl1-x633.google.com with SMTP id m2so13195304pls.4 for ; Tue, 30 Aug 2022 22:50:02 -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=bstUSyjs2LmOJ8SXsae32HU48ED7P1q8tMxr+a1QFf8=; b=dfGPshDHE+0Mnfr2kpmhDfUXZhs6g4ZF7g1Mn5kxnGx+YUDrfpOlzsul6vtyOnRs7t jFhUeCMaf9RJWEtVtumJEzROeV9HRME04DjBlgJDsqemTS6Xe3yM8d6RPJKY+6yCptA2 seECuWbVShHh0i9YlaE307tiCmq0Yk/AH9Xr0AVb0Wiw5V7RXZtISdlWPLXxtcR32t2r 0WnX0YXUz4DW2gfav3Wyy3gM+4A3bcO/Kp8cMMM1t+6Ko9rBtzNYHAZYZJIknqCsibO+ 9h6e0ZafgnT6nVqacrTWT36g88pkpcnMbNNiTB/UCb09BqzbKQnThyUDQr/qwZOBTlj9 j9tA== 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=bstUSyjs2LmOJ8SXsae32HU48ED7P1q8tMxr+a1QFf8=; b=ndaU+hZfnz5nHytTH542Zr6MyZzegebPNK92YavhvYPKsLzHMx1jOwMcAXLV1sGv3s toOp6CaGIrcVbCZtfeCflo9LlyOCe3TFvWSDjsH/oVz6rp98hA/r2PdphSAXtPXI/EGd I0GyLuh4DVxqcyQFuRgflVZuAeiyPkwVNiKOnFIA1rXJC2gagaBCVlPJF8umZOtda/EG V4PMdx0mTu/q9puMlvVyK8JT4TlGn03FlivKaKLNPRQnV76lAK/jPvlSQUEzBHWSshQw 2gwzufj0Zy9F811nxpBgZno5Wn6EBFzxWcVYTIem+Lb7GuRm2se+tDP5Ik9Kn7AgzqI2 zo0g== X-Gm-Message-State: ACgBeo2IeHmLHNgfjXcsCu80alkjX+25KfFCU76yngQIthDwKvlPvZW2 l2TcytyOJ2pQxte9WOLi1tkpFIiIUIc= X-Google-Smtp-Source: AA6agR60BCjwOWDsNOYdQfS0BecQVoO1+ilocqWrB2gi1HOTvlMuJOtbCJ0GuGcrtGdEyqVCrE3uOQ== X-Received: by 2002:a17:902:e552:b0:16d:d3c0:85fb with SMTP id n18-20020a170902e55200b0016dd3c085fbmr23655018plf.38.1661925001180; Tue, 30 Aug 2022 22:50:01 -0700 (PDT) Received: from devut-HP-Laptop-14q-cs0xxx.. ([103.36.82.122]) by smtp.gmail.com with ESMTPSA id q19-20020aa79833000000b00537eacc8fa6sm8307333pfl.40.2022.08.30.22.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 22:50:00 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 31 Aug 2022 11:19:35 +0530 Message-Id: <20220831054938.21617-5-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220831054938.21617-1-utkarsh02t@gmail.com> References: <20220831054938.21617-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v9 4/7] 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 Reviewed-by: Laurent Pinchart --- Difference from v9: 1. Remove handleCameraChange and use updateCamInfo directly 2. QLabel forward-declare 3. Rename cameraProperties to just properties src/qcam/cam_select_dialog.cpp | 50 ++++++++++++++++++++++++++++++++++ src/qcam/cam_select_dialog.h | 8 ++++++ 2 files changed, 58 insertions(+) diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp index f82930cc..6543228a 100644 --- a/src/qcam/cam_select_dialog.cpp +++ b/src/qcam/cam_select_dialog.cpp @@ -7,12 +7,15 @@ #include "cam_select_dialog.h" +#include + #include #include #include #include #include +#include #include CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager, @@ -27,6 +30,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; + + updateCamInfo(cameraIdComboBox_->currentText()); + connect(cameraIdComboBox_, &QComboBox::currentTextChanged, + this, &CameraSelectorDialog::updateCamInfo); + /* Setup the QDialogButton Box */ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | @@ -39,6 +50,8 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag /* Set the layout. */ layout->addRow("Camera:", cameraIdComboBox_); + layout->addRow("Location:", cameraLocation_); + layout->addRow("Model:", cameraModel_); layout->addWidget(buttonBox); } @@ -60,3 +73,40 @@ void CameraSelectorDialog::removeCamera(QString cameraId) int cameraIndex = cameraIdComboBox_->findText(cameraId); cameraIdComboBox_->removeItem(cameraIndex); } + +/* Camera Information */ +void CameraSelectorDialog::updateCamInfo(QString cameraId) +{ + const std::shared_ptr &camera = + cm_->get(cameraId.toStdString()); + + if (!camera) + return; + + const libcamera::ControlList &properties = camera->properties(); + + const auto &location = properties.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 = properties + .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 bd2dbc1e..c91b7ebe 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 class QComboBox; +class QLabel; class CameraSelectorDialog : public QDialog { @@ -32,9 +35,14 @@ public: void addCamera(QString cameraId); void removeCamera(QString cameraId); + /* Camera Information */ + void updateCamInfo(QString cameraId); + private: libcamera::CameraManager *cm_; /* UI elements. */ QComboBox *cameraIdComboBox_; + QLabel *cameraLocation_; + QLabel *cameraModel_; };