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
DEPENDS Qt5::Core
PLUGIN_DEPENDS Core ProjectExplorer Debugger CMakeProjectManager
PLUGIN_DEPENDS Core ProjectExplorer Debugger CMakeProjectManager QtSupport
SOURCES
mcusupport.qrc
mcusupport_global.h

View File

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

View File

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

View File

@@ -39,6 +39,7 @@
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/infolabel.h>
@@ -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);

View File

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

View File

@@ -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/"));