From patchwork Tue Aug 9 20:50:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17059 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 62AFABE173 for ; Tue, 9 Aug 2022 20:53:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1D94363334; Tue, 9 Aug 2022 22:53:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660078402; bh=XyTA9Gh1d2o5gLaO6sM827NF2rOSS/csQrznwpcDSK4=; 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=kkvMXchCie3N2uYd763caObDofERbs/664iqnoEwbNjgPDxXpDr982aXDzU1bAWEP b0h475JmfvyRo03uSnKjf+NlwK6CTtRp6w9uRQkPDdlKJ5ut8WoRzf0UWMuFhmfK+a kX8l5cFqAD3MY6w+++3oRI/o4EwB/D0SaHiNRCS6Y4aUbhei+nEwYE50VH989OTzLM YA/BGJlxknTJapsMe1PUnZ2fd91WCRO7516+MLH4rwv3xWf3X8MJhze7WTHcLaunOZ vnrnunZDvH6d5zpb09r/tbFjqqFDTk1+aIl9Pm0Sf/3/ZY5p/Opj+/b/mg7qzvDdvX dGXDAeYyUBdrQ== Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F61063328 for ; Tue, 9 Aug 2022 22:53:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Goy0GOSY"; dkim-atps=neutral Received: by mail-pl1-x62d.google.com with SMTP id o3so12435519ple.5 for ; Tue, 09 Aug 2022 13:53:19 -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=OmavJLYphfFZBhTcOP/Gxk0CM7TEQuFfx5FQ9o/vXsI=; b=Goy0GOSYNIE/yY+g+K4FQP3JIh4FpR0N2zylI9G9roo23EBSIM+tYNMtIq+M4Fl/Wg NFmjXPXqESYG9AtSwf14J7ihPZTXMZFHEpXlvsSfidrV9wAtoAC6fBzpHH9GNxg/wHpq 1i2pIn6dpFCiCMnKZ87kx15BOZYsw6/x1UDgAwjTflcSCT2ocvZaBuoVhPdxhhk3ZYDl XVpobKSB2YTEnZi8VKxdZ4DJrhpXW6kgOGoMp95ngNJkaoU4n0P9Ti4otFDeB9PfBv13 mzc9HYoYl7mRL9Nc8IWTDiY62oTNhtfxer0bHrOmJzQ8Pq0U9FJHm/+QmWBtQT0yt4gc f9tA== 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=OmavJLYphfFZBhTcOP/Gxk0CM7TEQuFfx5FQ9o/vXsI=; b=Rc7YPG4oGI73SpS/95bXxQHRqbxiapgv5eIblMAiHyoX1Ys0oCNftQLUkkZLG2cdIz puwZwkU8bT/95qe3XJsYM+Ki8S2kTp+J5zxVSfq0WV/30+RPOHIgUsjfH5f6y59witOP vM2MqlyD2sdA7lWy2HxtAA+OCxS4MtvUQmEvbbEGB/pc6+1u077qvS973hcH8Pxc6/7D LRu7dobKWCR5NNKtiPlgqwcoVZsmlKTTSvwnnF4ow9YFftSzviR1PeBjmSW9/4hz14kf aRk9C5zNK0Bs85Pbh4qyJvyFsWg2RwWae5FMBs2qgU6U2RVM/wLcZ1TlHUR0NwjtWWrC UOnA== X-Gm-Message-State: ACgBeo2WV6G0kJ4ijOpW5RNx+uSkUYQSnT1Hm20pOuBaALJT1NtQ+/xx 1x4Ok/BQhZzkO24xQusT6jSJEBe9zjg= X-Google-Smtp-Source: AA6agR7fkgHTKzxfEznfu19AWEqR9AvZROS19j3KJsCh1+m6Sty5OsF1dZgcF8DyxlvTkVG9MfU8wA== X-Received: by 2002:a17:903:1104:b0:16c:2f71:7803 with SMTP id n4-20020a170903110400b0016c2f717803mr25590962plh.101.1660078398468; Tue, 09 Aug 2022 13:53:18 -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.53.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 13:53:18 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Aug 2022 02:20:41 +0530 Message-Id: <20220809205042.344923-8-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 7/8] qcam: CamSelectDialog: Display Capture script path 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" Display the path of the selected capture script in a thinner font. Signed-off-by: Utkarsh Tiwari --- src/qcam/cam_select_dialog.cpp | 38 +++++++++++++++++++++++++++------- src/qcam/cam_select_dialog.h | 8 ++++++- src/qcam/main_window.cpp | 3 ++- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp index f3df9970..5a9de08c 100644 --- a/src/qcam/cam_select_dialog.cpp +++ b/src/qcam/cam_select_dialog.cpp @@ -20,8 +20,9 @@ #include CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager, - bool isScriptRunning, QWidget *parent) - : QDialog(parent), cm_(cameraManager), isScriptRunning_(isScriptRunning) + bool isScriptRunning, std::string scriptPath, QWidget *parent) + : QDialog(parent), cm_(cameraManager), + isScriptRunning_(isScriptRunning), scriptPath_(scriptPath) { /* Use a QFormLayout for the dialog. */ QFormLayout *layout = new QFormLayout(this); @@ -39,14 +40,31 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag connect(cameraIdComboBox_, &QComboBox::currentTextChanged, this, &CameraSelectorDialog::handleCameraChange); + /* Setup widget for capture script button. */ + QWidget *captureWidget = new QWidget; + captureWidgetLayout_ = new QVBoxLayout(captureWidget); + captureWidgetLayout_->setMargin(0); + captureScriptButton_ = new QPushButton; connect(captureScriptButton_, &QPushButton::clicked, this, &CameraSelectorDialog::handleCaptureScriptButton); + captureWidgetLayout_->addWidget(captureScriptButton_); + + /* Use a thinner font to indicate script info. */ + QFont smallFont; + smallFont.setWeight(QFont::Thin); + + scriptPathLabel_ = new QLabel; + scriptPathLabel_->setFont(smallFont); + scriptPathLabel_->setWordWrap(true); /* Display the action that would be performed when button is clicked. */ - if (isScriptRunning_) + if (isScriptRunning_) { captureScriptButton_->setText("Stop"); - else + + scriptPathLabel_->setText(QString::fromStdString(scriptPath_)); + captureWidgetLayout_->addWidget(scriptPathLabel_); + } else captureScriptButton_->setText("Open"); /* Setup the QDialogButton Box */ @@ -63,7 +81,7 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag layout->addRow("Camera:", cameraIdComboBox_); layout->addRow("Location:", cameraLocation_); layout->addRow("Model:", cameraModel_); - layout->addRow("Capture Script:", captureScriptButton_); + layout->addRow("Capture Script:", captureWidget); layout->addWidget(buttonBox); } @@ -138,16 +156,22 @@ void CameraSelectorDialog::handleCaptureScriptButton() Q_EMIT stopCaptureScript(); isScriptRunning_ = false; captureScriptButton_->setText("Open"); + + captureWidgetLayout_->removeWidget(scriptPathLabel_); } else { selectedScriptPath_ = QFileDialog::getOpenFileName(this, "Run Capture Script", QDir::currentPath(), "Capture Script (*.yaml)") .toStdString(); - if (!selectedScriptPath_.empty()) + if (!selectedScriptPath_.empty()) { captureScriptButton_->setText("Loaded"); - else + scriptPathLabel_->setText(QString::fromStdString(selectedScriptPath_)); + captureWidgetLayout_->addWidget(scriptPathLabel_); + } else { captureScriptButton_->setText("Open"); + captureWidgetLayout_->removeWidget(scriptPathLabel_); + } } } diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index 56d90596..84904640 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -18,17 +18,20 @@ #include #include #include +#include #include #include #include #include +#include +#include class CameraSelectorDialog : public QDialog { Q_OBJECT public: CameraSelectorDialog(libcamera::CameraManager *cameraManager, - bool isScriptRunning, QWidget *parent); + bool isScriptRunning, std::string scriptPath, QWidget *parent); ~CameraSelectorDialog() = default; @@ -66,5 +69,8 @@ private: QComboBox *cameraIdComboBox_; QLabel *cameraLocation_; QLabel *cameraModel_; + + QVBoxLayout *captureWidgetLayout_; QPushButton *captureScriptButton_; + QLabel *scriptPathLabel_ = new QLabel; }; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index d73fb42a..f2e3c576 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -337,7 +337,8 @@ std::string MainWindow::chooseCamera() bool scriptRunning = script_ != nullptr; /* Construct the selection dialog, unconditionally. */ - cameraSelectorDialog_ = new CameraSelectorDialog(cm_, scriptRunning, this); + cameraSelectorDialog_ = new CameraSelectorDialog(cm_, scriptRunning, + scriptPath_, this); connect(cameraSelectorDialog_, &CameraSelectorDialog::stopCaptureScript, this, &MainWindow::stopCaptureScript);