-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9082 from ivangrek/settings/cleanup_3
Fix settings saving for "Detailed" section by selected setting source
- Loading branch information
Showing
18 changed files
with
399 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using GitUIPluginInterfaces; | ||
using GitUIPluginInterfaces.Settings; | ||
|
||
namespace GitCommands.Settings | ||
{ | ||
internal sealed class BuildServerSettings : IBuildServerSettings | ||
{ | ||
private const string BuildServerGroupName = "BuildServer"; | ||
|
||
private const string? TypeDefault = null; | ||
private const bool EnableIntegrationDefault = false; | ||
private const bool ShowBuildResultPageDefault = true; | ||
|
||
private readonly ISettingsSource _settingsSource; | ||
|
||
public BuildServerSettings(ISettingsSource settingsSource) | ||
{ | ||
_settingsSource = settingsSource; | ||
} | ||
|
||
public string? Type | ||
{ | ||
get => _settingsSource.GetString($"{BuildServerGroupName}.{nameof(Type)}", TypeDefault); | ||
set | ||
{ | ||
if (Type == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetString($"{BuildServerGroupName}.{nameof(Type)}", value); | ||
} | ||
} | ||
|
||
public bool EnableIntegration | ||
{ | ||
get => _settingsSource.GetBool($"{BuildServerGroupName}.{nameof(EnableIntegration)}", EnableIntegrationDefault); | ||
set | ||
{ | ||
if (EnableIntegration == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetBool($"{BuildServerGroupName}.{nameof(EnableIntegration)}", value); | ||
} | ||
} | ||
|
||
public bool ShowBuildResultPage | ||
{ | ||
get => _settingsSource.GetBool($"{BuildServerGroupName}.{nameof(ShowBuildResultPage)}", ShowBuildResultPageDefault); | ||
set | ||
{ | ||
if (ShowBuildResultPage == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetBool($"{BuildServerGroupName}.{nameof(ShowBuildResultPage)}", value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using GitUIPluginInterfaces; | ||
using GitUIPluginInterfaces.Settings; | ||
|
||
namespace GitCommands.Settings | ||
{ | ||
internal sealed class DetachedSettings : IDetachedSettings | ||
{ | ||
private const string DictionaryDefault = "en-US"; | ||
private const bool NoFastForwardMergeDefault = false; | ||
|
||
private readonly ISettingsSource _settingsSource; | ||
|
||
public DetachedSettings(ISettingsSource settingsSource) | ||
{ | ||
_settingsSource = settingsSource; | ||
} | ||
|
||
public string Dictionary | ||
{ | ||
get => _settingsSource.GetString(nameof(Dictionary).ToLower(), DictionaryDefault); | ||
set | ||
{ | ||
if (Dictionary == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetString(nameof(Dictionary).ToLower(), value); | ||
} | ||
} | ||
|
||
public bool NoFastForwardMerge | ||
{ | ||
get => _settingsSource.GetBool(nameof(NoFastForwardMerge), NoFastForwardMergeDefault); | ||
set | ||
{ | ||
if (NoFastForwardMerge == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetBool(nameof(NoFastForwardMerge), value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using GitUIPluginInterfaces; | ||
using GitUIPluginInterfaces.Settings; | ||
|
||
namespace GitCommands.Settings | ||
{ | ||
internal sealed class DetailedSettings : IDetailedSettings | ||
{ | ||
private const string DetailedGroupName = "Detailed"; | ||
|
||
private const string SmtpServerDefault = "smtp.gmail.com"; | ||
private const int SmtpPortDefault = 465; | ||
private const bool SmtpUseSslDefault = true; | ||
private const bool GetRemoteBranchesDirectlyFromRemoteDefault = false; | ||
private const bool AddMergeLogMessagesDefault = false; | ||
private const int MergeLogMessagesCountDefault = 20; | ||
|
||
private readonly ISettingsSource _settingsSource; | ||
|
||
public DetailedSettings(ISettingsSource settingsSource) | ||
{ | ||
_settingsSource = settingsSource; | ||
} | ||
|
||
public string SmtpServer | ||
{ | ||
get => _settingsSource.GetString(nameof(SmtpServer), SmtpServerDefault); | ||
set | ||
{ | ||
if (SmtpServer == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetString(nameof(SmtpServer), value); | ||
} | ||
} | ||
|
||
public int SmtpPort | ||
{ | ||
get => _settingsSource.GetInt(nameof(SmtpPort), SmtpPortDefault); | ||
set | ||
{ | ||
if (SmtpPort == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetInt(nameof(SmtpPort), value); | ||
} | ||
} | ||
|
||
public bool SmtpUseSsl | ||
{ | ||
get => _settingsSource.GetBool(nameof(SmtpUseSsl), SmtpUseSslDefault); | ||
set | ||
{ | ||
if (SmtpUseSsl == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetBool(nameof(SmtpUseSsl), value); | ||
} | ||
} | ||
|
||
public bool GetRemoteBranchesDirectlyFromRemote | ||
{ | ||
get => _settingsSource.GetBool($"{DetailedGroupName}.{nameof(GetRemoteBranchesDirectlyFromRemote)}", GetRemoteBranchesDirectlyFromRemoteDefault); | ||
set | ||
{ | ||
if (GetRemoteBranchesDirectlyFromRemote == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetBool($"{DetailedGroupName}.{nameof(GetRemoteBranchesDirectlyFromRemote)}", value); | ||
} | ||
} | ||
|
||
public bool AddMergeLogMessages | ||
{ | ||
get => _settingsSource.GetBool($"{DetailedGroupName}.{nameof(AddMergeLogMessages)}", AddMergeLogMessagesDefault); | ||
set | ||
{ | ||
if (AddMergeLogMessages == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetBool($"{DetailedGroupName}.{nameof(AddMergeLogMessages)}", value); | ||
} | ||
} | ||
|
||
public int MergeLogMessagesCount | ||
{ | ||
get => _settingsSource.GetInt($"{DetailedGroupName}.{nameof(MergeLogMessagesCount)}", MergeLogMessagesCountDefault); | ||
set | ||
{ | ||
if (MergeLogMessagesCount == value) | ||
{ | ||
return; | ||
} | ||
|
||
_settingsSource.SetInt($"{DetailedGroupName}.{nameof(MergeLogMessagesCount)}", value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using GitUIPluginInterfaces; | ||
using GitUIPluginInterfaces.Settings; | ||
|
||
namespace GitCommands.Settings | ||
{ | ||
public static class SettingsSourceExtension | ||
{ | ||
public static ISettingsSource ByPath(this ISettingsSource settingsSource, string pathName) | ||
=> new SettingsPath(settingsSource, pathName); | ||
|
||
public static IDetailedSettings Detailed(this ISettingsSource settingsSource) | ||
=> new DetailedSettings(settingsSource); | ||
|
||
public static IBuildServerSettings BuildServer(this ISettingsSource settingsSource) | ||
=> new BuildServerSettings(settingsSource); | ||
|
||
public static IDetachedSettings Detached(this ISettingsSource settingsSource) | ||
=> new DetachedSettings(settingsSource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.