diff --git a/share/qtcreator/qmldesigner/welcomepage/ThumbnailDelegate.qml b/share/qtcreator/qmldesigner/welcomepage/ThumbnailDelegate.qml index 3d918328bf0..ada6292b8c6 100644 --- a/share/qtcreator/qmldesigner/welcomepage/ThumbnailDelegate.qml +++ b/share/qtcreator/qmldesigner/welcomepage/ThumbnailDelegate.qml @@ -75,6 +75,7 @@ Item { root.startDownload() } else if (downloadButton.alreadyDownloaded) { root.clicked() // open example + extractor.probeTargetPath() } } } diff --git a/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp b/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp index 0b37996b8c9..763d85b83b8 100644 --- a/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp +++ b/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.cpp @@ -259,6 +259,11 @@ void FileExtractor::extract() m_unarchiver->start(); } +void FileExtractor::probeTargetPath() +{ + emit targetFolderExistsChanged(); +} + void QmlDesigner::FileExtractor::removeTempTargetPath() { if (m_isTempTargetPath && m_targetPath.exists()) { diff --git a/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.h b/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.h index 8cee7b34c42..9fbf18ea953 100644 --- a/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.h +++ b/src/plugins/qmldesigner/libs/qmldesignerutils/fileextractor.h @@ -59,6 +59,8 @@ public: Q_INVOKABLE void browse(); Q_INVOKABLE void extract(); + Q_INVOKABLE void probeTargetPath(); + signals: void targetPathChanged(); void detailedTextChanged(); diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp index 93c0131d1ed..725abe21c12 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp +++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -290,14 +291,23 @@ public: QmlDesigner::QmlDesignerPlugin::emitUsageStatistics("exampleOpened:" + exampleName); - const QString exampleFolder = examplePath + "/" + exampleName + "/"; + const FilePath exampleFilePath = FilePath::fromString(examplePath) / exampleName; - QString projectFile = exampleFolder + exampleName + ".qmlproject"; + FilePath projectFile = exampleFilePath / (exampleName + ".qmlproject"); if (!explicitQmlproject.isEmpty()) - projectFile = exampleFolder + explicitQmlproject; + projectFile = exampleFilePath / explicitQmlproject; - ProjectExplorer::ProjectExplorerPlugin::openProjectWelcomePage(FilePath::fromString(projectFile)); + if (!projectFile.exists()) { + Core::AsynchronousMessageBox::warning( + tr("Could not open %1").arg(exampleName), + tr("Project file %1 is missing. Try downloading the example again.") + .arg(projectFile.nativePath())); + + return; + } + + ProjectExplorer::ProjectExplorerPlugin::openProjectWelcomePage(projectFile); } Q_INVOKABLE void openExample(const QString &example,