From 0e8dcb886288bb64e5ef8b1f1ed898fd0f84d862 Mon Sep 17 00:00:00 2001 From: Aleksei German Date: Mon, 20 Feb 2023 16:22:12 +0100 Subject: [PATCH] QmlDesigner: Update MCU Wizard template for 2.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QDS-4729 Change-Id: I17c07e87542ad140c55e8cde5bc75086b0e05cd0 Reviewed-by: Sivert Krøvel Reviewed-by: Thomas Hartmann --- .../projects/app_mcu.qmlproject | 22 ++- .../projects/application-mcu/CMakeLists.txt | 137 +++++++++--------- .../application-mcu/Constants.qml.tpl | 4 +- .../constants_module.qmlproject.tpl | 13 ++ .../projects/application-mcu/wizard.json | 4 + 5 files changed, 108 insertions(+), 72 deletions(-) create mode 100644 share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/constants_module.qmlproject.tpl diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/app_mcu.qmlproject b/share/qtcreator/qmldesigner/studio_templates/projects/app_mcu.qmlproject index d339fcffb50..bbf848151fe 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/app_mcu.qmlproject +++ b/share/qtcreator/qmldesigner/studio_templates/projects/app_mcu.qmlproject @@ -1,6 +1,6 @@ -/* File generated by Qt Creator */ +/* File generated by Qt Design Studio */ -import QmlProject 1.1 +import QmlProject 1.3 Project { mainFile: "%{MainQmlFileName}" @@ -32,6 +32,21 @@ Project { filter: "*.ttf;*.otf" } + ModuleFiles { + files: [ + "imports/Constants/constants_module.qmlproject" + ] + + MCU.qulModules: [ + "Controls", + "ControlsTemplates", + "Timeline", + "Shapes" + ] + } + + + /* Following entries are for Qt Design Studio compatibility: */ Environment { QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" } @@ -39,8 +54,7 @@ Project { qtForMCUs: true /* List of plugin directories passed to QML runtime */ - importPaths: [ "imports", "asset_imports" ] + importPaths: [ "imports" ] - /* Required for deployment */ targetDirectory: "/opt/%{ProjectName}" } diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/CMakeLists.txt b/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/CMakeLists.txt index b979c45227b..42693c255d4 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/CMakeLists.txt +++ b/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.15) +cmake_minimum_required (VERSION 3.21.1) project(%{ProjectName} VERSION 0.0.1 LANGUAGES C CXX ASM) @@ -6,72 +6,77 @@ if (NOT TARGET Qul::Core) find_package(Qul) endif() -if (Qul_VERSION VERSION_GREATER_EQUAL "1.7") - qul_add_target(%{ProjectName}) +if (Qul_VERSION VERSION_GREATER_EQUAL "2.4") + qul_add_target(%{ProjectName} QML_PROJECT %{ProjectName}.qmlproject GENERATE_ENTRYPOINT) + app_target_setup_os(%{ProjectName}) else() - add_executable(%{ProjectName}) - target_link_libraries(%{ProjectName} - Qul::QuickUltralite - Qul::QuickUltralitePlatform) -endif() - -if (Qul_VERSION VERSION_GREATER_EQUAL "2.0") - file(GLOB_RECURSE fontSources "${CMAKE_CURRENT_SOURCE_DIR}/fonts/*.ttf") - set_property(TARGET %{ProjectName} APPEND PROPERTY QUL_FONT_FILES ${fontSources}) -elseif (Qul_VERSION VERSION_GREATER_EQUAL "1.7") - set_property(TARGET %{ProjectName} APPEND PROPERTY QUL_FONTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fonts") -else() - set(QUL_FONTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fonts,${QUL_FONTS_DIR}") -endif() - -# Using recurse search to find image files in project directory -# Excluding MCUDefaultStyle because it exists for compatibility purposes with QDS -file(GLOB_RECURSE imgSources "*.png" "*.svg" "*.jpg" "*.jpeg") -list(FILTER imgSources EXCLUDE REGEX ".*/MCUDefaultStyle/.*") - -if(imgSources) - qul_add_resource(%{ProjectName} FILES ${imgSources}) -endif() - -# Registering singletons as qml module -qul_add_qml_module(ConstantsModule - URI Constants - QML_FILES - imports/Constants/Constants.qml -) - -message(WARNING "It is recommended to replace the recursive search with the actual list of .qml files in your project.") -file(GLOB_RECURSE qmlSources "*.qml") -# Excluding Constants folder because it is part of another qml module -list(FILTER qmlSources EXCLUDE REGEX ".*/imports/Constants/.*") -# Excluding MCUDefaultStyle because it exists for compatibility purposes with QDS -list(FILTER qmlSources EXCLUDE REGEX ".*/MCUDefaultStyle/.*") -# Excluding binary directory because it can break builds in source dir -list(FILTER qmlSources EXCLUDE REGEX "${CMAKE_CURRENT_BINARY_DIR}/.*") -qul_target_qml_sources(%{ProjectName} ${qmlSources}) - -if (Qul_VERSION VERSION_GREATER_EQUAL "2.0") - target_link_libraries(%{ProjectName} PRIVATE - Qul::Timeline - Qul::Controls - Qul::Shapes - ConstantsModule) -else() - target_link_libraries(%{ProjectName} - Qul::QuickUltraliteTimeline - Qul::QuickUltraliteControlsStyleDefault - ConstantsModule) - - if (Qul_VERSION VERSION_GREATER_EQUAL "1.8") + if (Qul_VERSION VERSION_GREATER_EQUAL "1.7") + qul_add_target(%{ProjectName}) + else() + add_executable(%{ProjectName}) target_link_libraries(%{ProjectName} - Qul::QuickUltraliteShapes) + Qul::QuickUltralite + Qul::QuickUltralitePlatform) + endif() + + if (Qul_VERSION VERSION_GREATER_EQUAL "2.0") + file(GLOB_RECURSE fontSources "${CMAKE_CURRENT_SOURCE_DIR}/fonts/*.ttf") + set_property(TARGET %{ProjectName} APPEND PROPERTY QUL_FONT_FILES ${fontSources}) + elseif (Qul_VERSION VERSION_GREATER_EQUAL "1.7") + set_property(TARGET %{ProjectName} APPEND PROPERTY QUL_FONTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fonts") + else() + set(QUL_FONTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fonts,${QUL_FONTS_DIR}") + endif() + + # Using recurse search to find image files in project directory + # Excluding MCUDefaultStyle because it exists for compatibility purposes with QDS + file(GLOB_RECURSE imgSources "*.png" "*.svg" "*.jpg" "*.jpeg") + list(FILTER imgSources EXCLUDE REGEX ".*/MCUDefaultStyle/.*") + + if(imgSources) + qul_add_resource(%{ProjectName} FILES ${imgSources}) + endif() + + # Registering singletons as qml module + qul_add_qml_module(ConstantsModule + URI Constants + QML_FILES + imports/Constants/Constants.qml + ) + + message(WARNING "It is recommended to replace the recursive search with the actual list of .qml files in your project.") + file(GLOB_RECURSE qmlSources "*.qml") + # Excluding Constants folder because it is part of another qml module + list(FILTER qmlSources EXCLUDE REGEX ".*/imports/Constants/.*") + # Excluding MCUDefaultStyle because it exists for compatibility purposes with QDS + list(FILTER qmlSources EXCLUDE REGEX ".*/MCUDefaultStyle/.*") + # Excluding binary directory because it can break builds in source dir + list(FILTER qmlSources EXCLUDE REGEX "${CMAKE_CURRENT_BINARY_DIR}/.*") + qul_target_qml_sources(%{ProjectName} ${qmlSources}) + + if (Qul_VERSION VERSION_GREATER_EQUAL "2.0") + target_link_libraries(%{ProjectName} PRIVATE + Qul::Timeline + Qul::Controls + Qul::Shapes + ConstantsModule) + else() + target_link_libraries(%{ProjectName} + Qul::QuickUltraliteTimeline + Qul::QuickUltraliteControlsStyleDefault + ConstantsModule) + + if (Qul_VERSION VERSION_GREATER_EQUAL "1.8") + target_link_libraries(%{ProjectName} + Qul::QuickUltraliteShapes) + endif() + endif() + + app_target_setup_os(%{ProjectName}) + + if (Qul_VERSION VERSION_GREATER_EQUAL "1.7") + app_target_default_entrypoint(%{ProjectName} %{RootItemName}) + else() + app_target_default_main(%{ProjectName} %{RootItemName}) endif() endif() - -app_target_setup_os(%{ProjectName}) - -if (Qul_VERSION VERSION_GREATER_EQUAL "1.7") - app_target_default_entrypoint(%{ProjectName} %{RootItemName}) -else() - app_target_default_main(%{ProjectName} %{RootItemName}) -endif() diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/Constants.qml.tpl b/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/Constants.qml.tpl index ef8bfddcef6..fb14c1e895d 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/Constants.qml.tpl +++ b/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/Constants.qml.tpl @@ -8,8 +8,8 @@ QtObject { readonly property color backgroundColor: "#e8e8e8" - /* DirectoryFontLoader doesn't work with Qt Ultralite. - However you may want to uncomment this block to load fonts in real qml environment */ + /* DirectoryFontLoader doesn't work with Qt Quick Ultralite. + However you may want to uncomment this block to load fonts in QtQuick environment: */ /* property alias fontDirectory: directoryFontLoader.fontDirectory property alias relativeFontDirectory: directoryFontLoader.relativeFontDirectory diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/constants_module.qmlproject.tpl b/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/constants_module.qmlproject.tpl new file mode 100644 index 00000000000..01711f43ef3 --- /dev/null +++ b/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/constants_module.qmlproject.tpl @@ -0,0 +1,13 @@ +import QmlProject 1.3 + +Project { + MCU.Module { + uri: "Constants" + } + + QmlFiles { + files: [ + "Constants.qml" + ] + } +} diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/wizard.json b/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/wizard.json index 45965fad3db..b485866b602 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/wizard.json +++ b/share/qtcreator/qmldesigner/studio_templates/projects/application-mcu/wizard.json @@ -164,6 +164,10 @@ "source": "DirectoryFontLoader.qml.tpl", "target": "%{ProjectDirectory}/imports/Constants/DirectoryFontLoader.qml" }, + { + "source": "constants_module.qmlproject.tpl", + "target": "%{ProjectDirectory}/imports/Constants/constants_module.qmlproject" + }, { "source": "Screen01.ui.qml.tpl", "target": "%{ProjectDirectory}/Screen01.ui.qml",