From 516d2b97334e75170bfaf5da075260d0936ee095 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Fri, 2 Sep 2022 16:58:57 +0200 Subject: [PATCH] Change wallpaper enums to be in namespaces rather than in gadgets Qt 6 no longer allows exporting gadgets with an uppercase name. Namespaces work just as well here, but we unfortunately have this problem also in other places where the solution is less straightforward. --- wallpapers/image/plugin/imagebackend.h | 2 +- wallpapers/image/plugin/imageplugin.cpp | 4 ++-- wallpapers/image/plugin/sortingmode.h | 21 +++++++++---------- .../image/plugin/utils/backgroundtype.h | 17 +++++++-------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/wallpapers/image/plugin/imagebackend.h b/wallpapers/image/plugin/imagebackend.h index 1fc97bcd6..ee9fa02cb 100644 --- a/wallpapers/image/plugin/imagebackend.h +++ b/wallpapers/image/plugin/imagebackend.h @@ -24,7 +24,7 @@ class ImageProxyModel; class SlideModel; class SlideFilterModel; -class ImageBackend : public QObject, public QQmlParserStatus, public SortingMode +class ImageBackend : public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) diff --git a/wallpapers/image/plugin/imageplugin.cpp b/wallpapers/image/plugin/imageplugin.cpp index de773f443..7e88a6ba6 100644 --- a/wallpapers/image/plugin/imageplugin.cpp +++ b/wallpapers/image/plugin/imageplugin.cpp @@ -39,6 +39,6 @@ void ImagePlugin::registerTypes(const char *uri) qmlRegisterAnonymousType("QAbstractItemModel", 1); - qmlRegisterUncreatableType(uri, 2, 0, "BackgroundType", QStringLiteral("error: only enums")); - qmlRegisterUncreatableType(uri, 2, 0, "SortingMode", QStringLiteral("error: only enums")); + qmlRegisterUncreatableMetaObject(BackgroundType::staticMetaObject, uri, 2, 0, "BackgroundType", QStringLiteral("error: only enums")); + qmlRegisterUncreatableMetaObject(SortingMode::staticMetaObject, uri, 2, 0, "SortingMode", QStringLiteral("error: only enums")); } diff --git a/wallpapers/image/plugin/sortingmode.h b/wallpapers/image/plugin/sortingmode.h index 17131d4e1..4193dd9cf 100644 --- a/wallpapers/image/plugin/sortingmode.h +++ b/wallpapers/image/plugin/sortingmode.h @@ -7,19 +7,18 @@ #ifndef SORTINGMODE_H #define SORTINGMODE_H -class SortingMode +namespace SortingMode { - Q_GADGET +Q_NAMESPACE -public: - enum Mode { - Random, - Alphabetical, - AlphabeticalReversed, - Modified, - ModifiedReversed, - }; - Q_ENUM(Mode) +enum Mode { + Random, + Alphabetical, + AlphabeticalReversed, + Modified, + ModifiedReversed, }; +Q_ENUM_NS(Mode) +} #endif diff --git a/wallpapers/image/plugin/utils/backgroundtype.h b/wallpapers/image/plugin/utils/backgroundtype.h index d198d4d98..124542d2d 100644 --- a/wallpapers/image/plugin/utils/backgroundtype.h +++ b/wallpapers/image/plugin/utils/backgroundtype.h @@ -6,15 +6,14 @@ #pragma once -class BackgroundType +namespace BackgroundType { - Q_GADGET +Q_NAMESPACE -public: - enum class Type { - Unknown, - Image, - AnimatedImage, /**< AnimatedImage doesn't support \QQuickImageProvider , @see https://bugreports.qt.io/browse/QTBUG-30524 */ - }; - Q_ENUM(Type) +enum class Type { + Unknown, + Image, + AnimatedImage, /**< AnimatedImage doesn't support \QQuickImageProvider , @see https://bugreports.qt.io/browse/QTBUG-30524 */ }; +Q_ENUM_NS(Type) +}