From 2f94e93334af366589fb2c5dcbff33a0694b6074 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 28 Jan 2023 15:40:34 +0900 Subject: [PATCH] "New Class" wizard: Add QML_ELEMENT checkbox Change-Id: I219b539ba5f36c895be1042a74571e54a0c67ec6 Reviewed-by: Reviewed-by: Christian Kandeler --- share/qtcreator/templates/wizards/classes/cpp/file.h | 3 +++ .../templates/wizards/classes/cpp/wizard.json | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/share/qtcreator/templates/wizards/classes/cpp/file.h b/share/qtcreator/templates/wizards/classes/cpp/file.h index df35bd553c2..77f1b213516 100644 --- a/share/qtcreator/templates/wizards/classes/cpp/file.h +++ b/share/qtcreator/templates/wizards/classes/cpp/file.h @@ -32,6 +32,9 @@ class %{CN} @if '%{AddQObjectMacro}' Q_OBJECT @endif +@if '%{AddQmlElementMacro}' + QML_ELEMENT +@endif public: @if '%{Base}' === 'QObject' || %{JS: Cpp.hasQObjectParent('%{Base}')} explicit %{CN}(QObject *parent = nullptr); diff --git a/share/qtcreator/templates/wizards/classes/cpp/wizard.json b/share/qtcreator/templates/wizards/classes/cpp/wizard.json index 33ba82355a9..9317c175981 100644 --- a/share/qtcreator/templates/wizards/classes/cpp/wizard.json +++ b/share/qtcreator/templates/wizards/classes/cpp/wizard.json @@ -146,6 +146,17 @@ "checked": "%{JS: [ 'QObject', 'QWidget', 'QMainWindow', 'QDeclarativeItem', 'QQuickItem'].indexOf(value('Base')) >= 0 }" } }, + { + "name": "AddQmlElementMacro", + "trDisplayName": "Add QML_ELEMENT", + "type": "CheckBox", + "data": + { + "checkedValue": "AddQmlElementMacro", + "uncheckedValue": "", + "checked": "%{JS: ['QQuickItem'].indexOf(value('Base')) >= 0 }" + } + }, { "name": "Sp2", "type": "Spacer"