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 <alessandro.portale@qt.io>
This commit is contained in:
Alessandro Portale
2020-04-02 19:31:52 +02:00
parent 7e76a76402
commit a02b6e3e7d
6 changed files with 35 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
add_qtc_plugin(McuSupport add_qtc_plugin(McuSupport
DEPENDS Qt5::Core DEPENDS Qt5::Core
PLUGIN_DEPENDS Core ProjectExplorer Debugger CMakeProjectManager PLUGIN_DEPENDS Core ProjectExplorer Debugger CMakeProjectManager QtSupport
SOURCES SOURCES
mcusupport.qrc mcusupport.qrc
mcusupport_global.h mcusupport_global.h

View File

@@ -11,6 +11,7 @@ QtcPlugin {
Depends { name: "ProjectExplorer" } Depends { name: "ProjectExplorer" }
Depends { name: "Debugger" } Depends { name: "Debugger" }
Depends { name: "CMakeProjectManager" } Depends { name: "CMakeProjectManager" }
Depends { name: "QtSupport" }
files: [ files: [
"mcusupport.qrc", "mcusupport.qrc",

View File

@@ -8,4 +8,5 @@ QTC_PLUGIN_DEPENDS += \
coreplugin \ coreplugin \
projectexplorer \ projectexplorer \
debugger \ debugger \
cmakeprojectmanager cmakeprojectmanager \
qtsupport

View File

@@ -39,6 +39,7 @@
#include <projectexplorer/kitmanager.h> #include <projectexplorer/kitmanager.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/devicemanager.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/infolabel.h> #include <utils/infolabel.h>
@@ -356,22 +357,45 @@ void McuSupportOptions::populatePackagesAndTargets()
setQulDir(Utils::FilePath::fromUserInput(qtForMCUsSdkPackage->path())); 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() void McuSupportOptions::registerQchFiles()
{ {
const QString qulDir = qulDirFromSettings().toString(); const QString docsDir = qulDocsDir().toString();
if (qulDir.isEmpty() || !QFileInfo::exists(qulDir)) if (docsDir.isEmpty())
return; return;
const QString docsPath = qulDir + "/docs/";
const QStringList qchFiles = { const QStringList qchFiles = {
docsPath + "quickultralite.qch", docsDir + "/quickultralite.qch",
docsPath + "quickultralitecmake.qch" docsDir + "/quickultralitecmake.qch"
}; };
Core::HelpManager::registerDocumentation( Core::HelpManager::registerDocumentation(
Utils::filtered(qchFiles, Utils::filtered(qchFiles,
[](const QString &file) { return QFileInfo::exists(file); })); [](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() void McuSupportOptions::deletePackagesAndTargets()
{ {
qDeleteAll(packages); qDeleteAll(packages);

View File

@@ -168,6 +168,7 @@ public:
ProjectExplorer::Kit *newKit(const McuTarget *mcuTarget); ProjectExplorer::Kit *newKit(const McuTarget *mcuTarget);
void populatePackagesAndTargets(); void populatePackagesAndTargets();
static void registerQchFiles(); static void registerQchFiles();
static void registerExamples();
private: private:
void deletePackagesAndTargets(); void deletePackagesAndTargets();

View File

@@ -76,6 +76,7 @@ bool McuSupportPlugin::initialize(const QStringList& arguments, QString* errorSt
dd = new McuSupportPluginPrivate; dd = new McuSupportPluginPrivate;
McuSupportOptions::registerQchFiles(); McuSupportOptions::registerQchFiles();
McuSupportOptions::registerExamples();
ProjectExplorer::JsonWizardFactory::addWizardPath( ProjectExplorer::JsonWizardFactory::addWizardPath(
Utils::FilePath::fromString(":/mcusupport/wizards/")); Utils::FilePath::fromString(":/mcusupport/wizards/"));