From a02b6e3e7daf572b63b15e53a2c1c9da6d5e8dab Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 2 Apr 2020 19:31:52 +0200 Subject: [PATCH] McuSupport: Register Qt for MCUs examples This change introduces the registration of examples (or rather demos) of the Qt for MCUs SDK at the launch time of Qt Creator. This presumes that either the SDK installer set the Qt for MCUs SDK path (which is the default use-case) or that the user selected/changed the SDK path in a prior run of Qt Creator. Task-number: UL-1218 Change-Id: I6484d3e3065f501da4cd6faccfe02605003f6cbf Reviewed-by: Alessandro Portale --- src/plugins/mcusupport/CMakeLists.txt | 2 +- src/plugins/mcusupport/mcusupport.qbs | 1 + .../mcusupport/mcusupport_dependencies.pri | 3 +- src/plugins/mcusupport/mcusupportoptions.cpp | 34 ++++++++++++++++--- src/plugins/mcusupport/mcusupportoptions.h | 1 + src/plugins/mcusupport/mcusupportplugin.cpp | 1 + 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/plugins/mcusupport/CMakeLists.txt b/src/plugins/mcusupport/CMakeLists.txt index f2c8cf9b762..2af652f2602 100644 --- a/src/plugins/mcusupport/CMakeLists.txt +++ b/src/plugins/mcusupport/CMakeLists.txt @@ -1,6 +1,6 @@ add_qtc_plugin(McuSupport DEPENDS Qt5::Core - PLUGIN_DEPENDS Core ProjectExplorer Debugger CMakeProjectManager + PLUGIN_DEPENDS Core ProjectExplorer Debugger CMakeProjectManager QtSupport SOURCES mcusupport.qrc mcusupport_global.h diff --git a/src/plugins/mcusupport/mcusupport.qbs b/src/plugins/mcusupport/mcusupport.qbs index f3bb8a12e99..f3200d49b1c 100644 --- a/src/plugins/mcusupport/mcusupport.qbs +++ b/src/plugins/mcusupport/mcusupport.qbs @@ -11,6 +11,7 @@ QtcPlugin { Depends { name: "ProjectExplorer" } Depends { name: "Debugger" } Depends { name: "CMakeProjectManager" } + Depends { name: "QtSupport" } files: [ "mcusupport.qrc", diff --git a/src/plugins/mcusupport/mcusupport_dependencies.pri b/src/plugins/mcusupport/mcusupport_dependencies.pri index 1f2dd5bc644..f68cd308a95 100644 --- a/src/plugins/mcusupport/mcusupport_dependencies.pri +++ b/src/plugins/mcusupport/mcusupport_dependencies.pri @@ -8,4 +8,5 @@ QTC_PLUGIN_DEPENDS += \ coreplugin \ projectexplorer \ debugger \ - cmakeprojectmanager + cmakeprojectmanager \ + qtsupport diff --git a/src/plugins/mcusupport/mcusupportoptions.cpp b/src/plugins/mcusupport/mcusupportoptions.cpp index 159c88e7a0a..6d888b48f5e 100644 --- a/src/plugins/mcusupport/mcusupportoptions.cpp +++ b/src/plugins/mcusupport/mcusupportoptions.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -356,22 +357,45 @@ void McuSupportOptions::populatePackagesAndTargets() setQulDir(Utils::FilePath::fromUserInput(qtForMCUsSdkPackage->path())); } +static Utils::FilePath qulDocsDir() +{ + const Utils::FilePath qulDir = McuSupportOptions::qulDirFromSettings(); + if (qulDir.isEmpty() || !qulDir.exists()) + return {}; + const Utils::FilePath docsDir = qulDir.pathAppended("docs"); + return docsDir.exists() ? docsDir : Utils::FilePath(); +} + void McuSupportOptions::registerQchFiles() { - const QString qulDir = qulDirFromSettings().toString(); - if (qulDir.isEmpty() || !QFileInfo::exists(qulDir)) + const QString docsDir = qulDocsDir().toString(); + if (docsDir.isEmpty()) return; - const QString docsPath = qulDir + "/docs/"; const QStringList qchFiles = { - docsPath + "quickultralite.qch", - docsPath + "quickultralitecmake.qch" + docsDir + "/quickultralite.qch", + docsDir + "/quickultralitecmake.qch" }; Core::HelpManager::registerDocumentation( Utils::filtered(qchFiles, [](const QString &file) { return QFileInfo::exists(file); })); } +void McuSupportOptions::registerExamples() +{ + const Utils::FilePath docsDir = qulDocsDir(); + if (docsDir.isEmpty()) + return; + + const Utils::FilePath examplesDir = + McuSupportOptions::qulDirFromSettings().pathAppended("demos"); + if (!examplesDir.exists()) + return; + + QtSupport::QtVersionManager::registerExampleSet("Qt for MCUs", docsDir.toString(), + examplesDir.toString()); +} + void McuSupportOptions::deletePackagesAndTargets() { qDeleteAll(packages); diff --git a/src/plugins/mcusupport/mcusupportoptions.h b/src/plugins/mcusupport/mcusupportoptions.h index b22f32375e3..92790bac13c 100644 --- a/src/plugins/mcusupport/mcusupportoptions.h +++ b/src/plugins/mcusupport/mcusupportoptions.h @@ -168,6 +168,7 @@ public: ProjectExplorer::Kit *newKit(const McuTarget *mcuTarget); void populatePackagesAndTargets(); static void registerQchFiles(); + static void registerExamples(); private: void deletePackagesAndTargets(); diff --git a/src/plugins/mcusupport/mcusupportplugin.cpp b/src/plugins/mcusupport/mcusupportplugin.cpp index 4182713e866..3028c7e80e2 100644 --- a/src/plugins/mcusupport/mcusupportplugin.cpp +++ b/src/plugins/mcusupport/mcusupportplugin.cpp @@ -76,6 +76,7 @@ bool McuSupportPlugin::initialize(const QStringList& arguments, QString* errorSt dd = new McuSupportPluginPrivate; McuSupportOptions::registerQchFiles(); + McuSupportOptions::registerExamples(); ProjectExplorer::JsonWizardFactory::addWizardPath( Utils::FilePath::fromString(":/mcusupport/wizards/"));