QmlDesigner: Make 3D edit view onboarding text translatable

Also add a potential related nullptr check.

Change-Id: I8c6e4facbdb0c2d94f7c2af54f83eef0eca0b796
Fixes: QDS-1993
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Miikka Heikkinen
2020-04-24 12:21:35 +03:00
parent 923bd79323
commit a248138685
2 changed files with 14 additions and 13 deletions

View File

@@ -312,14 +312,16 @@ QVector<Edit3DAction *> Edit3DView::rightActions() const
void Edit3DView::addQuick3DImport()
{
const QList<Import> imports = model()->possibleImports();
for (const auto &import : imports) {
if (import.url() == "QtQuick3D") {
model()->changeImports({import}, {});
if (model()) {
const QList<Import> imports = model()->possibleImports();
for (const auto &import : imports) {
if (import.url() == "QtQuick3D") {
model()->changeImports({import}, {});
// Subcomponent manager update needed to make item library entries appear
QmlDesignerPlugin::instance()->currentDesignDocument()->updateSubcomponentManager();
return;
// Subcomponent manager update needed to make item library entries appear
QmlDesignerPlugin::instance()->currentDesignDocument()->updateSubcomponentManager();
return;
}
}
}
Core::AsynchronousMessageBox::warning(tr("Failed to Add Import"),

View File

@@ -106,12 +106,11 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) :
// Onboarding label contains instructions for new users how to get 3D content into the project
m_onboardingLabel = new QLabel(this);
QString labelText =
"No 3D import here yet!<br><br>"
"To create a 3D View you need to add the QtQuick3D import to your file.<br>"
"You can add the import via the QML Imports tab of the Library view, or alternatively click"
" <a href=\"#add_import\"><span style=\"text-decoration:none;color:%1\">here</span></a> "
"to add it straight away.<br><br>"
"If you want to import 3D assets from another tool, click on the \"Add New Assets...\" button in the Assets tab of the Library view.";
tr("Your file does not import Qt Quick 3D.<br><br>"
"To create a 3D view, add the QtQuick3D import to your file in the QML Imports tab of the Library view. Or click"
" <a href=\"#add_import\"><span style=\"text-decoration:none;color:%1\">here</span></a> "
"here to add it immediately.<br><br>"
"To import 3D assets from another tool, click on the \"Add New Assets...\" button in the Assets tab of the Library view.");
m_onboardingLabel->setText(labelText.arg(Utils::creatorTheme()->color(Utils::Theme::TextColorLink).name()));
m_onboardingLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
connect(m_onboardingLabel, &QLabel::linkActivated, this, &Edit3DWidget::linkActivated);