[libcamera-devel,04/11] qcam: ControlsTab: Implement QScrollArea
diff mbox series

Message ID 20220715191400.890976-5-utkarsh02t@gmail.com
State Superseded
Headers show
Series
  • Introduce control interaction to qcam
Related show

Commit Message

Utkarsh Tiwari July 15, 2022, 7:13 p.m. UTC
If the camera has lots of controls it can overrun the screen.
Fix this by using a QScrollArea.

Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>
---
 src/qcam/settings/controls_tab.cpp | 9 +++++++--
 src/qcam/settings/controls_tab.h   | 3 ++-
 2 files changed, 9 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/src/qcam/settings/controls_tab.cpp b/src/qcam/settings/controls_tab.cpp
index 0777d708..30899783 100644
--- a/src/qcam/settings/controls_tab.cpp
+++ b/src/qcam/settings/controls_tab.cpp
@@ -13,6 +13,7 @@ 
 
 #include <QGridLayout>
 #include <QLabel>
+#include <QScrollArea>
 #include <QWidget>
 
 #include "control_frame.h"
@@ -21,10 +22,11 @@  using namespace libcamera;
 
 ControlsTab::ControlsTab(std::shared_ptr<libcamera::Camera> camera_,
 			 QWidget *parent)
-	: QWidget(parent), controlList_(std::make_shared<ControlList>())
+	: QScrollArea(parent), controlList_(std::make_shared<ControlList>())
 {
+	QWidget *containerWidget = new QWidget(this);
 	/* Main Layout for the tab */
-	QGridLayout *controlGLayout = new QGridLayout(this);
+	QGridLayout *controlGLayout = new QGridLayout(containerWidget);
 
 	int controlCount = 0;
 	for (auto &[control, info] : camera_->controls()) {
@@ -39,6 +41,9 @@  ControlsTab::ControlsTab(std::shared_ptr<libcamera::Camera> camera_,
 
 	if (controlCount == 0)
 		controlGLayout->addWidget(new QLabel("No controls available"));
+
+	/* Set widget and policies for the scrollarea */
+	setWidget(containerWidget);
 }
 
 /* -----------------------------------------------------------------------------
diff --git a/src/qcam/settings/controls_tab.h b/src/qcam/settings/controls_tab.h
index 5bac7d48..28efd35e 100644
--- a/src/qcam/settings/controls_tab.h
+++ b/src/qcam/settings/controls_tab.h
@@ -11,10 +11,11 @@ 
 
 #include <libcamera/camera.h>
 
+#include <QScrollArea>
 #include <QVBoxLayout>
 #include <QWidget>
 
-class ControlsTab : public QWidget
+class ControlsTab : public QScrollArea
 {
 	Q_OBJECT