From patchwork Wed Aug 3 17:55:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16956 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 2FF02C3272 for ; Wed, 3 Aug 2022 17:55:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D6AAA6330F; Wed, 3 Aug 2022 19:55:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659549329; bh=Zk7ObCaikQB0Rr/hkHevWBkMzOIDVn8qxqSX+MzNb+g=; 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=t9b0exwnBGKBHwv21mAFmTtqr4Qkf/vM16X0+HEIoDfWZ+uH5Ya7JQpXNSc8ktpXU O4Ockhd/zfjtgZTCa98u/0NfDK03cjz4RTHK2xy7P+ASGo4fZqdDAbDHPhFKUcDxHi Uc9r0z2wBzq2APNhuPbkWJ7ffuFKBrvecNI8vvVRVjPAG+7VpGL0gqMgfGyWLHOgLu k9I2vqKxFhoj+KtzE/zcwNRlBynft9+TknwOrmuvuTv/SA4APEYUd6UqYyl2dRNBLH 6+fTiYZ8c/2+2T/1R6nD0u8+kaVO9JV0Et2+AQ7Lx6UKaXNe2KfEz4JICqXxaxVTzD XuOPvQ5VhxsvA== Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A5E9D63314 for ; Wed, 3 Aug 2022 19:55:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Up5ZLgn9"; dkim-atps=neutral Received: by mail-pj1-x1035.google.com with SMTP id p14-20020a17090a74ce00b001f4d04492faso2901617pjl.4 for ; Wed, 03 Aug 2022 10:55:27 -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=IW+h5cRdAHnoLrIKdaIkEIUEf3/NheN/VmD+zgCaZpE=; b=Up5ZLgn9kJJ7hyCLjksXktJZzXDvzONCbUyqxhPtz8R7qe7FdQKmSAfGxLBZXZ6NwN KAQfzfZZNdIBYuDVlkjTsF7NgHwyARDKHPV9lqYMkGhmhw90trT+U4S01VMNTO+Cq9bi +Oi6Roa6324P6+gxmmHwZsnVGqw2X31hRy5DKaUavry+hAEFvDxhPNM+TretpbNE2TRo jqdLmondGTftQLXxFLGG5huQz/AEiz2tQ79Z9UN04Artvs4cmcHfddfJfIalEogulw3u n6+fcYw7yR2TSSXg2xiyP/9UWkQWFWm1G/W23Dam/sFKLWSNU2xuIy5lvJj4uiA8wYiZ 3ZKg== 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=IW+h5cRdAHnoLrIKdaIkEIUEf3/NheN/VmD+zgCaZpE=; b=0m3W3Pdv3KA0zMqBQxQiBwM2jHpUkJjNytRrPaIipPTsIjE56rOcsfSGycET5RLIYd uL+k05zluZhL0wcBzhxAyFU6gY9b1KLhVzul36OFLYV6xGWjwSCnJbM8111641joYz7J ubGc3V7iBAIc/JxHfZ7WpWS7GpGU4fih/8xyHO0h6oJXBcnKw1x6DfmmigApxVDnkWv7 yfQYlo+apXoeMe2Dx3YohsZIaY9y81BOHC1XDLCnYP5Mg6nAvu4CIO1bHi8IE/2qluLY MXRR8ZegHifcXPgbbOrRfqJtzUPZQuY50M8YNKgYrqoJzRuNmhQ2TrmvQcNXEFEu7pyu zDMw== X-Gm-Message-State: ACgBeo3L6N4xCYcVYWA0w14pju335qv8AICldDUEy85qsNOrFvkbTgqs eaH3ZtsxGZBGsB3Ca5q5xRPMTeGDoz4= X-Google-Smtp-Source: AA6agR5liS4sUwTq0tDRCmHVoIFReUGJ8mT10ZsLhd8Qf/DDItBmD6LokdNgH9cus8/Sns6f93LJkQ== X-Received: by 2002:a17:902:b605:b0:16d:3497:775d with SMTP id b5-20020a170902b60500b0016d3497775dmr27254994pls.1.1659549325916; Wed, 03 Aug 2022 10:55:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Aug 2022 10:55:25 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 23:25:14 +0530 Message-Id: <20220803175517.175332-2-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 1/4] qcam: Use QDialog for selection of cameras 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 we use QInputDialog convenience dialogs to allow the user to select a camera. This doesn't allow adding of more information (such as camera location, model etc). Create a QDialog with a QFormLayout that shows a QComboBox with camera Ids. Use a QButtonBox to provide buttons for accepting and cancelling the action. Signed-off-by: Utkarsh Tiwari --- src/qcam/main_window.cpp | 47 ++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 7433d647..7761a6c6 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -16,7 +16,10 @@ #include #include +#include +#include #include +#include #include #include #include @@ -291,23 +294,43 @@ void MainWindow::switchCamera(int index) std::string MainWindow::chooseCamera() { QStringList cameras; - bool result; - - /* If only one camera is available, use it automatically. */ - if (cm_->cameras().size() == 1) - return cm_->cameras()[0]->id(); + std::string result; /* Present a dialog box to pick a camera. */ + QDialog *cameraSelectDialog = new QDialog(this); + + /* Setup a QComboBox to display camera Ids. */ for (const std::shared_ptr &cam : cm_->cameras()) - cameras.append(QString::fromStdString(cam->id())); + cameras.push_back(QString::fromStdString(cam->id())); + + QComboBox *cameraIdComboBox = new QComboBox; + cameraIdComboBox->addItems(cameras); + + /* Setup QDialogButtonBox. */ + QDialogButtonBox *dialogButtonBox = new QDialogButtonBox; + dialogButtonBox->addButton(QDialogButtonBox::Cancel); + dialogButtonBox->addButton(QDialogButtonBox::Ok); + + connect(dialogButtonBox, &QDialogButtonBox::accepted, + this, [&]() { + result = cameraIdComboBox->currentText().toStdString(); + cameraSelectDialog->accept(); + }); + + connect(dialogButtonBox, &QDialogButtonBox::rejected, + this, [&]() { + result = std::string(); + cameraSelectDialog->reject(); + }); + + /* Setup the layout for the dialog. */ + QFormLayout *cameraSelectLayout = new QFormLayout(cameraSelectDialog); + cameraSelectLayout->addRow("Camera: ", cameraIdComboBox); + cameraSelectLayout->addWidget(dialogButtonBox); - QString id = QInputDialog::getItem(this, "Select Camera", - "Camera:", cameras, 0, - false, &result); - if (!result) - return std::string(); + cameraSelectDialog->exec(); - return id.toStdString(); + return result; } int MainWindow::openCamera()