forked from qt-creator/qt-creator
McuSupport: move auto-kit-creation option to McuSupportOptions
It was part of McuPackage, and only used by the SDK instance. Task-number: QTCREATORBUG-27093 Change-Id: I9d9eaac621e9997129c227fae3ac88b502ba4340 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -58,14 +58,10 @@ public:
|
||||
virtual const QString &environmentVariableName() const = 0;
|
||||
virtual void setAddToPath(bool) = 0;
|
||||
virtual bool addToPath() const = 0;
|
||||
virtual void writeGeneralSettings() const = 0;
|
||||
virtual bool writeToSettings() const = 0;
|
||||
virtual void setRelativePathModifier(const QString &) = 0;
|
||||
virtual void setVersions(const QStringList &) = 0;
|
||||
|
||||
virtual bool automaticKitCreationEnabled() const = 0;
|
||||
virtual void setAutomaticKitCreationEnabled(const bool enabled) = 0;
|
||||
|
||||
virtual QWidget *widget() = 0;
|
||||
|
||||
signals:
|
||||
|
@@ -387,7 +387,7 @@ void createAutomaticKits()
|
||||
auto qtForMCUsPackage = Sdk::createQtForMCUsPackage();
|
||||
|
||||
const auto createKits = [qtForMCUsPackage]() {
|
||||
if (qtForMCUsPackage->automaticKitCreationEnabled()) {
|
||||
if (McuSupportOptions::automaticKitCreationFromSettings()) {
|
||||
qtForMCUsPackage->updateStatus();
|
||||
if (!qtForMCUsPackage->validStatus()) {
|
||||
switch (qtForMCUsPackage->status()) {
|
||||
|
@@ -41,15 +41,6 @@ using namespace Utils;
|
||||
|
||||
namespace McuSupport::Internal {
|
||||
|
||||
static bool automaticKitCreationFromSettings(QSettings::Scope scope = QSettings::UserScope)
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings(scope);
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||
+ QLatin1String(Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||
bool automaticKitCreation = settings->value(key, true).toBool();
|
||||
return automaticKitCreation;
|
||||
}
|
||||
|
||||
McuPackage::McuPackage(const QString &label,
|
||||
const FilePath &defaultPath,
|
||||
const QString &detectionPath,
|
||||
@@ -66,7 +57,6 @@ McuPackage::McuPackage(const QString &label,
|
||||
, m_downloadUrl(downloadUrl)
|
||||
{
|
||||
m_path = Sdk::packagePathFromSettings(settingsKey, QSettings::UserScope, m_defaultPath);
|
||||
m_automaticKitCreation = automaticKitCreationFromSettings(QSettings::UserScope);
|
||||
}
|
||||
|
||||
FilePath McuPackage::basePath() const
|
||||
@@ -162,14 +152,6 @@ bool McuPackage::addToPath() const
|
||||
return m_addToPath;
|
||||
}
|
||||
|
||||
void McuPackage::writeGeneralSettings() const
|
||||
{
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||
+ QLatin1String(Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->setValue(key, m_automaticKitCreation);
|
||||
}
|
||||
|
||||
bool McuPackage::writeToSettings() const
|
||||
{
|
||||
const FilePath savedPath = Sdk::packagePathFromSettings(m_settingsKey,
|
||||
@@ -192,16 +174,6 @@ void McuPackage::setVersions(const QStringList &versions)
|
||||
m_versions = versions;
|
||||
}
|
||||
|
||||
bool McuPackage::automaticKitCreationEnabled() const
|
||||
{
|
||||
return m_automaticKitCreation;
|
||||
}
|
||||
|
||||
void McuPackage::setAutomaticKitCreationEnabled(const bool enabled)
|
||||
{
|
||||
m_automaticKitCreation = enabled;
|
||||
}
|
||||
|
||||
void McuPackage::updatePath()
|
||||
{
|
||||
m_path = m_fileChooser->rawFilePath();
|
||||
|
@@ -74,15 +74,10 @@ public:
|
||||
bool validStatus() const override;
|
||||
void setAddToPath(bool addToPath) override;
|
||||
bool addToPath() const override;
|
||||
void writeGeneralSettings() const override;
|
||||
bool writeToSettings() const override;
|
||||
void setRelativePathModifier(const QString &path) override;
|
||||
void setVersions(const QStringList &versions) override;
|
||||
|
||||
//TODO(piotr.mucko): Why every package knows about automatic kit creation. This should be outside of this class.
|
||||
bool automaticKitCreationEnabled() const override;
|
||||
void setAutomaticKitCreationEnabled(const bool enabled) override;
|
||||
|
||||
QWidget *widget() override;
|
||||
|
||||
const QString &environmentVariableName() const override;
|
||||
@@ -108,7 +103,6 @@ private:
|
||||
const QString m_environmentVariableName;
|
||||
const QString m_downloadUrl;
|
||||
bool m_addToPath = false;
|
||||
bool m_automaticKitCreation = true;
|
||||
|
||||
Status m_status = Status::InvalidPath;
|
||||
};
|
||||
|
@@ -70,6 +70,7 @@ McuSupportOptions::McuSupportOptions(QObject *parent)
|
||||
&McuAbstractPackage::changed,
|
||||
this,
|
||||
&McuSupportOptions::populatePackagesAndTargets);
|
||||
m_automaticKitCreation = automaticKitCreationFromSettings();
|
||||
}
|
||||
|
||||
McuSupportOptions::~McuSupportOptions()
|
||||
@@ -434,5 +435,33 @@ bool McuSupportOptions::kitsNeedQtVersion()
|
||||
return !HostOsInfo::isWindowsHost();
|
||||
}
|
||||
|
||||
|
||||
bool McuSupportOptions::automaticKitCreationEnabled() const
|
||||
{
|
||||
return m_automaticKitCreation;
|
||||
}
|
||||
|
||||
void McuSupportOptions::setAutomaticKitCreationEnabled(const bool enabled)
|
||||
{
|
||||
m_automaticKitCreation = enabled;
|
||||
}
|
||||
|
||||
void McuSupportOptions::writeGeneralSettings() const
|
||||
{
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||
+ QLatin1String(Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||
QSettings *settings = Core::ICore::settings(QSettings::UserScope);
|
||||
settings->setValue(key, m_automaticKitCreation);
|
||||
}
|
||||
|
||||
bool McuSupportOptions::automaticKitCreationFromSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings(QSettings::UserScope);
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||
+ QLatin1String(Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||
const bool automaticKitCreation = settings->value(key, true).toBool();
|
||||
return automaticKitCreation;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace McuSupport
|
||||
|
@@ -91,9 +91,15 @@ public:
|
||||
void populatePackagesAndTargets();
|
||||
|
||||
static bool kitsNeedQtVersion();
|
||||
|
||||
bool automaticKitCreationEnabled() const;
|
||||
void setAutomaticKitCreationEnabled(const bool enabled);
|
||||
void writeGeneralSettings() const;
|
||||
static bool automaticKitCreationFromSettings();
|
||||
private:
|
||||
void deletePackagesAndTargets();
|
||||
|
||||
bool m_automaticKitCreation = true;
|
||||
signals:
|
||||
void packagesChanged();
|
||||
};
|
||||
|
@@ -146,7 +146,7 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
|
||||
m_kitAutomaticCreationCheckBox = new QCheckBox(
|
||||
tr("Automatically create kits for all available targets on start"));
|
||||
connect(m_kitAutomaticCreationCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
|
||||
m_options.qtForMCUsSdkPackage->setAutomaticKitCreationEnabled(
|
||||
m_options.setAutomaticKitCreationEnabled(
|
||||
state == Qt::CheckState::Checked);
|
||||
});
|
||||
mainLayout->addWidget(m_kitAutomaticCreationCheckBox);
|
||||
@@ -245,8 +245,7 @@ void McuSupportOptionsWidget::updateStatus()
|
||||
}
|
||||
|
||||
// Automatic Kit creation
|
||||
m_kitAutomaticCreationCheckBox->setChecked(
|
||||
m_options.qtForMCUsSdkPackage->automaticKitCreationEnabled());
|
||||
m_kitAutomaticCreationCheckBox->setChecked(m_options.automaticKitCreationEnabled());
|
||||
|
||||
// Status label in the bottom
|
||||
{
|
||||
@@ -300,7 +299,7 @@ void McuSupportOptionsWidget::apply()
|
||||
{
|
||||
bool pathsChanged = false;
|
||||
|
||||
m_options.qtForMCUsSdkPackage->writeGeneralSettings();
|
||||
m_options.writeGeneralSettings();
|
||||
pathsChanged |= m_options.qtForMCUsSdkPackage->writeToSettings();
|
||||
for (auto package : qAsConst(m_options.sdkRepository.packages))
|
||||
pathsChanged |= package->writeToSettings();
|
||||
|
@@ -45,19 +45,13 @@ public:
|
||||
|
||||
MOCK_METHOD(Status, status, (), (const));
|
||||
MOCK_METHOD(bool, validStatus, (), (const));
|
||||
MOCK_METHOD(void, setDownloadUrl, (const QString &) );
|
||||
MOCK_METHOD(void, setEnvironmentVariableName, (const QString &) );
|
||||
MOCK_METHOD(const QString &, environmentVariableName, (), (const));
|
||||
MOCK_METHOD(void, setAddToPath, (bool) );
|
||||
MOCK_METHOD(bool, addToPath, (), (const));
|
||||
MOCK_METHOD(void, writeGeneralSettings, (), (const));
|
||||
MOCK_METHOD(bool, writeToSettings, (), (const));
|
||||
MOCK_METHOD(void, setRelativePathModifier, (const QString &) );
|
||||
MOCK_METHOD(void, setVersions, (const QStringList &) );
|
||||
|
||||
MOCK_METHOD(bool, automaticKitCreationEnabled, (), (const));
|
||||
MOCK_METHOD(void, setAutomaticKitCreationEnabled, (const bool enabled));
|
||||
|
||||
MOCK_METHOD(QWidget *, widget, ());
|
||||
}; // class PackageMock
|
||||
} // namespace McuSupport::Internal
|
||||
|
Reference in New Issue
Block a user