forked from qt-creator/qt-creator
McuSupport: Discard un-applied changes to Qul SDK package
The path to the Qul SDK entered in the settings path persisted in the UI when re-opening the settings page, even if it was not applied. Kits and the settings file are not affected unless pressing apply so this did not affect functionality. Un-applied changes are discarded by re-reading the path from the settings file in the constructor for the settings page. Task-number: QTCREATORBUG-28568 Change-Id: Id03be22fba429e4764493cd3bedf45faa6908637 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Yasser Grimes <yasser.grimes@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -47,6 +47,7 @@ public:
|
||||
virtual bool isValidStatus() const = 0;
|
||||
|
||||
virtual bool writeToSettings() const = 0;
|
||||
virtual void readFromSettings() = 0;
|
||||
|
||||
virtual QWidget *widget() = 0;
|
||||
virtual const McuPackageVersionDetector *getVersionDetector() const = 0;
|
||||
|
||||
@@ -244,6 +244,11 @@ bool McuPackage::writeToSettings() const
|
||||
return settingsHandler->write(m_settingsKey, m_path, m_defaultPath);
|
||||
}
|
||||
|
||||
void McuPackage::readFromSettings()
|
||||
{
|
||||
setPath(settingsHandler->getPath(m_settingsKey, QSettings::UserScope, m_defaultPath));
|
||||
}
|
||||
|
||||
QWidget *McuPackage::widget()
|
||||
{
|
||||
auto *widget = new QWidget;
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
QString statusText() const override;
|
||||
|
||||
bool writeToSettings() const override;
|
||||
void readFromSettings() override;
|
||||
|
||||
QWidget *widget() override;
|
||||
const McuPackageVersionDetector *getVersionDetector() const override;
|
||||
|
||||
@@ -90,6 +90,9 @@ McuSupportOptionsWidget::McuSupportOptionsWidget(McuSupportOptions &options,
|
||||
m_qtForMCUsSdkGroupBox = new QGroupBox(Tr::tr("Qt for MCUs SDK"));
|
||||
m_qtForMCUsSdkGroupBox->setFlat(true);
|
||||
auto *layout = new QVBoxLayout(m_qtForMCUsSdkGroupBox);
|
||||
// Re-read the qtForMCUs package from settings to discard un-applied changes from previous sessions
|
||||
m_options.qtForMCUsSdkPackage->readFromSettings();
|
||||
|
||||
layout->addWidget(m_options.qtForMCUsSdkPackage->widget());
|
||||
mainLayout->addWidget(m_qtForMCUsSdkGroupBox);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
MOCK_METHOD(QString, environmentVariableName, (), (const));
|
||||
MOCK_METHOD(bool, isAddToSystemPath, (), (const));
|
||||
MOCK_METHOD(bool, writeToSettings, (), (const));
|
||||
MOCK_METHOD(void, readFromSettings, ());
|
||||
MOCK_METHOD(QStringList, versions, (), (const));
|
||||
|
||||
MOCK_METHOD(QWidget *, widget, ());
|
||||
|
||||
Reference in New Issue
Block a user