From patchwork Tue Aug 9 20:50:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17054 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 5B66ABE173 for ; Tue, 9 Aug 2022 20:51:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 165DE6332E; Tue, 9 Aug 2022 22:51:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660078262; bh=Jr3N5xZ/pt0OpbqVWsjfe9vtI7OL/MbZ6n1JpILI72Y=; 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=HMWNBGRQgbYzgT4hJtxTafZBB8+uRY4/8R0jEg440WMbODKRcjhT92ynq8x+wu0i6 wp4aMeHfSE4jcfqHn9irL/Oqi+qoqecZBgSXhIyr+LsFLxvopuuG3qx616jS6RVnV2 z+iGwf5zXNw8PnWRm3Cf2Tg0I1U1u3NhAANDpAMb92Z9gjtTVldjJWNKTHaxtWCxij o2/tGS1ifgLWQO3J9r/X4eYCY4cW1JffANL3/RDRMiAbgwwP7kLuvJxYf91qj8Yrpw 9E2XC0Dufy/S7UN5c1RjjfQO7apRYSniWAmCQQrca7vGDO5K1fYaBNt9C2xguZOS+m 9PErkHWJkeJeA== Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F333C63328 for ; Tue, 9 Aug 2022 22:50:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pFRj4lnM"; dkim-atps=neutral Received: by mail-pf1-x42f.google.com with SMTP id 130so11817411pfv.13 for ; Tue, 09 Aug 2022 13:50:59 -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=MXl7enM09lK80T/81FGaBB7h+PlTHLqNA78faA96bmc=; b=pFRj4lnMq+W/Qzq8mmRjGgR+QZwfQ1rVG4RBX9PfiwUAilRXEZ0qzqCl6bIrbJSmj/ eik7NkKROpD+bmAE3PaX3YhAocmvjEtmRTqfO9mIpOfHeOII8efUhCdMOfsj5XuFMb9n NODhRHl1cLMyQDSURpFGM7aiQjUEbwHuhdSmY9N2/6NgFpp8S20MP2SCxLsHgnjqmDyN gY9+SoM3sUcUDonIvxXTRyWVOGnENEjktqH/OxeZttJO2T6PQWLsQkWhtAv9k0JVSKI9 a5CVYyG1/hanfeO8icHdZXi7O3j7pE/nOf3HB1V1+HFdDE6ZHUn1azz9ttxwuvaDupmR bUnw== 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=MXl7enM09lK80T/81FGaBB7h+PlTHLqNA78faA96bmc=; b=To7DQEzPSkTRepsYD/+fBAhfczh7bSHxJ/TCF6JJBcrJeVt8v2I2Mz6tOW0s/X2fFR 06drEAlPN/KVGe28Gu9+fmweTZV3xwhkrYFCrZ+GxGtg1cqionUo3RdZ8J11O0PwQL67 U3BE/AHg87hxiBBosx1JifULAqCck5KthoCL6gJOjrgATKQBM4Aas20tR6+s2KuPnbqv PbdgyC6GXRMvGzUeeJbrZ2m3m7B1pzhOVBGv07xo6z3ze6d3WOsUFBtL64zj9yIA0BuM 49K569bK8L8MpbJvnrfc3b/VhhAHzMfr/nKWRMMj8UTgwWOda6moEXpWtRar0AWGQd06 QQFQ== X-Gm-Message-State: ACgBeo1iM0bm0+SJSBc/ndRzi2XQkB1Io7czg9t08qPRgpCXGfU6Kh9s Lxe5cTIe4MA18g87oUF28tH9DBsJIJU= X-Google-Smtp-Source: AA6agR75QJoIaSc7v4srUDdaiDfJmmdzzy/4dYspseaIV/LRpKuTke2jDh/VaKKyXRzJFfYtteIWlg== X-Received: by 2002:aa7:8c51:0:b0:528:2ed8:7e35 with SMTP id e17-20020aa78c51000000b005282ed87e35mr24012073pfd.13.1660078258364; Tue, 09 Aug 2022 13:50:58 -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.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 13:50:58 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Aug 2022 02:20:36 +0530 Message-Id: <20220809205042.344923-3-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 2/8] qcam: Support Hotplug for Camera Selection Dialog 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" Currently if there is HotPlug event when the user is on the Camera selection dialog, the QComboBox didn't update to reflect the change. If the QDialog exists then alert it for the Hotplug event. The check for QDialog existance is done by QPointer. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- Difference: 1. Moved functions implementation to its own .cpp src/qcam/cam_select_dialog.cpp | 14 ++++++++++++++ src/qcam/cam_select_dialog.h | 4 ++++ src/qcam/main_window.cpp | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp index dceaa590..d8982800 100644 --- a/src/qcam/cam_select_dialog.cpp +++ b/src/qcam/cam_select_dialog.cpp @@ -49,3 +49,17 @@ std::string CameraSelectorDialog::getCameraId() { return cameraIdComboBox_->currentText().toStdString(); } + +/* Hotplug / Unplug Support. */ +void CameraSelectorDialog::cameraAdded(libcamera::Camera *camera) +{ + cameraIdComboBox_->addItem(QString::fromStdString(camera->id())); +} + +void CameraSelectorDialog::cameraRemoved(libcamera::Camera *camera) +{ + int cameraIndex = cameraIdComboBox_->findText( + QString::fromStdString(camera->id())); + + cameraIdComboBox_->removeItem(cameraIndex); +} diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index 8e54f916..567083ae 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -29,6 +29,10 @@ public: std::string getCameraId(); + /* Hotplug / Unplug Support. */ + void cameraAdded(libcamera::Camera *camera); + + void cameraRemoved(libcamera::Camera *camera); private: libcamera::CameraManager *cm_; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 48479f35..377b4650 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -593,6 +593,8 @@ void MainWindow::processHotplug(HotplugEvent *e) if (event == HotplugEvent::HotPlug) { cameraCombo_->addItem(QString::fromStdString(camera->id())); + + cameraSelectorDialog_->cameraAdded(camera); } else if (event == HotplugEvent::HotUnplug) { /* Check if the currently-streaming camera is removed. */ if (camera == camera_.get()) { @@ -604,6 +606,8 @@ void MainWindow::processHotplug(HotplugEvent *e) int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id())); cameraCombo_->removeItem(camIndex); + + cameraSelectorDialog_->cameraRemoved(camera); } }