IOS: Don't save default values needlessly

Change-Id: I127ee409f6bb0011704fcb08ef720a71fd084a16
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marcus Tillmanns
2024-01-31 12:06:58 +01:00
parent 813961babb
commit 78d42d2d54

View File

@@ -65,6 +65,8 @@ using ToolchainPair = std::pair<GccToolchain *, GccToolchain *>;
namespace Ios {
namespace Internal {
const bool IgnoreAllDevicesDefault = false;
const char SettingsGroup[] = "IosConfigurations";
const char ignoreAllDevicesKey[] = "IgnoreAllDevices";
const char screenshotDirPathKey[] = "ScreeshotDirPath";
@@ -365,12 +367,20 @@ QVersionNumber IosConfigurations::xcodeVersion()
return m_instance->m_xcodeVersion;
}
static FilePath defaultScreenshotDirPath()
{
return FilePath::fromUserInput(
QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).constFirst());
}
void IosConfigurations::save()
{
QtcSettings *settings = Core::ICore::settings();
settings->beginGroup(SettingsGroup);
settings->setValue(ignoreAllDevicesKey, m_ignoreAllDevices);
settings->setValue(screenshotDirPathKey, m_screenshotDir.toString());
settings->setValueWithDefault(ignoreAllDevicesKey, m_ignoreAllDevices, IgnoreAllDevicesDefault);
settings->setValueWithDefault(screenshotDirPathKey,
m_screenshotDir.toSettings(),
defaultScreenshotDirPath().toSettings());
settings->endGroup();
}
@@ -386,13 +396,11 @@ void IosConfigurations::load()
{
QtcSettings *settings = Core::ICore::settings();
settings->beginGroup(SettingsGroup);
m_ignoreAllDevices = settings->value(ignoreAllDevicesKey, false).toBool();
m_screenshotDir = FilePath::fromString(settings->value(screenshotDirPathKey).toString());
if (!m_screenshotDir.exists()) {
QString defaultDir =
QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).constFirst();
m_screenshotDir = FilePath::fromString(defaultDir);
}
m_ignoreAllDevices = settings->value(ignoreAllDevicesKey, IgnoreAllDevicesDefault).toBool();
m_screenshotDir = FilePath::fromSettings(settings->value(screenshotDirPathKey));
if (!m_screenshotDir.isWritableDir())
m_screenshotDir = defaultScreenshotDirPath();
settings->endGroup();
}