@@ -6,6 +6,7 @@
<file>file.svg</file>
<file>play-circle.svg</file>
<file>save.svg</file>
+ <file>settings.svg</file>
<file>stop-circle.svg</file>
<file>x-circle.svg</file>
<file>x-square.svg</file>
@@ -255,6 +255,10 @@ int MainWindow::createToolbars()
/* Do not operate directly call toggleScriptAction */
scriptExecAction_ = action;
+ /* Settings Dialog open action */
+ action = toolbar_->addAction(QIcon(":settings.svg"), "Open Settings Window");
+ connect(action, &QAction::triggered, this, &MainWindow::openSettingsDialog);
+
return 0;
}
@@ -341,6 +345,17 @@ void MainWindow::toggleScriptAction(bool showAvailable)
}
}
+void MainWindow::openSettingsDialog()
+{
+ if (settingsDialog_) {
+ settingsDialog_->show();
+ return;
+ }
+
+ settingsDialog_ = std::make_unique<SettingsDialog>(camera_, this);
+ settingsDialog_->show();
+}
+
/* -----------------------------------------------------------------------------
* Camera Selection
*/
@@ -28,6 +28,7 @@
#include "../cam/capture_script.h"
#include "../cam/stream_options.h"
+#include "settings/settings_dialog.h"
#include "viewfinder.h"
class QAction;
@@ -89,6 +90,7 @@ private:
void processViewfinder(libcamera::FrameBuffer *buffer);
void chooseScript();
+ void openSettingsDialog();
void toggleScriptAction(bool showAvailable);
@@ -106,6 +108,8 @@ private:
QString title_;
QTimer titleTimer_;
+ std::unique_ptr<SettingsDialog> settingsDialog_;
+
/* Options */
const OptionsParser::Options &options_;
@@ -23,11 +23,16 @@ qcam_sources = files([
'main.cpp',
'main_window.cpp',
'message_handler.cpp',
+ 'settings/control_frame.cpp',
+ 'settings/controls_tab.cpp',
'viewfinder_qt.cpp',
])
qcam_moc_headers = files([
'main_window.h',
+ 'settings/control_frame.h',
+ 'settings/controls_tab.h',
+ 'settings/settings_dialog.h',
'viewfinder_qt.h',
])
new file mode 100644
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>
+ *
+ * control_frame.cpp - qcam - Control frame
+ */
+
+#include "control_frame.h"
+
+#include <libcamera/controls.h>
+
+#include <QFrame>
+#include <QLabel>
+#include <QString>
+#include <QVBoxLayout>
+
+ControlFrame::ControlFrame(const libcamera::ControlId *control, QWidget *parent)
+ : QFrame(parent), control_(control)
+{
+ /* Main layout for the frame */
+ QVBoxLayout *frameVLayout = new QVBoxLayout(this);
+
+ frameVLayout->addWidget(new QLabel(QString::fromStdString(control_->name())));
+
+ setFrameStyle(QFrame::StyledPanel);
+}
new file mode 100644
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>
+ *
+ * control_frame.h - qcam - Control frame
+ */
+
+#pragma once
+
+#include <libcamera/controls.h>
+
+#include <QFrame>
+#include <QWidget>
+
+class ControlFrame : public QFrame
+{
+ Q_OBJECT
+
+public:
+ ControlFrame(const libcamera::ControlId *control,
+ QWidget *parent);
+ ~ControlFrame() = default;
+
+private:
+ const libcamera::ControlId *control_;
+};
new file mode 100644
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>
+ *
+ * controls_tab.cpp - qcam - Controls Tab
+ */
+
+#include "controls_tab.h"
+
+#include <memory>
+
+#include <libcamera/camera.h>
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QWidget>
+
+#include "control_frame.h"
+
+ControlsTab::ControlsTab(std::shared_ptr<libcamera::Camera> camera_,
+ QWidget *parent)
+ : QWidget(parent)
+{
+ /* Main Layout for the tab */
+ QGridLayout *controlGLayout = new QGridLayout(this);
+
+ int controlCount = 0;
+ for (auto &[control, info] : camera_->controls()) {
+ ControlFrame *controlFrame = new ControlFrame(control, this);
+
+ controlGLayout->addWidget(controlFrame, controlCount / 2,
+ controlCount % 2);
+ controlCount++;
+ }
+
+ if (controlCount == 0)
+ controlGLayout->addWidget(new QLabel("No controls available"));
+}
new file mode 100644
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>
+ *
+ * controls_tab.h - qcam - Controls Tab
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <libcamera/camera.h>
+
+#include <QVBoxLayout>
+#include <QWidget>
+
+class ControlsTab : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ControlsTab(std::shared_ptr<libcamera::Camera> camera_, QWidget *parent);
+ ~ControlsTab() = default;
+};
new file mode 100644
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>
+ *
+ * settings_dialog.h - qcam - Settings Dialog
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <QDialog>
+#include <QTabWidget>
+#include <QVBoxLayout>
+#include <QWidget>
+
+#include "controls_tab.h"
+class SettingsDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ SettingsDialog(std::shared_ptr<libcamera::Camera> camera, QWidget *parent)
+ : QDialog(parent)
+ {
+ /*Main layout for dialog */
+ QVBoxLayout *settingVLayout = new QVBoxLayout(this);
+
+ /* Main TabWidget which would hold other tabs */
+ QTabWidget *settingTabWidget = new QTabWidget;
+ settingVLayout->addWidget(settingTabWidget);
+
+ ControlsTab *controlsTab = new ControlsTab(camera, this);
+ settingTabWidget->addTab(controlsTab, "Controls");
+
+ setWindowTitle("Settings");
+ }
+ ~SettingsDialog() = default;
+};
Implement a Settings QDialog and add its buttonon the toolbar. We only create one instance of the SettingsWindow and its created the first time user clicks on the button. This Setting Dialog implements a QTabWidget which resides in a QVBoxLayout so that it spans the whole QDialog. The QTabWidget currently only holds the control tab. This Tab lays out the respective ControlFrames in a QGridLayout listing two controls in each row. ControlFrames handles the UI for each respective controls. It also implements the QVBoxLayout as for future when we want to add more information in each frame. Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> --- src/qcam/assets/feathericons/feathericons.qrc | 1 + src/qcam/main_window.cpp | 15 +++++++ src/qcam/main_window.h | 4 ++ src/qcam/meson.build | 5 +++ src/qcam/settings/control_frame.cpp | 26 +++++++++++++ src/qcam/settings/control_frame.h | 26 +++++++++++++ src/qcam/settings/controls_tab.cpp | 38 ++++++++++++++++++ src/qcam/settings/controls_tab.h | 24 ++++++++++++ src/qcam/settings/settings_dialog.h | 39 +++++++++++++++++++ 9 files changed, 178 insertions(+) create mode 100644 src/qcam/settings/control_frame.cpp create mode 100644 src/qcam/settings/control_frame.h create mode 100644 src/qcam/settings/controls_tab.cpp create mode 100644 src/qcam/settings/controls_tab.h create mode 100644 src/qcam/settings/settings_dialog.h