forked from qt-creator/qt-creator
McuSupport: Register Qt for MCUs .qch files
At plugin initialization and along with the creation of a Qt for MCUs Kit (which currently happens when the user presses "Apply"), these .qch files get registered: <Qul_DIR>/docs/quickultralite.qch <Qul_DIR>/docs/quickultralitecmake.qch In order not to duplicate the code for retrieving package paths (e.g. the one for "QtForMCUsSdk") from the settings, some refactoring was done. As a result McuSupportOptions::qulDirFromSettings() has been introduced. It will be also used in further changes. Task-number: UL-1685 Change-Id: I82e638e129120cdadcf2f4812f467fce34b32ec9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -37,6 +37,7 @@ const char KIT_MCUTARGET_MODEL_KEY[] = "McuSupport.McuTargetModel";
|
||||
|
||||
const char SETTINGS_GROUP[] = "McuSupport";
|
||||
const char SETTINGS_KEY_PACKAGE_PREFIX[] = "Package_";
|
||||
const char SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK[] = "QtForMCUsSdk"; // Key known by SDK installer
|
||||
|
||||
} // namespace McuSupport
|
||||
} // namespace Constants
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "mcusupportsdk.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <cmakeprojectmanager/cmakekitinformation.h>
|
||||
#include <debugger/debuggeritem.h>
|
||||
#include <debugger/debuggeritemmanager.h>
|
||||
@@ -56,6 +57,16 @@
|
||||
namespace McuSupport {
|
||||
namespace Internal {
|
||||
|
||||
static QString packagePathFromSettings(const QString &settingsKey, const QString &defaultPath = {})
|
||||
{
|
||||
QSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(Constants::SETTINGS_GROUP);
|
||||
const QString path = s->value(QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX)
|
||||
+ settingsKey, defaultPath).toString();
|
||||
s->endGroup();
|
||||
return path;
|
||||
}
|
||||
|
||||
McuPackage::McuPackage(const QString &label, const QString &defaultPath,
|
||||
const QString &detectionPath, const QString &settingsKey)
|
||||
: m_label(label)
|
||||
@@ -63,11 +74,7 @@ McuPackage::McuPackage(const QString &label, const QString &defaultPath,
|
||||
, m_detectionPath(detectionPath)
|
||||
, m_settingsKey(settingsKey)
|
||||
{
|
||||
QSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(Constants::SETTINGS_GROUP);
|
||||
m_path = s->value(QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey,
|
||||
m_defaultPath).toString();
|
||||
s->endGroup();
|
||||
m_path = packagePathFromSettings(settingsKey, defaultPath);
|
||||
}
|
||||
|
||||
QString McuPackage::path() const
|
||||
@@ -349,6 +356,22 @@ void McuSupportOptions::populatePackagesAndTargets()
|
||||
setQulDir(Utils::FilePath::fromUserInput(qtForMCUsSdkPackage->path()));
|
||||
}
|
||||
|
||||
void McuSupportOptions::registerQchFiles()
|
||||
{
|
||||
const QString qulDir = qulDirFromSettings().toString();
|
||||
if (qulDir.isEmpty() || !QFileInfo::exists(qulDir))
|
||||
return;
|
||||
|
||||
const QString docsPath = qulDir + "/docs/";
|
||||
const QStringList qchFiles = {
|
||||
docsPath + "quickultralite.qch",
|
||||
docsPath + "quickultralitecmake.qch"
|
||||
};
|
||||
Core::HelpManager::registerDocumentation(
|
||||
Utils::filtered(qchFiles,
|
||||
[](const QString &file) { return QFileInfo::exists(file); }));
|
||||
}
|
||||
|
||||
void McuSupportOptions::deletePackagesAndTargets()
|
||||
{
|
||||
qDeleteAll(packages);
|
||||
@@ -370,6 +393,12 @@ void McuSupportOptions::setQulDir(const Utils::FilePath &dir)
|
||||
emit changed();
|
||||
}
|
||||
|
||||
Utils::FilePath McuSupportOptions::qulDirFromSettings()
|
||||
{
|
||||
return Utils::FilePath::fromUserInput(
|
||||
packagePathFromSettings(Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK));
|
||||
}
|
||||
|
||||
static bool mcuTargetIsDesktop(const McuTarget* mcuTarget)
|
||||
{
|
||||
return mcuTarget->qulPlatform() == "Qt";
|
||||
|
@@ -160,12 +160,14 @@ public:
|
||||
McuPackage *qtForMCUsSdkPackage = nullptr;
|
||||
|
||||
void setQulDir(const Utils::FilePath &dir);
|
||||
static Utils::FilePath qulDirFromSettings();
|
||||
|
||||
QString kitName(const McuTarget* mcuTarget) const;
|
||||
|
||||
QList<ProjectExplorer::Kit *> existingKits(const McuTarget *mcuTargt);
|
||||
ProjectExplorer::Kit *newKit(const McuTarget *mcuTarget);
|
||||
void populatePackagesAndTargets();
|
||||
static void registerQchFiles();
|
||||
|
||||
private:
|
||||
void deletePackagesAndTargets();
|
||||
|
@@ -223,14 +223,15 @@ void McuSupportOptionsWidget::showEvent(QShowEvent *event)
|
||||
|
||||
void McuSupportOptionsWidget::apply()
|
||||
{
|
||||
m_options.qtForMCUsSdkPackage->writeToSettings();
|
||||
for (auto package : m_options.packages)
|
||||
package->writeToSettings();
|
||||
|
||||
QTC_ASSERT(m_options.qtForMCUsSdkPackage, return);
|
||||
|
||||
if (!isVisible())
|
||||
return;
|
||||
|
||||
McuSupportOptions::registerQchFiles();
|
||||
|
||||
const McuTarget *mcuTarget = currentMcuTarget();
|
||||
if (!mcuTarget)
|
||||
return;
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "mcusupportplugin.h"
|
||||
#include "mcusupportconstants.h"
|
||||
#include "mcusupportdevice.h"
|
||||
#include "mcusupportoptions.h"
|
||||
#include "mcusupportoptionspage.h"
|
||||
#include "mcusupportrunconfiguration.h"
|
||||
|
||||
@@ -74,6 +75,7 @@ bool McuSupportPlugin::initialize(const QStringList& arguments, QString* errorSt
|
||||
|
||||
dd = new McuSupportPluginPrivate;
|
||||
|
||||
McuSupportOptions::registerQchFiles();
|
||||
ProjectExplorer::JsonWizardFactory::addWizardPath(
|
||||
Utils::FilePath::fromString(":/mcusupport/wizards/"));
|
||||
|
||||
|
@@ -55,7 +55,7 @@ McuPackage *createQtForMCUsPackage()
|
||||
McuPackage::tr("Qt for MCUs SDK"),
|
||||
QDir::homePath(),
|
||||
Utils::HostOsInfo::withExecutableSuffix("bin/qmltocpp"),
|
||||
"QtForMCUsSdk");
|
||||
Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK);
|
||||
result->setEnvironmentVariableName("Qul_DIR");
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user