summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-08-08 09:48:39 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-08-08 10:39:38 +0000
commit9b531f23e619454e34a1f93b5fee03ef06a8ef81 (patch)
tree7c8a57dc2fc1a99cc4c6ba31002ab5de6db0648d
parent4faa14cb00dd879e734fbd75d1966548accbc4b7 (diff)
QtMultimedia: fix duplicated type exports to QML
For some of the QtMultimedia types we need to export both the type as a value type, and also its enums into a namespace. With the pre-existing approach this results into duplicated entries in the qmltypes file, which confuses Qt Design Studio. Fix it by introducing a dummy derived class for each of such types, and using this derived type to export the enums. This patch fixes exports for the following classes: * QAudioDevice * QCameraDevice * QMediaFormat * QMediaMetaData Fixes: QTBUG-115360 Fixes: QTBUG-115563 Fixes: QTBUG-115564 Fixes: QTBUG-115566 Change-Id: I9073ec8317e1ef4f5f2a613406c750f1d1cd6d4e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 16ab1dd1d13b6644476e2bc33ac9cb2310903c32) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/multimediaquick/qtmultimediaquicktypes_p.h36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/multimediaquick/qtmultimediaquicktypes_p.h b/src/multimediaquick/qtmultimediaquicktypes_p.h
index 93aed7193..87c3a0e66 100644
--- a/src/multimediaquick/qtmultimediaquicktypes_p.h
+++ b/src/multimediaquick/qtmultimediaquicktypes_p.h
@@ -63,10 +63,17 @@ struct QMediaMetaDataForeign
QML_NAMED_ELEMENT(mediaMetaData)
};
+// To prevent the same type from being exported twice into qmltypes
+// (for value type and for the enums)
+struct QMediaMetaDataDerived : public QMediaMetaData
+{
+ Q_GADGET
+};
+
namespace QMediaMetaDataNamespaceForeign
{
Q_NAMESPACE
- QML_FOREIGN_NAMESPACE(QMediaMetaData)
+ QML_FOREIGN_NAMESPACE(QMediaMetaDataDerived)
QML_NAMED_ELEMENT(MediaMetaData)
};
@@ -98,10 +105,17 @@ struct QAudioDeviceForeign
QML_NAMED_ELEMENT(audioDevice)
};
+// To prevent the same type from being exported twice into qmltypes
+// (for value type and for the enums)
+struct QAudioDeviceDerived : public QAudioDevice
+{
+ Q_GADGET
+};
+
namespace QAudioDeviceNamespaceForeign
{
Q_NAMESPACE
- QML_FOREIGN_NAMESPACE(QAudioDevice)
+ QML_FOREIGN_NAMESPACE(QAudioDeviceDerived)
QML_NAMED_ELEMENT(AudioDevice)
};
@@ -112,10 +126,17 @@ struct QCameraDeviceForeign
QML_NAMED_ELEMENT(cameraDevice)
};
+// To prevent the same type from being exported twice into qmltypes
+// (for value type and for the enums)
+struct QCameraDeviceDerived : public QCameraDevice
+{
+ Q_GADGET
+};
+
namespace QCameraDeviceNamespaceForeign
{
Q_NAMESPACE
- QML_FOREIGN_NAMESPACE(QCameraDevice)
+ QML_FOREIGN_NAMESPACE(QCameraDeviceDerived)
QML_NAMED_ELEMENT(CameraDevice)
};
@@ -126,10 +147,17 @@ struct QMediaFormatForeign
QML_NAMED_ELEMENT(mediaFormat)
};
+// To prevent the same type from being exported twice into qmltypes
+// (for value type and for the enums)
+struct QMediaFormatDerived : public QMediaFormat
+{
+ Q_GADGET
+};
+
namespace QMediaFormatNamespaceForeign
{
Q_NAMESPACE
- QML_FOREIGN_NAMESPACE(QMediaFormat)
+ QML_FOREIGN_NAMESPACE(QMediaFormatDerived)
QML_NAMED_ELEMENT(MediaFormat)
};