From df16d4511e6c3daa17b6fbc1b9ffca510da1f882 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 26 Apr 2022 09:22:15 +0200 Subject: [PATCH] QmlDesigner: Add new way to load fonts to template StudioApplication will load the correct font in time. This only works for Qt 6. Task-number: QDS-3286 Change-Id: I2d97ca19bace8e13c7a4df355d1addb7267e117c Reviewed-by: Tim Jenssen (cherry picked from commit 099f02b5db2b4256b9238c3a27173c458da6f95e) --- .../projects/shared-plugin/name/Constants.qml.tpl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/Constants.qml.tpl b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/Constants.qml.tpl index 98c1927f2ea..6fcae14ea65 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/Constants.qml.tpl +++ b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/Constants.qml.tpl @@ -1,12 +1,15 @@ pragma Singleton import QtQuick %{QtQuickVersion} +@if %{IsQt6Project} +import QtQuick.Studio.Application +@else +@endif QtObject { readonly property int width: %{ScreenWidth} readonly property int height: %{ScreenHeight} - property alias fontDirectory: directoryFontLoader.fontDirectory - property alias relativeFontDirectory: directoryFontLoader.relativeFontDirectory + property string relativeFontDirectory: "fonts" /* Edit this comment to add your custom font */ readonly property font font: Qt.font({ @@ -20,7 +23,14 @@ QtObject { readonly property color backgroundColor: "#c2c2c2" + +@if %{IsQt6Project} + property StudioApplication application: StudioApplication { + fontPath: Qt.resolvedUrl("../../content/" + relativeFontDirectory) + } +@else property DirectoryFontLoader directoryFontLoader: DirectoryFontLoader { id: directoryFontLoader } +@endif }