forked from qt-creator/qt-creator
McuSupport: Move auto kit creation settings to handler"
Change-Id: I86a8588b812c10e0d547405c432f9fdc9c72aee3 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -452,7 +452,7 @@ void createAutomaticKits(const SettingsHandler::Ptr &settingsHandler)
|
|||||||
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage(settingsHandler)};
|
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage(settingsHandler)};
|
||||||
|
|
||||||
const auto createKits = [qtForMCUsPackage, settingsHandler]() {
|
const auto createKits = [qtForMCUsPackage, settingsHandler]() {
|
||||||
if (McuSupportOptions::automaticKitCreationFromSettings()) {
|
if (settingsHandler->isAutomaticKitCreationEnabled()) {
|
||||||
qtForMCUsPackage->updateStatus();
|
qtForMCUsPackage->updateStatus();
|
||||||
if (!qtForMCUsPackage->isValidStatus()) {
|
if (!qtForMCUsPackage->isValidStatus()) {
|
||||||
switch (qtForMCUsPackage->status()) {
|
switch (qtForMCUsPackage->status()) {
|
||||||
|
@@ -51,12 +51,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace McuSupport::Internal {
|
namespace McuSupport::Internal {
|
||||||
|
|
||||||
namespace {
|
|
||||||
const QString automaticKitCreationSettingsKey = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
|
||||||
+ QLatin1String(
|
|
||||||
Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
McuSupportOptions::McuSupportOptions(const SettingsHandler::Ptr &settingsHandler, QObject *parent)
|
McuSupportOptions::McuSupportOptions(const SettingsHandler::Ptr &settingsHandler, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage(settingsHandler))
|
, qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage(settingsHandler))
|
||||||
@@ -66,7 +60,7 @@ McuSupportOptions::McuSupportOptions(const SettingsHandler::Ptr &settingsHandler
|
|||||||
&McuAbstractPackage::changed,
|
&McuAbstractPackage::changed,
|
||||||
this,
|
this,
|
||||||
&McuSupportOptions::populatePackagesAndTargets);
|
&McuSupportOptions::populatePackagesAndTargets);
|
||||||
m_automaticKitCreation = automaticKitCreationFromSettings();
|
m_automaticKitCreation = settingsHandler->isAutomaticKitCreationEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportOptions::populatePackagesAndTargets()
|
void McuSupportOptions::populatePackagesAndTargets()
|
||||||
@@ -197,17 +191,4 @@ void McuSupportOptions::setAutomaticKitCreationEnabled(const bool enabled)
|
|||||||
m_automaticKitCreation = enabled;
|
m_automaticKitCreation = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportOptions::writeGeneralSettings() const
|
|
||||||
{
|
|
||||||
QSettings *settings = Core::ICore::settings(QSettings::UserScope);
|
|
||||||
settings->setValue(automaticKitCreationSettingsKey, m_automaticKitCreation);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool McuSupportOptions::automaticKitCreationFromSettings()
|
|
||||||
{
|
|
||||||
QSettings *settings = Core::ICore::settings(QSettings::UserScope);
|
|
||||||
const bool automaticKitCreation = settings->value(automaticKitCreationSettingsKey, true).toBool();
|
|
||||||
return automaticKitCreation;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace McuSupport::Internal
|
} // namespace McuSupport::Internal
|
||||||
|
@@ -87,8 +87,6 @@ public:
|
|||||||
|
|
||||||
bool automaticKitCreationEnabled() const;
|
bool automaticKitCreationEnabled() const;
|
||||||
void setAutomaticKitCreationEnabled(const bool enabled);
|
void setAutomaticKitCreationEnabled(const bool enabled);
|
||||||
void writeGeneralSettings() const;
|
|
||||||
static bool automaticKitCreationFromSettings();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsHandler::Ptr settingsHandler;
|
SettingsHandler::Ptr settingsHandler;
|
||||||
|
@@ -309,7 +309,7 @@ void McuSupportOptionsWidget::apply()
|
|||||||
{
|
{
|
||||||
bool pathsChanged = false;
|
bool pathsChanged = false;
|
||||||
|
|
||||||
m_options.writeGeneralSettings();
|
m_settingsHandler->setAutomaticKitCreation(m_options.automaticKitCreationEnabled());
|
||||||
pathsChanged |= m_options.qtForMCUsSdkPackage->writeToSettings();
|
pathsChanged |= m_options.qtForMCUsSdkPackage->writeToSettings();
|
||||||
for (auto package : qAsConst(m_options.sdkRepository.packages))
|
for (auto package : qAsConst(m_options.sdkRepository.packages))
|
||||||
pathsChanged |= package->writeToSettings();
|
pathsChanged |= package->writeToSettings();
|
||||||
|
@@ -30,8 +30,6 @@
|
|||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class FilePath;
|
class FilePath;
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
@@ -35,6 +35,12 @@ namespace McuSupport::Internal {
|
|||||||
|
|
||||||
using Utils::FilePath;
|
using Utils::FilePath;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const QString automaticKitCreationSettingsKey = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||||
|
+ QLatin1String(
|
||||||
|
Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||||
|
}
|
||||||
|
|
||||||
static FilePath packagePathFromSettings(const QString &settingsKey,
|
static FilePath packagePathFromSettings(const QString &settingsKey,
|
||||||
QSettings &settings,
|
QSettings &settings,
|
||||||
const FilePath &defaultPath)
|
const FilePath &defaultPath)
|
||||||
@@ -67,4 +73,18 @@ bool SettingsHandler::write(const QString &settingsKey,
|
|||||||
|
|
||||||
return savedPath != path;
|
return savedPath != path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingsHandler::isAutomaticKitCreationEnabled() const
|
||||||
|
{
|
||||||
|
QSettings *settings = Core::ICore::settings(QSettings::UserScope);
|
||||||
|
const bool automaticKitCreation = settings->value(automaticKitCreationSettingsKey, true).toBool();
|
||||||
|
return automaticKitCreation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsHandler::setAutomaticKitCreation(bool isEnabled)
|
||||||
|
{
|
||||||
|
QSettings *settings = Core::ICore::settings(QSettings::UserScope);
|
||||||
|
settings->setValue(automaticKitCreationSettingsKey, isEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace McuSupport::Internal
|
} // namespace McuSupport::Internal
|
||||||
|
@@ -46,5 +46,8 @@ public:
|
|||||||
virtual bool write(const QString &settingsKey,
|
virtual bool write(const QString &settingsKey,
|
||||||
const Utils::FilePath &path,
|
const Utils::FilePath &path,
|
||||||
const Utils::FilePath &defaultPath) const;
|
const Utils::FilePath &defaultPath) const;
|
||||||
|
|
||||||
|
virtual bool isAutomaticKitCreationEnabled() const;
|
||||||
|
void setAutomaticKitCreation(bool isEnabled);
|
||||||
}; //class SettingsHandler
|
}; //class SettingsHandler
|
||||||
} // namespace McuSupport::Internal
|
} // namespace McuSupport::Internal
|
||||||
|
Reference in New Issue
Block a user