From 50fe4051e34781f45f21e698927eba6b02484d5f Mon Sep 17 00:00:00 2001 From: Ali Kianian Date: Wed, 22 Nov 2023 15:39:35 +0200 Subject: QmlDesigner: Add the Collection Singleton to the QDS template Change-Id: I8bad907766dfa0f630cee935d2b587fc613b0922 Reviewed-by: Mahmoud Badri Reviewed-by: Qt CI Patch Build Bot --- .../projects/application-3d/wizard.json | 8 ++++++ .../projects/application/wizard.json | 8 ++++++ .../projects/desktop-launcher/wizard.json | 8 ++++++ .../name/CMakeLists.importmodule.txt.tpl | 1 + .../projects/shared-plugin/name/DataStore.json.tpl | 30 ++++++++++++++++++++++ .../projects/shared-plugin/name/DataStore.qml.tpl | 12 +++++++++ .../shared-plugin/name/importmodule.qmldir.tpl | 2 +- .../projects/shared-plugin/name/qmldir | 1 + .../projects/qtquickapplication/wizard.json | 10 ++++++++ 9 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/DataStore.json.tpl create mode 100644 share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/DataStore.qml.tpl diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/application-3d/wizard.json b/share/qtcreator/qmldesigner/studio_templates/projects/application-3d/wizard.json index d5b1fef1e4..232dfd4319 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/application-3d/wizard.json +++ b/share/qtcreator/qmldesigner/studio_templates/projects/application-3d/wizard.json @@ -367,6 +367,14 @@ "source": "../shared-plugin/name/Constants.qml.tpl", "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/Constants.qml" }, + { + "source": "../shared-plugin/name/DataStore.json.tpl", + "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DataStore.json" + }, + { + "source": "../shared-plugin/name/DataStore.qml.tpl", + "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DataStore.qml" + }, { "source": "../shared-plugin/name/DirectoryFontLoader.qml.tpl", "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DirectoryFontLoader.qml" diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/application/wizard.json b/share/qtcreator/qmldesigner/studio_templates/projects/application/wizard.json index 0708838a5a..2c5d606750 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/application/wizard.json +++ b/share/qtcreator/qmldesigner/studio_templates/projects/application/wizard.json @@ -380,6 +380,14 @@ "source": "../shared-plugin/name/Constants.qml.tpl", "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/Constants.qml" }, + { + "source": "../shared-plugin/name/DataStore.json.tpl", + "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DataStore.json" + }, + { + "source": "../shared-plugin/name/DataStore.qml.tpl", + "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DataStore.qml" + }, { "source": "../shared-plugin/name/DirectoryFontLoader.qml.tpl", "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DirectoryFontLoader.qml" diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/desktop-launcher/wizard.json b/share/qtcreator/qmldesigner/studio_templates/projects/desktop-launcher/wizard.json index 913eb0bf28..81bbcb73f2 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/desktop-launcher/wizard.json +++ b/share/qtcreator/qmldesigner/studio_templates/projects/desktop-launcher/wizard.json @@ -367,6 +367,14 @@ "source": "../shared-plugin/name/Constants.qml.tpl", "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/Constants.qml" }, + { + "source": "../shared-plugin/name/DataStore.json.tpl", + "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DataStore.json" + }, + { + "source": "../shared-plugin/name/DataStore.qml.tpl", + "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DataStore.qml" + }, { "source": "../shared-plugin/name/DirectoryFontLoader.qml.tpl", "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DirectoryFontLoader.qml" diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/CMakeLists.importmodule.txt.tpl b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/CMakeLists.importmodule.txt.tpl index 517b91355a..5606f3c7b1 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/CMakeLists.importmodule.txt.tpl +++ b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/CMakeLists.importmodule.txt.tpl @@ -13,6 +13,7 @@ qt6_add_qml_module(%{ImportModuleName} RESOURCE_PREFIX "/qt/qml" QML_FILES Constants.qml + DataStore.qml DirectoryFontLoader.qml EventListModel.qml EventListSimulator.qml diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/DataStore.json.tpl b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/DataStore.json.tpl new file mode 100644 index 0000000000..8ebda6fb7e --- /dev/null +++ b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/DataStore.json.tpl @@ -0,0 +1,30 @@ +{ + "book": [ + { + "author": "Nigel Rees", + "category": "reference", + "price": 8.95, + "title": "Sayings of the Century" + }, + { + "author": "Evelyn Waugh", + "category": "fiction", + "price": 12.99, + "title": "Sword of Honor" + }, + { + "author": "Herman Melville", + "category": "fiction", + "isbn": "0-553-21311-3", + "price": 8.99, + "title": "Moby Dick" + }, + { + "author": "J. R. R. Tolkien", + "category": "fiction", + "isbn": "0-395-19395-8", + "price": 22.99, + "title": "The Lord of the Rings" + } + ] +} diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/DataStore.qml.tpl b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/DataStore.qml.tpl new file mode 100644 index 0000000000..0f9c24373c --- /dev/null +++ b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/DataStore.qml.tpl @@ -0,0 +1,12 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +pragma Singleton +import QtQuick.Studio.Utils + +JsonListModel { + property alias allModels: models + id: models + + source: Qt.resolvedUrl("DataStore.json") +} diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/importmodule.qmldir.tpl b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/importmodule.qmldir.tpl index d374931eab..a0ec2f17cf 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/importmodule.qmldir.tpl +++ b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/importmodule.qmldir.tpl @@ -1,6 +1,6 @@ Module %{ImportModuleName} +singleton DataStore 1.0 DataStore.qml singleton Constants 1.0 Constants.qml EventListSimulator 1.0 EventListSimulator.qml EventListModel 1.0 EventListModel.qml DirectoryFontLoader 1.0 DirectoryFontLoader.qml - diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/qmldir b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/qmldir index 3ba5adcc64..b5924a433c 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/qmldir +++ b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/qmldir @@ -1,4 +1,5 @@ singleton Constants 1.0 Constants.qml +singleton DataStore 1.0 DataStore.qml EventListModel 1.0 EventListModel.qml EventListSimulator 1.0 EventListSimulator.qml DirectoryFontLoader 1.0 DirectoryFontLoader.qml diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/wizard.json b/share/qtcreator/templates/wizards/projects/qtquickapplication/wizard.json index 2e885c2bb6..64502bd124 100644 --- a/share/qtcreator/templates/wizards/projects/qtquickapplication/wizard.json +++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/wizard.json @@ -242,6 +242,16 @@ "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/Constants.qml", "condition": "%{QdsProjectStyle}" }, + { + "source": "%{QdsWizardPath}/shared-plugin/name/DataStore.json.tpl", + "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DataStore.json", + "condition": "%{QdsProjectStyle}" + }, + { + "source": "%{QdsWizardPath}/shared-plugin/name/DataStore.qml.tpl", + "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DataStore.qml", + "condition": "%{QdsProjectStyle}" + }, { "source": "%{QdsWizardPath}/shared-plugin/name/DirectoryFontLoader.qml.tpl", "target": "%{ProjectDirectory}/imports/%{ImportModuleName}/DirectoryFontLoader.qml", -- cgit v1.2.3