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