[PATCH v2] qcam: Decrease minimum width of selector dialog
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu Sep 5 16:10:45 CEST 2024
From: Luca Weiss <luca at z3ntu.xyz>
On phone screens the default width is too wide, so the OK button cannot
be clicked.
Fix this by decreasing the minimum size of the dialog so it fits nicely.
Signed-off-by: Luca Weiss <luca at z3ntu.xyz>
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
I found this patch in a branch in my tree. The v2 incorporates the
change I proposed in the review of v1. The discussion died out after
that, so I thought posting a new version could help getting it merged.
I've dropped the R-b tags as the implementation has changed.
---
Changes since v1:
- Make the minimum width depend on the screen geometry
- Only decrease the width
---
src/apps/qcam/cam_select_dialog.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/apps/qcam/cam_select_dialog.cpp b/src/apps/qcam/cam_select_dialog.cpp
index c51f59745e48..6b6d0713cc3d 100644
--- a/src/apps/qcam/cam_select_dialog.cpp
+++ b/src/apps/qcam/cam_select_dialog.cpp
@@ -15,7 +15,9 @@
#include <QComboBox>
#include <QDialogButtonBox>
#include <QFormLayout>
+#include <QGuiApplication>
#include <QLabel>
+#include <QScreen>
#include <QString>
CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager,
@@ -53,6 +55,14 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag
layout->addRow("Location:", cameraLocation_);
layout->addRow("Model:", cameraModel_);
layout->addWidget(buttonBox);
+
+ /*
+ * Decrease the minimum width of dialog to fit on narrow screens, with a
+ * 20 pixels margin.
+ */
+ QRect screenGeometry = qGuiApp->primaryScreen()->availableGeometry();
+ if (screenGeometry.width() < minimumWidth())
+ setMinimumWidth(screenGeometry.width() - 20);
}
CameraSelectorDialog::~CameraSelectorDialog() = default;
base-commit: f75b8dd26feaca86701704390dea18c71e2f0350
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list