qcam: Decrease minimum width of selector dialog

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@z3ntu.xyz>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Luca Weiss 2023-01-28 17:24:03 +01:00 committed by Laurent Pinchart
parent 5456e02d3f
commit 13645ab0ab

View file

@ -15,7 +15,9 @@
#include <QComboBox> #include <QComboBox>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QFormLayout> #include <QFormLayout>
#include <QGuiApplication>
#include <QLabel> #include <QLabel>
#include <QScreen>
#include <QString> #include <QString>
CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager, CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager,
@ -53,6 +55,14 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag
layout->addRow("Location:", cameraLocation_); layout->addRow("Location:", cameraLocation_);
layout->addRow("Model:", cameraModel_); layout->addRow("Model:", cameraModel_);
layout->addWidget(buttonBox); 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; CameraSelectorDialog::~CameraSelectorDialog() = default;