summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/camera/imagesettings.cpp
diff options
context:
space:
mode:
authorKai Köhne <kai.koehne@qt.io>2022-08-30 20:30:26 +0200
committerKai Köhne <kai.koehne@qt.io>2022-09-05 11:21:58 +0200
commitc3081f86f4fc53509d853a2b88aff88df8c55d87 (patch)
treecf324600f90e3c2bbebca46023d5363288141d7d /examples/multimedia/camera/imagesettings.cpp
parent8158647414e9f706a38233f4b7299d695aaeed18 (diff)
Let examples show up in Qt Creator again
Fix an issue where the relative paths in the generated examples-manifest.xml did miss the parent directory, effectively blocking the examples from being shown in the Qt Creator Welcome screen. This broke in commit c403e775f60a, where the exampledirs path was changed from "../../../examples" to "../../../examples/multimedia" and "../../../examples/multimediawidgets". This made qdoc miss the "multimedia" and "multimediawidgets" directories in the generated paths. To fix this, the patch * moves all the multimediawidgets examples to multimedia * sets examplesinstallpath to "multimedia" The unification of directories is needed because there can be only one examplesinstallpath per qdoc project. Pick-to: 6.4 Fixes: QTBUG-104943 Change-Id: I4d1b1f857563ec23b4d60028ca08d0470ba96298 Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Diffstat (limited to 'examples/multimedia/camera/imagesettings.cpp')
-rw-r--r--examples/multimedia/camera/imagesettings.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/examples/multimedia/camera/imagesettings.cpp b/examples/multimedia/camera/imagesettings.cpp
new file mode 100644
index 000000000..a107cc62d
--- /dev/null
+++ b/examples/multimedia/camera/imagesettings.cpp
@@ -0,0 +1,83 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "imagesettings.h"
+#include "ui_imagesettings.h"
+
+#include <QComboBox>
+#include <QDebug>
+#include <QImageCapture>
+#include <QCamera>
+#include <QMediaCaptureSession>
+
+ImageSettings::ImageSettings(QImageCapture *imageCapture, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::ImageSettingsUi),
+ imagecapture(imageCapture)
+{
+ ui->setupUi(this);
+
+ //image codecs
+ ui->imageCodecBox->addItem(tr("Default image format"), QVariant(QString()));
+ const auto supportedImageFormats = QImageCapture::supportedFormats();
+ for (const auto &f : supportedImageFormats) {
+ QString description = QImageCapture::fileFormatDescription(f);
+ ui->imageCodecBox->addItem(QImageCapture::fileFormatName(f) + ": " + description, QVariant::fromValue(f));
+ }
+
+ ui->imageQualitySlider->setRange(0, int(QImageCapture::VeryHighQuality));
+
+ ui->imageResolutionBox->addItem(tr("Default Resolution"));
+ const QList<QSize> supportedResolutions = imagecapture->captureSession()->camera()->cameraDevice().photoResolutions();
+ for (const QSize &resolution : supportedResolutions) {
+ ui->imageResolutionBox->addItem(QString("%1x%2").arg(resolution.width()).arg(resolution.height()),
+ QVariant(resolution));
+ }
+
+ selectComboBoxItem(ui->imageCodecBox, QVariant::fromValue(imagecapture->fileFormat()));
+ selectComboBoxItem(ui->imageResolutionBox, QVariant(imagecapture->resolution()));
+ ui->imageQualitySlider->setValue(imagecapture->quality());
+}
+
+ImageSettings::~ImageSettings()
+{
+ delete ui;
+}
+
+void ImageSettings::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void ImageSettings::applyImageSettings() const
+{
+ imagecapture->setFileFormat(boxValue(ui->imageCodecBox).value<QImageCapture::FileFormat>());
+ imagecapture->setQuality(QImageCapture::Quality(ui->imageQualitySlider->value()));
+ imagecapture->setResolution(boxValue(ui->imageResolutionBox).toSize());
+}
+
+QVariant ImageSettings::boxValue(const QComboBox *box) const
+{
+ int idx = box->currentIndex();
+ if (idx == -1)
+ return QVariant();
+
+ return box->itemData(idx);
+}
+
+void ImageSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
+{
+ for (int i = 0; i < box->count(); ++i) {
+ if (box->itemData(i) == value) {
+ box->setCurrentIndex(i);
+ break;
+ }
+ }
+}