From patchwork Wed Aug 3 17:55:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16958 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 188ABC3275 for ; Wed, 3 Aug 2022 17:55:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C16EE63318; Wed, 3 Aug 2022 19:55:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659549332; bh=L5SUs8syTThpflIJmphIG1FYn8k+QjPN8wemRiOXVjg=; 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=A/y3NbFuwfQKWakEVWPttvaDMAxiNlVXIbFR43hA1/wUgf4CMc1bji5BxOwcQPm/r +zc8RTBzqZi7mx9SIyRjPVbKmhjKLfnaILyEr+T4KI+s5Eu0YN+DsHzxC/bLtudkmr WtnLbXKTnYxqHqTDYCqUlkx1qMTcTaiFFD6p3kO0PTBsHTuJ8Ccy0/vQp80z46K1pn cNhW4YOnRp+jZJUh8uMjUcLCkz1DJuGeluLrLYXOjTQrkx1ISduuCGrSerLn735xO3 1ou3rH9DsxweTR2j5FVMBUBsBB+0N0QUBwXuqSDjjvN8k3/Tr99xgmQlOQJI9U9l5p hHeaZUPq5z3+w== Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CF5663314 for ; Wed, 3 Aug 2022 19:55:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ee6e85WI"; dkim-atps=neutral Received: by mail-pl1-x629.google.com with SMTP id v18so17067525plo.8 for ; Wed, 03 Aug 2022 10:55:31 -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=+AYKpewvBPvWpyDdvrjVaXbdLyr0CbHI6oebH/diOL4=; b=Ee6e85WIV7IJfjNWViDN7BbUMTU/AGsxfE+JL4OM1iOaWv51QMj96CfX6bt72ZQVJp Tgz8FH5xRwiYFWbL0Nx/lKAPLbFuY49n4otymlHPpCE6Qd6WCZ/te0PTcQ8JHc9BxEKB DYVo5SqXpMDvzzAaGONfVrvxl4rti7BJGcncJCO2hfSMBO+ZzJ/lGMNBMuP+ZObd2PsO XKTXohS670lDJedzIVK9TNHp7deuTh10SVds0Gf0THpVq7TNXFa5Kx2ASimBhcHIiSME N4QVkfLtCo8NdYyLSDQTPs2jplEgBxOCPJuS0WWd6k1Q6KFNOqKQ2Epqfn0B34hni3HL pa+g== 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=+AYKpewvBPvWpyDdvrjVaXbdLyr0CbHI6oebH/diOL4=; b=6wV0A8DwiV65w3ipLqOt4TqoGQ4CAzkkZi6OkRdXZ5LBWK+pEG6RwOblP5Rsd/+TB/ M58nJoTj9Q0akwNh4dIaeGebHha7WRxA4RjdiQvP/h5RD8qcyuIs125v4nHjNPaACtz0 Gz32W5QLoSlG9pAma2kNnbxD1C2cUYKPj4mqoYvKrchCbsCAHYZ5PSEkits3PaSF+KUR qKXFf1odSigtCBUQO7cLpIlf+vs+PdOREJdsgVevq58AYKp9Jn+qH1GGTKL4a3saZKHI VGZPiDCM6qBDKOy7/829yR7mTKNSzwHu4c/PyQHdKybV92Cj63IgQggaYTnfu7tKdF2U M5JQ== X-Gm-Message-State: ACgBeo3gzulld8XbMOgsaudSM94L9v/2rdGoZtjne2Gdc72WyPYDDeiV S1gu/xHkG1s9C+MrrQXfRTVUdXhGSw4= X-Google-Smtp-Source: AA6agR5GcKUrE7wJr5TyDqUj6K7NdwxjXBZEx6fCLOo6wSM/orF2fW+QtUpIfrTMHdX9qIKl0NQa2Q== X-Received: by 2002:a17:902:cece:b0:16e:d4c3:5894 with SMTP id d14-20020a170902cece00b0016ed4c35894mr19732219plg.154.1659549329482; Wed, 03 Aug 2022 10:55:29 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d5b8:ad21:c99c:170f:1ae]) by smtp.gmail.com with ESMTPSA id f3-20020a170902860300b0016357fd0fd1sm2193343plo.69.2022.08.03.10.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Aug 2022 10:55:29 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 23:25:16 +0530 Message-Id: <20220803175517.175332-4-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803175517.175332-1-utkarsh02t@gmail.com> References: <20220803175517.175332-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] qcam: CameraSelectDialog: 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/main_window.cpp | 69 ++++++++++++++++++++++++++++++++++++++++ src/qcam/main_window.h | 7 ++++ 2 files changed, 76 insertions(+) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 80a73b68..81fa3e60 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -23,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -291,6 +293,47 @@ void MainWindow::switchCamera(int index) startStopAction_->setChecked(true); } +QString MainWindow::getCameraLocation(const std::shared_ptr &camera) +{ + if (camera == nullptr) + return QString(); + + const ControlList &cameraProperties = camera->properties(); + const auto &location = cameraProperties.get(properties::Location); + + if (location) { + switch (*location) { + case properties::CameraLocationFront: + return "Internal front camera "; + case properties::CameraLocationBack: + return "Internal back camera "; + case properties::CameraLocationExternal: + return "External camera "; + } + } + return QString(); +} + +QString MainWindow::getCameraModel(const std::shared_ptr &camera) +{ + if (camera == nullptr) + return QString(); + + const ControlList &cameraProperties = camera->properties(); + const auto &model = cameraProperties.get(properties::Model); + + if (model) + return QString::fromStdString(*model); + + return QString(); +} + +void MainWindow::updateCameraInfo(const std::shared_ptr &camera) +{ + cameraLocation_->setText(getCameraLocation(camera)); + cameraModel_->setText(getCameraModel(camera)); +} + std::string MainWindow::chooseCamera() { std::string result; @@ -303,6 +346,29 @@ std::string MainWindow::chooseCamera() for (const std::shared_ptr &cam : cm_->cameras()) cameraIdComboBox_->addItem(QString::fromStdString(cam->id())); + /* Display Camera Informtion in the Selection Dialog. */ + cameraLocation_ = new QLabel; + cameraModel_ = new QLabel; + + std::shared_ptr currentCamera; + + /* + * When the Qdialog starts, the QComboBox would have the first + * camera's Id as its currentText. + */ + if (cm_->cameras().size()) + currentCamera = cm_->cameras()[0]; + else + currentCamera = nullptr; + + if (currentCamera) + updateCameraInfo(currentCamera); + + connect(cameraIdComboBox_, &QComboBox::currentTextChanged, + this, [&]() { + updateCameraInfo(cm_->get(cameraIdComboBox_->currentText().toStdString())); + }); + /* Setup QDialogButtonBox. */ QDialogButtonBox *dialogButtonBox = new QDialogButtonBox; dialogButtonBox->addButton(QDialogButtonBox::Cancel); @@ -323,6 +389,9 @@ std::string MainWindow::chooseCamera() /* Setup the layout for the dialog. */ QFormLayout *cameraSelectLayout = new QFormLayout(cameraSelectDialog); cameraSelectLayout->addRow("Camera: ", cameraIdComboBox_); + cameraSelectLayout->addRow("Location: ", cameraLocation_); + cameraSelectLayout->addRow("Model: ", cameraModel_); + cameraSelectLayout->addWidget(dialogButtonBox); cameraSelectDialog->exec(); diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index b8122eb9..3a1c6156 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -88,6 +89,10 @@ private: void processHotplug(HotplugEvent *e); void processViewfinder(libcamera::FrameBuffer *buffer); + QString getCameraLocation(const std::shared_ptr &camera); + QString getCameraModel(const std::shared_ptr &camera); + void updateCameraInfo(const std::shared_ptr &camera); + /* UI elements */ QToolBar *toolbar_; QAction *startStopAction_; @@ -102,6 +107,8 @@ private: QTimer titleTimer_; QPointer cameraIdComboBox_; + QLabel *cameraLocation_; + QLabel *cameraModel_; /* Options */ const OptionsParser::Options &options_;