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 const QString &environmentVariableName() const = 0;
|
||||||
virtual void setAddToPath(bool) = 0;
|
virtual void setAddToPath(bool) = 0;
|
||||||
virtual bool addToPath() const = 0;
|
virtual bool addToPath() const = 0;
|
||||||
virtual void writeGeneralSettings() const = 0;
|
|
||||||
virtual bool writeToSettings() const = 0;
|
virtual bool writeToSettings() const = 0;
|
||||||
virtual void setRelativePathModifier(const QString &) = 0;
|
virtual void setRelativePathModifier(const QString &) = 0;
|
||||||
virtual void setVersions(const QStringList &) = 0;
|
virtual void setVersions(const QStringList &) = 0;
|
||||||
|
|
||||||
virtual bool automaticKitCreationEnabled() const = 0;
|
|
||||||
virtual void setAutomaticKitCreationEnabled(const bool enabled) = 0;
|
|
||||||
|
|
||||||
virtual QWidget *widget() = 0;
|
virtual QWidget *widget() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@@ -387,7 +387,7 @@ void createAutomaticKits()
|
|||||||
auto qtForMCUsPackage = Sdk::createQtForMCUsPackage();
|
auto qtForMCUsPackage = Sdk::createQtForMCUsPackage();
|
||||||
|
|
||||||
const auto createKits = [qtForMCUsPackage]() {
|
const auto createKits = [qtForMCUsPackage]() {
|
||||||
if (qtForMCUsPackage->automaticKitCreationEnabled()) {
|
if (McuSupportOptions::automaticKitCreationFromSettings()) {
|
||||||
qtForMCUsPackage->updateStatus();
|
qtForMCUsPackage->updateStatus();
|
||||||
if (!qtForMCUsPackage->validStatus()) {
|
if (!qtForMCUsPackage->validStatus()) {
|
||||||
switch (qtForMCUsPackage->status()) {
|
switch (qtForMCUsPackage->status()) {
|
||||||
|
@@ -41,15 +41,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace McuSupport::Internal {
|
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,
|
McuPackage::McuPackage(const QString &label,
|
||||||
const FilePath &defaultPath,
|
const FilePath &defaultPath,
|
||||||
const QString &detectionPath,
|
const QString &detectionPath,
|
||||||
@@ -66,7 +57,6 @@ McuPackage::McuPackage(const QString &label,
|
|||||||
, m_downloadUrl(downloadUrl)
|
, m_downloadUrl(downloadUrl)
|
||||||
{
|
{
|
||||||
m_path = Sdk::packagePathFromSettings(settingsKey, QSettings::UserScope, m_defaultPath);
|
m_path = Sdk::packagePathFromSettings(settingsKey, QSettings::UserScope, m_defaultPath);
|
||||||
m_automaticKitCreation = automaticKitCreationFromSettings(QSettings::UserScope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath McuPackage::basePath() const
|
FilePath McuPackage::basePath() const
|
||||||
@@ -162,14 +152,6 @@ bool McuPackage::addToPath() const
|
|||||||
return m_addToPath;
|
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
|
bool McuPackage::writeToSettings() const
|
||||||
{
|
{
|
||||||
const FilePath savedPath = Sdk::packagePathFromSettings(m_settingsKey,
|
const FilePath savedPath = Sdk::packagePathFromSettings(m_settingsKey,
|
||||||
@@ -192,16 +174,6 @@ void McuPackage::setVersions(const QStringList &versions)
|
|||||||
m_versions = versions;
|
m_versions = versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool McuPackage::automaticKitCreationEnabled() const
|
|
||||||
{
|
|
||||||
return m_automaticKitCreation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void McuPackage::setAutomaticKitCreationEnabled(const bool enabled)
|
|
||||||
{
|
|
||||||
m_automaticKitCreation = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void McuPackage::updatePath()
|
void McuPackage::updatePath()
|
||||||
{
|
{
|
||||||
m_path = m_fileChooser->rawFilePath();
|
m_path = m_fileChooser->rawFilePath();
|
||||||
|
@@ -74,15 +74,10 @@ public:
|
|||||||
bool validStatus() const override;
|
bool validStatus() const override;
|
||||||
void setAddToPath(bool addToPath) override;
|
void setAddToPath(bool addToPath) override;
|
||||||
bool addToPath() const override;
|
bool addToPath() const override;
|
||||||
void writeGeneralSettings() const override;
|
|
||||||
bool writeToSettings() const override;
|
bool writeToSettings() const override;
|
||||||
void setRelativePathModifier(const QString &path) override;
|
void setRelativePathModifier(const QString &path) override;
|
||||||
void setVersions(const QStringList &versions) 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;
|
QWidget *widget() override;
|
||||||
|
|
||||||
const QString &environmentVariableName() const override;
|
const QString &environmentVariableName() const override;
|
||||||
@@ -108,7 +103,6 @@ private:
|
|||||||
const QString m_environmentVariableName;
|
const QString m_environmentVariableName;
|
||||||
const QString m_downloadUrl;
|
const QString m_downloadUrl;
|
||||||
bool m_addToPath = false;
|
bool m_addToPath = false;
|
||||||
bool m_automaticKitCreation = true;
|
|
||||||
|
|
||||||
Status m_status = Status::InvalidPath;
|
Status m_status = Status::InvalidPath;
|
||||||
};
|
};
|
||||||
|
@@ -70,6 +70,7 @@ McuSupportOptions::McuSupportOptions(QObject *parent)
|
|||||||
&McuAbstractPackage::changed,
|
&McuAbstractPackage::changed,
|
||||||
this,
|
this,
|
||||||
&McuSupportOptions::populatePackagesAndTargets);
|
&McuSupportOptions::populatePackagesAndTargets);
|
||||||
|
m_automaticKitCreation = automaticKitCreationFromSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
McuSupportOptions::~McuSupportOptions()
|
McuSupportOptions::~McuSupportOptions()
|
||||||
@@ -434,5 +435,33 @@ bool McuSupportOptions::kitsNeedQtVersion()
|
|||||||
return !HostOsInfo::isWindowsHost();
|
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 Internal
|
||||||
} // namespace McuSupport
|
} // namespace McuSupport
|
||||||
|
@@ -91,9 +91,15 @@ public:
|
|||||||
void populatePackagesAndTargets();
|
void populatePackagesAndTargets();
|
||||||
|
|
||||||
static bool kitsNeedQtVersion();
|
static bool kitsNeedQtVersion();
|
||||||
|
|
||||||
|
bool automaticKitCreationEnabled() const;
|
||||||
|
void setAutomaticKitCreationEnabled(const bool enabled);
|
||||||
|
void writeGeneralSettings() const;
|
||||||
|
static bool automaticKitCreationFromSettings();
|
||||||
private:
|
private:
|
||||||
void deletePackagesAndTargets();
|
void deletePackagesAndTargets();
|
||||||
|
|
||||||
|
bool m_automaticKitCreation = true;
|
||||||
signals:
|
signals:
|
||||||
void packagesChanged();
|
void packagesChanged();
|
||||||
};
|
};
|
||||||
|
@@ -146,7 +146,7 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
|
|||||||
m_kitAutomaticCreationCheckBox = new QCheckBox(
|
m_kitAutomaticCreationCheckBox = new QCheckBox(
|
||||||
tr("Automatically create kits for all available targets on start"));
|
tr("Automatically create kits for all available targets on start"));
|
||||||
connect(m_kitAutomaticCreationCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
|
connect(m_kitAutomaticCreationCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
|
||||||
m_options.qtForMCUsSdkPackage->setAutomaticKitCreationEnabled(
|
m_options.setAutomaticKitCreationEnabled(
|
||||||
state == Qt::CheckState::Checked);
|
state == Qt::CheckState::Checked);
|
||||||
});
|
});
|
||||||
mainLayout->addWidget(m_kitAutomaticCreationCheckBox);
|
mainLayout->addWidget(m_kitAutomaticCreationCheckBox);
|
||||||
@@ -245,8 +245,7 @@ void McuSupportOptionsWidget::updateStatus()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Automatic Kit creation
|
// Automatic Kit creation
|
||||||
m_kitAutomaticCreationCheckBox->setChecked(
|
m_kitAutomaticCreationCheckBox->setChecked(m_options.automaticKitCreationEnabled());
|
||||||
m_options.qtForMCUsSdkPackage->automaticKitCreationEnabled());
|
|
||||||
|
|
||||||
// Status label in the bottom
|
// Status label in the bottom
|
||||||
{
|
{
|
||||||
@@ -300,7 +299,7 @@ void McuSupportOptionsWidget::apply()
|
|||||||
{
|
{
|
||||||
bool pathsChanged = false;
|
bool pathsChanged = false;
|
||||||
|
|
||||||
m_options.qtForMCUsSdkPackage->writeGeneralSettings();
|
m_options.writeGeneralSettings();
|
||||||
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();
|
||||||
|
@@ -45,19 +45,13 @@ public:
|
|||||||
|
|
||||||
MOCK_METHOD(Status, status, (), (const));
|
MOCK_METHOD(Status, status, (), (const));
|
||||||
MOCK_METHOD(bool, validStatus, (), (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(const QString &, environmentVariableName, (), (const));
|
||||||
MOCK_METHOD(void, setAddToPath, (bool) );
|
MOCK_METHOD(void, setAddToPath, (bool) );
|
||||||
MOCK_METHOD(bool, addToPath, (), (const));
|
MOCK_METHOD(bool, addToPath, (), (const));
|
||||||
MOCK_METHOD(void, writeGeneralSettings, (), (const));
|
|
||||||
MOCK_METHOD(bool, writeToSettings, (), (const));
|
MOCK_METHOD(bool, writeToSettings, (), (const));
|
||||||
MOCK_METHOD(void, setRelativePathModifier, (const QString &) );
|
MOCK_METHOD(void, setRelativePathModifier, (const QString &) );
|
||||||
MOCK_METHOD(void, setVersions, (const QStringList &) );
|
MOCK_METHOD(void, setVersions, (const QStringList &) );
|
||||||
|
|
||||||
MOCK_METHOD(bool, automaticKitCreationEnabled, (), (const));
|
|
||||||
MOCK_METHOD(void, setAutomaticKitCreationEnabled, (const bool enabled));
|
|
||||||
|
|
||||||
MOCK_METHOD(QWidget *, widget, ());
|
MOCK_METHOD(QWidget *, widget, ());
|
||||||
}; // class PackageMock
|
}; // class PackageMock
|
||||||
} // namespace McuSupport::Internal
|
} // namespace McuSupport::Internal
|
||||||
|
Reference in New Issue
Block a user