@@ -19,10 +19,12 @@
#include <QFileDialog>
#include <QFormLayout>
#include <QString>
+#include <QVBoxLayout>
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);
@@ -40,14 +42,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(captureWidget);
+ 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 */
@@ -64,7 +83,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);
}
@@ -139,16 +158,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_);
+ }
}
}
@@ -18,13 +18,15 @@
#include <QDialog>
#include <QLabel>
#include <QPushButton>
+#include <QVBoxLayout>
+#include <QWidget>
class CameraSelectorDialog : public QDialog
{
Q_OBJECT
public:
CameraSelectorDialog(libcamera::CameraManager *cameraManager,
- bool isScriptRunning, QWidget *parent);
+ bool isScriptRunning, std::string scriptPath, QWidget *parent);
~CameraSelectorDialog() = default;
@@ -62,5 +64,8 @@ private:
QComboBox *cameraIdComboBox_;
QLabel *cameraLocation_;
QLabel *cameraModel_;
+
+ QVBoxLayout *captureWidgetLayout_;
QPushButton *captureScriptButton_;
+ QLabel *scriptPathLabel_;
};
@@ -339,7 +339,8 @@ std::string MainWindow::chooseCamera()
/* Construct the selection dialog, only the first time. */
if (!cameraSelectorDialog_)
- cameraSelectorDialog_ = new CameraSelectorDialog(cm_, scriptRunning, this);
+ cameraSelectorDialog_ = new CameraSelectorDialog(cm_, scriptRunning,
+ scriptPath_, this);
connect(cameraSelectorDialog_, &CameraSelectorDialog::stopCaptureScript,
this, &MainWindow::stopCaptureScript);
Display the path of the selected capture script in a thinner font. Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> --- Difference: 1. The scriptPathLabel_ has a fixed parent now captureWidget src/qcam/cam_select_dialog.cpp | 39 ++++++++++++++++++++++++++++------ src/qcam/cam_select_dialog.h | 7 +++++- src/qcam/main_window.cpp | 3 ++- 3 files changed, 40 insertions(+), 9 deletions(-)