From patchwork Wed Aug 10 15:03:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17068 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 62221C3272 for ; Wed, 10 Aug 2022 15:04:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 781926332C; Wed, 10 Aug 2022 17:04:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660143842; bh=a6AwtFQ3QrVrUPnhwmhPFs0L5JDLFHpteCPdPaZ6JNg=; 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=b6fLXWjej3k40xaG6ipmdRvb5zZok4T0FPlfBnkmcbeueKdp7sqi6zCyiIIePkH01 sjr454s5Dmlpa8teGyjt6SvmGTJSOm+vZ8ei0hIIUCAANxXxMVsaNxzP4mGGKZX4Fm 6xyVsn50dzli2U22xMFZXP91yFhZeRZs7Aoyd7/woSy8JQotq0QOae2gpl63cIIcOZ aGtSTPTidlD6lX+DNgXw9mJ384mm3AYnlH8iZelU7IWaBM6wEwTAbKYzH/wl9AOUQE jgPTpeu5/b2879R2yeeaLXq2b34A/yRVXVl9o+alU/UZacpMw8n3BgDZCVoITp4ci/ OcClCeOGY1W8Q== Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0206A63328 for ; Wed, 10 Aug 2022 17:04:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pSWLGJJ4"; dkim-atps=neutral Received: by mail-pf1-x429.google.com with SMTP id u133so13933069pfc.10 for ; Wed, 10 Aug 2022 08:04:00 -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=kvufxfZHW8jFx4wZYakmIfbO7HxI/zGP6BLC7jNXmrs=; b=pSWLGJJ4e4geNPryAV2dwBatxEftailbcpjpshC26dazVDCxp2Zddd6z0XG1QKiuJo IKRG+gJ5suKhQgqbAmnkZLVmwCe0SwBegMPemTyS8MzWeW9HzCo1CRWrhqkxuRDyiiIN 6FYzMIR+rJ1XFJQPz+WqZhRzn7LTEk4h32eK0S5elrl35QRF9d2LzWLGPk0fgEpgNLT6 ZQto+aOhH/oqyzP1Cbua1/SvSulx5aYh6FwxV2Xom+NBXNB8zXlfHgMKvUm/JyJ3qs33 8GmhUueIabmJcxwJOfDtHHx7WTUNGDMGYXwwj8KDEivEjfvqfTm/P3+EnYMx4yLoQxi8 /P2g== 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=kvufxfZHW8jFx4wZYakmIfbO7HxI/zGP6BLC7jNXmrs=; b=JRErbSRWsN+Y+/dOiZ2GlgXcaXzWSTjnzpdu8jRAIGi6F6wxO7L0jHWC5+HUMXSuGZ H/R2FsgTaaXomU5V9wPOjtzMlsFl5pq8GznF5fkLkxaH4FziTtJhd41VXImyrLGggnVp gJ2Sk2r5IBc9Yn/wwKxVAFmevkS3fNCFHncMsnXK+QxOjywilHux8mRtF7XVAWYS0c3u x8zCTeyJ9Qzfdt4gJzkCHrTktLgBNoCrl4NbhXhunXPls1JEFT7cJlq21vIB7f/2nYZ0 eA9jusdXk5GYLjVkJR/PrZeNFwuI5HO12gayizEnykm93skoyOxuwITgsy+tX8iNshdw lmdg== X-Gm-Message-State: ACgBeo1Ffmzo7vIDcrzIVGEe+aDrHHa5ILPIl3Yl8bSTk/diJzkf1Jp1 tJPh0niRvoWx97wZ/K3V+3kYX2NhDv0= X-Google-Smtp-Source: AA6agR5Y6PDit0QuxTah73xhgHw4zfTrP80aptT50jsG/OMxdHQvfqvWG3IDTGyHguL7EfpoUWK7hg== X-Received: by 2002:a05:6a00:1d84:b0:52f:4a8f:7381 with SMTP id z4-20020a056a001d8400b0052f4a8f7381mr14445905pfw.52.1660143839389; Wed, 10 Aug 2022 08:03:59 -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.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 08:03:59 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Aug 2022 20:33:43 +0530 Message-Id: <20220810150349.414043-3-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 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 Reviewed-by: Laurent Pinchart --- Difference from v7: 1. Nothing 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 5544f49a..04c71fd8 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -26,6 +26,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 e794221a..9ec94708 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -594,6 +594,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()) { @@ -605,6 +607,8 @@ void MainWindow::processHotplug(HotplugEvent *e) int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id())); cameraCombo_->removeItem(camIndex); + + cameraSelectorDialog_->cameraRemoved(camera); } }