QmlDesigner: Unify add QtQuick3D links

Fixes: QDS-14876
Change-Id: I6b3eaba09807d67c02dc895eb596d5bdce87f70f
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2025-03-06 13:35:33 +02:00
parent fd258651bd
commit a1b4b35940
7 changed files with 68 additions and 45 deletions

View File

@@ -109,29 +109,35 @@ HelperWidgets.ScrollView {
id: infoText
text: {
if (!ContentLibraryBackend.rootView.isQt6Project)
if (!ContentLibraryBackend.rootView.isQt6Project) {
qsTr("<b>Content Library</b> effects are not supported in Qt5 projects.")
else if (!ContentLibraryBackend.rootView.hasQuick3DImport)
qsTr('To use <b>Content Library</b>, first <a href="#add_import" style="text-decoration:none;color:%1">
add the QtQuick3D module</a> in the <b>Components</b> view.')
.arg(StudioTheme.Values.themeInteraction)
else if (!ContentLibraryBackend.effectsModel.hasRequiredQuick3DImport)
} else if (!ContentLibraryBackend.rootView.hasQuick3DImport) {
qsTr('To use <b>Content Library</b> effects, add the <b>QtQuick3D</b> module and the <b>View3D</b>
component in the <b>Components</b> view, or click
<a href=\"#add_import\"><span style=\"text-decoration:none;color:%1\">
here</span></a>.').arg(StudioTheme.Values.themeInteraction)
} else if (!ContentLibraryBackend.effectsModel.hasRequiredQuick3DImport) {
qsTr("To use <b>Content Library</b>, version 6.4 or later of the QtQuick3D module is required.")
else if (!ContentLibraryBackend.rootView.hasMaterialLibrary)
} else if (!ContentLibraryBackend.rootView.hasMaterialLibrary) {
qsTr("<b>Content Library</b> is disabled inside a non-visual component.")
else if (!ContentLibraryBackend.effectsModel.bundleExists)
} else if (!ContentLibraryBackend.effectsModel.bundleExists) {
qsTr("No effects available.")
else if (!searchBox.isEmpty())
} else if (!searchBox.isEmpty()) {
qsTr("No match found.")
else
} else {
""
}
}
textFormat: Text.RichText
color: StudioTheme.Values.themeTextColor
font.pixelSize: StudioTheme.Values.baseFontSize
topPadding: 10
leftPadding: 10
rightPadding: 10
visible: ContentLibraryBackend.effectsModel.isEmpty
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
width: root.width
onLinkActivated: ContentLibraryBackend.rootView.addQtQuick3D()
}

View File

@@ -114,30 +114,34 @@ HelperWidgets.ScrollView {
id: infoText
text: {
if (!ContentLibraryBackend.rootView.isQt6Project)
if (!ContentLibraryBackend.rootView.isQt6Project) {
qsTr("<b>Content Library</b> materials are not supported in Qt5 projects.")
else if (!ContentLibraryBackend.rootView.hasQuick3DImport)
qsTr('To use <b>Content Library</b>, first <a href="#add_import" style="text-decoration:none;color:%1">
add the QtQuick3D module</a> in the <b>Components</b> view.')
.arg(StudioTheme.Values.themeInteraction)
else if (!root.materialsModel.hasRequiredQuick3DImport)
} else if (!ContentLibraryBackend.rootView.hasQuick3DImport) {
qsTr('To use <b>Content Library</b> materials, add the <b>QtQuick3D</b> module and the <b>View3D</b>
component in the <b>Components</b> view, or click
<a href=\"#add_import\"><span style=\"text-decoration:none;color:%1\">
here</span></a>.').arg(StudioTheme.Values.themeInteraction)
} else if (!root.materialsModel.hasRequiredQuick3DImport) {
qsTr("To use <b>Content Library</b>, version 6.3 or later of the QtQuick3D module is required.")
else if (!ContentLibraryBackend.rootView.hasMaterialLibrary)
} else if (!ContentLibraryBackend.rootView.hasMaterialLibrary) {
qsTr("<b>Content Library</b> is disabled inside a non-visual component.")
else if (!root.materialsModel.bundleExists)
} else if (!root.materialsModel.bundleExists) {
qsTr("No materials available. Make sure you have an internet connection.")
else if (!searchBox.isEmpty())
} else if (!searchBox.isEmpty()) {
qsTr("No match found.")
else
} else {
""
}
}
textFormat: Text.RichText
color: StudioTheme.Values.themeTextColor
font.pixelSize: StudioTheme.Values.baseFontSize
topPadding: 10
leftPadding: 10
rightPadding: 10
wrapMode: Text.WordWrap
width: root.width - x
horizontalAlignment: Text.AlignHCenter
onLinkActivated: ContentLibraryBackend.rootView.addQtQuick3D()
}

View File

@@ -213,26 +213,33 @@ Item {
text: {
let categoryName = (categoryTitle === "3D") ? categoryTitle + " assets"
: categoryTitle.toLowerCase()
if (!ContentLibraryBackend.rootView.isQt6Project)
if (!ContentLibraryBackend.rootView.isQt6Project) {
qsTr("<b>Content Library</b> is not supported in Qt5 projects.")
else if (!ContentLibraryBackend.rootView.hasQuick3DImport && categoryTitle !== "Textures")
qsTr(`To use %1, first <a href="#add_import" style="text-decoration:none;color:%2">
add the <b>QtQuick3D</b> module</a> in the <b>Components</b> view.`)
} else if (!ContentLibraryBackend.rootView.hasQuick3DImport && categoryTitle !== "Textures") {
qsTr('To use %1, add the <b>QtQuick3D</b> module and the <b>View3D</b>
component in the <b>Components</b> view, or click
<a href=\"#add_import\"><span style=\"text-decoration:none;color:%2\">
here</span></a>.')
.arg(categoryName)
.arg(StudioTheme.Values.themeInteraction)
else if (!ContentLibraryBackend.rootView.hasMaterialLibrary && categoryTitle !== "Textures")
} else if (!ContentLibraryBackend.rootView.hasMaterialLibrary && categoryTitle !== "Textures") {
qsTr("<b>Content Library</b> is disabled inside a non-visual component.")
else if (categoryEmpty)
} else if (categoryEmpty) {
qsTr("There are no "+ categoryName + " in the <b>User Assets</b>.")
else
} else {
""
}
}
textFormat: Text.RichText
color: StudioTheme.Values.themeTextColor
font.pixelSize: StudioTheme.Values.baseFontSize
topPadding: 10
leftPadding: 10
rightPadding: 10
visible: infoText.text !== ""
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
width: root.width
onLinkActivated: ContentLibraryBackend.rootView.addQtQuick3D()
}

View File

@@ -596,21 +596,27 @@ Item {
anchors.centerIn: parent
text: {
if (!materialBrowserModel.isQt6Project)
if (!materialBrowserModel.isQt6Project) {
qsTr("<b>Material Browser</b> is not supported in Qt5 projects.")
else if (!materialBrowserModel.hasQuick3DImport)
qsTr("To use <b>Material Browser</b>, first add the QtQuick3D module in the <b>Components</b> view.")
else if (!materialBrowserModel.hasMaterialLibrary)
} else if (!materialBrowserModel.hasQuick3DImport) {
qsTr('To use the <b>Material Browser</b>, add the <b>QtQuick3D</b> module and the <b>View3D</b>
component in the <b>Components</b> view, or click
<a href=\"#add_import\"><span style=\"text-decoration:none;color:%1\">
here</span></a>.').arg(StudioTheme.Values.themeInteraction)
} else if (!materialBrowserModel.hasMaterialLibrary) {
qsTr("<b>Material Browser</b> is disabled inside a non-visual component.")
else
} else {
""
}
}
textFormat: Text.RichText
color: StudioTheme.Values.themeTextColor
font.pixelSize: StudioTheme.Values.mediumFontSize
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
onLinkActivated: rootView.addQtQuick3D()
}
}

View File

@@ -184,6 +184,7 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view)
// Onboarding label contains instructions for new users how to get 3D content into the project
m_onboardingLabel = new QLabel(this);
m_onboardingLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_onboardingLabel->setWordWrap(true);
connect(m_onboardingLabel, &QLabel::linkActivated, this, &Edit3DWidget::linkActivated);
fillLayout->addWidget(m_onboardingLabel.data());
@@ -418,19 +419,11 @@ void Edit3DWidget::showOnboardingLabel()
if (text.isEmpty()) {
if (m_view->externalDependencies().isQt6Project()) {
QString labelText =
tr("Your file does not import Qt Quick 3D.<br><br>"
"To create a 3D view, add the"
" <b>QtQuick3D</b>"
" module in the"
" <b>Components</b>"
" view or click"
tr("To use the <b>3D</b> view, add the <b>QtQuick3D</b> module and the <b>View3D</b>"
" component in the <b>Components</b> view or click"
" <a href=\"#add_import\"><span style=\"text-decoration:none;color:%1\">here</span></a>"
".<br><br>"
"To import 3D assets, select"
" <b>+</b>"
" in the"
" <b>Assets</b>"
" view.");
"To import 3D assets, select <b>+</b> in the <b>Assets</b> view.");
text = labelText.arg(Utils::creatorColor(Utils::Theme::TextColorLink).name());
} else {
text = tr("3D view is not supported in Qt5 projects.");

View File

@@ -18,6 +18,7 @@
#include <qmldesignerplugin.h>
#include <studioquickwidget.h>
#include <theme.h>
#include <utils3d.h>
#include <variantproperty.h>
#include <coreplugin/icore.h>
@@ -389,6 +390,11 @@ void MaterialBrowserWidget::exportMaterial()
m_bundleHelper->exportBundle({mat}, m_previewImageProvider->getPixmap(mat));
}
void MaterialBrowserWidget::addQtQuick3D()
{
Utils3D::addQuick3DImportAndView3D(m_materialBrowserView.data());
}
QString MaterialBrowserWidget::qmlSourcesPath()
{
#ifdef SHARE_QML_PATH

View File

@@ -66,6 +66,7 @@ public:
Q_INVOKABLE void addMaterialToContentLibrary();
Q_INVOKABLE void importMaterial();
Q_INVOKABLE void exportMaterial();
Q_INVOKABLE void addQtQuick3D();
StudioQuickWidget *quickWidget() const;