From patchwork Wed Aug 10 15:03:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17070 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 8D4B3C3272 for ; Wed, 10 Aug 2022 15:04:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5221063337; Wed, 10 Aug 2022 17:04:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660143847; bh=tSkV38layzPywD5+leW5gky6c211YBGtMOIU/YmxMJw=; 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=J5RLB16WcvEzy5LMj8mMXKFz3sy8EMrGxl1H5xo097id7+5xWA7IEDTnzv9cvaUgH A16BPJ/DxqI8bwG5mi5Zb3CTuMMIlMendPMjMEjuKrjf5svTEbILFhj7/Crw19RByc 7eMPuxEzsJLowGiZIRtu/K8MozgtrtmZXzLrik+ENfsYc+FGTYLqXnKz6lFKwbmKTs 4eE5BoNRtn4cQfzNhN7FY8FfnSBCsltsYcHlTuTMCyRnRS3T1+4NdQR1SpfFg+McXH 0rXp/JbNCRcMSFCM0I9CuUhfpaAqIhzwQqneP7GwJWY3AOn5Jcpc8luRtoq8RdhH2X si1McCRYTz4yg== Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6AB56600EA for ; Wed, 10 Aug 2022 17:04:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ubfd9Qgy"; dkim-atps=neutral Received: by mail-pj1-x102c.google.com with SMTP id e8-20020a17090a280800b001f2fef7886eso2385362pjd.3 for ; Wed, 10 Aug 2022 08:04:05 -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=yPqc+syOGhMuqA0QCVsz3uFjAHkQ3W7uVeQQ/RZBUUA=; b=Ubfd9QgyD17IQsFF7t5fGWP23wFPZINsEtZEQXLE+PBKtx5PEG0Tf34vtVzMF4LpxF sf9iy3BuNFxFqcwnAyNYKnM05eQaeOHQmOTZHLobjntElv0+ZAJLhREEshIgpL2b8JKu Oz4B96EFmrB56ud8WrhFAIed9lJlmEohjUADkH2bYdwxT0zZSbwdiUV4+6QyPFpB+Xh+ tsR3qgFPtr/3jq9FrNvcerc+dNjsKXQmBIxJ1hz0BzlKOjHIK0cOeUJt9FNEM4OWsOLs GJiCrqBvUeDsEB5BFi2VLbsk/4K/6iso28l455dqxzzwnoYdokUKgeNrcPiEALDUVlBG P5Kw== 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=yPqc+syOGhMuqA0QCVsz3uFjAHkQ3W7uVeQQ/RZBUUA=; b=AJCtnVu4RZDTNOwUlF4ImXGPIdOK8W/YrP3y+AFWD6hIW0Hp4eqh3mzmCaL/1zlVDX R3G8H2yTc23aLSRWimmHDOfIuAD+bIoqPgwPlNoBcPcx4Xpy7zmQw03OkIfjLsv4DCzg Loi9qdeTGsh2bQ+x71S2N+JTsI53v7JrmfWYBSORGNo+/zfDUBQi9h8UlWEzwAtokqN+ rSqxLV6SeU2ChBsHy8fOgQLbdaIO5IySEs6FXgl4O/F3RtjY5Kit0yp9A/OwtwebrD+P /dchboIzL922TI5HUWM7wMYr4Xy+FWZlKc84ZSR3iW+xeEbiIMEhPNOodhHTHO6syMoT iBbg== X-Gm-Message-State: ACgBeo26qL2kJUdtfWuHw+CpsQPELasnc+7Soqie7d7gPrtkiQ7mjUd4 7aMHvFZ9RTJIXi/8Ofd5EjTp4zASNuY= X-Google-Smtp-Source: AA6agR40B/UOntW5AeWAFN0kIbHN8zph+pR6mwgPMmTtJDn4DiyLBmWrjMMN6VL07rWOMQPPPAf1lQ== X-Received: by 2002:a17:90a:fa91:b0:1f5:1f52:a2ba with SMTP id cu17-20020a17090afa9100b001f51f52a2bamr4135279pjb.16.1660143843741; Wed, 10 Aug 2022 08:04:03 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:2a55:4cae:bf8f:f4ed]) by smtp.gmail.com with ESMTPSA id b3-20020a1709027e0300b0016f1319d2a7sm12882624plm.297.2022.08.10.08.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 08:04:03 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Aug 2022 20:33:45 +0530 Message-Id: <20220810150349.414043-5-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220810150349.414043-1-utkarsh02t@gmail.com> References: <20220810150349.414043-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 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 from v7: 1. Nothing 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 04c71fd8..16475af6 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -11,9 +11,12 @@ #include #include +#include +#include #include #include +#include class CameraSelectorDialog : public QDialog { @@ -30,9 +33,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_; };