From patchwork Sun Aug 7 15:40:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17012 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 68D3FC3272 for ; Sun, 7 Aug 2022 15:40:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D392963327; Sun, 7 Aug 2022 17:40:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659886822; bh=K6yTNq9W8bpNVicgBdGQnuNqkSC8a2n+cuPHN4KR0ag=; 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=Vw0RvJUYdBjfNtCcpXSBsO5QyLRzurCEyxsFOoxeu55sphfnzj1OzG1zGJzjMqWKz uSZapSbLMP8yRZ45hiqF6OMQ8boeQJorhiJeXlflE+9JM09dSSBf2dXwsBSjxv8VRJ TpmTWMy5BdKkUAdE+LR4kghKhCqcni//L2qNKC3+sZInLGbJetkF4Yo/PeamX+pVFl PqY1T8ufDKXbWIVJ11jJyasCveregEi3NdehY1RKIIS+npai1/ue9Zt8YTCD9nvoi/ FB+YE2wkGeKINSokrLVTTQqd/jHM/ksGi7bc3ZymbKqz11XS1ndddujrYh2wemeSrk 3AC2Bf6NLRslA== Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BF9963312 for ; Sun, 7 Aug 2022 17:40:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Oa00bzdx"; dkim-atps=neutral Received: by mail-pg1-x535.google.com with SMTP id 73so6566121pgb.9 for ; Sun, 07 Aug 2022 08:40:20 -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=wmaDYH9DIjUXsNGf+aQEiWFKdlIdCjQIpa/XcBfSS9M=; b=Oa00bzdxNuUiHjYkuYBcxnGNodeaYwUOvlutj+2tlDG0pZP0wNsD/z8DP4UAI06ssq GTWd+L4e7FfnN54jKLSK4Rx93WYn2uzKIxeOc3Tnnlig7X7Bt9ugzuub6NfjVNUYMlA1 KA927pa/Zt2D0AicjY29mXTiBndFng1o/zMeItGUNFxZR7Lit1230RlRavII04I5b43N me2cthx1bLpxHgwm09+U6fgCaNIsP+Ptp8CHrirFzpPCiFr4w92v5hVpHyXUR0eftIkD 9zBcO2drCbzOIVwJWPEH/AsUEX5QbKZ4W124+zhqXW5btbw1Q9KJspazuvkY1UJM6LgR B0YQ== 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=wmaDYH9DIjUXsNGf+aQEiWFKdlIdCjQIpa/XcBfSS9M=; b=4AtCoaDxkFsHy5wBJ+ObcljwU+jDYm5Gciet4yp5BeVYTZ7Ugm8Iu4fIyjEEVe34tE k9o8ZKMJPb70oqwLZi243VgcTtnguVFc6edeimxU3x8srJP/PsPND8Veb3h0kmsiQaIv fwXeqDjh+HSr7EU7MKNMp2Ai7whsXjpiI+l6xf2S3URj8Aq4DP3BZ7lYPqsoIOWbJ3Jd 5jM8fxIVNAtXP8eqebkj+C2ft7dsTLm52zqd9mH++SNLjAy+HihGiqb0wmws5HSqTeVj uqc86UqbdB6ASmGhLW1LF/HFV/f5GBG+T46EFpMWUp4Z3ohd5gGACgrp5J+GYgZ8l6X5 khHw== X-Gm-Message-State: ACgBeo2lxy587EkeV+61SLJy9gVfu5i3E0IL2DUB9fNTV8y4i3LeAN2l I5qGoBRrVXTA00vmjyGYmACqhm58QZ4= X-Google-Smtp-Source: AA6agR63ziX0/PwgE2dCTSEfLoaE38TK8egtIlGy0mi58XhyIHhkV9rWqKK62isctnjRP9NiYdJqTQ== X-Received: by 2002:a63:8bc7:0:b0:41c:d1e1:7fb2 with SMTP id j190-20020a638bc7000000b0041cd1e17fb2mr12577364pge.281.1659886818635; Sun, 07 Aug 2022 08:40:18 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:d9f0:4d1:f1a2:ade]) by smtp.gmail.com with ESMTPSA id w3-20020a17090a6b8300b001f4e8dbed8csm9055843pjj.7.2022.08.07.08.40.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Aug 2022 08:40:18 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 21:10:02 +0530 Message-Id: <20220807154002.91607-1-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220806190433.59128-4-utkarsh02t@gmail.com> References: <20220806190433.59128-4-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2.1 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 Reviewed-by: Kieran Bingham --- Difference from v2 : remove redudant function getCurrentCamera, its job can be done by getCameraId() src/qcam/main_window.cpp | 41 ++++++++++++++++++++-------------------- src/qcam/main_window.h | 5 +++-- 2 files changed, 23 insertions(+), 23 deletions(-) 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 Sun Aug 7 15:41: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: 17013 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 A9B0BC3272 for ; Sun, 7 Aug 2022 15:41:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D4AB6332B; Sun, 7 Aug 2022 17:41:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659886915; bh=yvl4Be1rDGPf//2TMwNf/uo1HTN3n1iBb/Xma4ZVIaU=; 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=p9cbdcrfbtMaGMNalgn3JM5SpX5VkfUtf8M3P0yZaa8gBOkH0k8s6H0AasfxpVa6d ZuVBFt7HDBcY7aUtHGhJtzEaQZmIZvwaDQX8RJ1q+WNEx5GhSRJLo183Dplyc+ynts B4RKY/SS2AePTVi3a2J5piyWtqMvErmWVWW0g/urjP3QFwWAbAt/fqBE7FRhLql3tA H2Gqg9nG9VilcphfXEY52oVH803K3v9u/JryTeRekMlK30tcxapfixCollT9M5NAlo 4tm2bQ459+32FWGN/qCGpSPQdjCibe2bByVcmPk11tk/UUbuwMQvJhvVHG60nfx8eb VPr9WztNSQ1lA== 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 074DB63312 for ; Sun, 7 Aug 2022 17:41:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UdQrH7Jm"; dkim-atps=neutral Received: by mail-pj1-x1036.google.com with SMTP id pm17so6750513pjb.3 for ; Sun, 07 Aug 2022 08:41:53 -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=lTHOLU79qXKIVDo134nYc49oQn/lIMGsg4pDKOK6Z3A=; b=UdQrH7Jm2zln4gfUbP9Bt+ZRgtYcuzxAru0Egchfjq3hiN/qOBs4t5AOvSpXiA9R/J shKWo1DVxCePXaiYSyHg56p6QBZqN+5ITHaCdOBktuxxyY5cx0wVulLcJ6K564TvU6+d kHfLP6SYdpFlF1pNNYMjOmkLga2MY6gwoVLgV1Hj0hDzTPAXagMFTBLhsTxRh66RSorv OgyAqYU4uWYjFXtklcXNHfND1uZsgDUGnVh7qDYQhpN+uM6ZXNloImZ2I6sGab/+ppmX bRgQgjSfrlWr6oSYFWFYRklOSp/067UlrfSLSNvjmecoiZQ6a5HIArdkSp+2zSs3xHoY xTpw== 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=lTHOLU79qXKIVDo134nYc49oQn/lIMGsg4pDKOK6Z3A=; b=Eov/Ktz8+fp56tP2bQdvsvy0hmS+8JnpX5lurdMGiG2A/CgF2iMn2kDatCo3UC3uVg xCjx2/1nQl7bBDcs7nbP4n/fQd2tiuciAtqSLcZrSSmINAhd662ijMrmKE0qaZZ8BFkz BV5ikiZy9ON83pbvie/TG3OO08M6BdIceBS7qc987yB40NnLxQqyxh/zxCU7svGKcFGC jL8ecoahEXAspK8HeweI9zyotAkCJ714wjXSRBOkDsirK7z21uoBO6FyodEWfBXou1wG +1SN5L+EemaPItd++peyK+RzKMG+rB1ifI9F5zOu+oRWCWj+/IJ4R56lZjq+TBlucFpD RaEw== X-Gm-Message-State: ACgBeo1orsTSWZXhRv+8DlQ2OR7QM1h+sDV/+AcDRzQBaERGhiGGInrq M2FtnOOpJKNyl65e2WeBtzraJ6NWPeI= X-Google-Smtp-Source: AA6agR4hmGl+kWXWQBGnZMdK+a5mWPc+iIp1Oc6L4IitG2xYxYQ/y2SJpGuhd/V21c8Wv4dnUwB6CA== X-Received: by 2002:a17:902:cccf:b0:168:c4c3:e8ca with SMTP id z15-20020a170902cccf00b00168c4c3e8camr15354380ple.40.1659886904624; Sun, 07 Aug 2022 08:41:44 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:d9f0:4d1:f1a2:ade]) by smtp.gmail.com with ESMTPSA id u6-20020a17090341c600b0016be596c8afsm6751889ple.282.2022.08.07.08.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Aug 2022 08:41:44 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 21:11:38 +0530 Message-Id: <20220807154138.91960-1-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220806190433.59128-5-utkarsh02t@gmail.com> References: <20220806190433.59128-5-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2.1 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 Reviewed-by: Kieran Bingham --- Difference from v2: Use getCameraId() instead of getCurrentCamera() 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 ee65eb88..6ba61cff 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(getCameraId())); + 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); } @@ -70,9 +86,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_; };