mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
Add afterload event for LoadDefaultConfig
This commit is contained in:
@@ -44,7 +44,10 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void LoadDefaultConfig() { }
|
||||
protected virtual T LoadDefaultConfig()
|
||||
{
|
||||
return storage;
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
@@ -61,19 +64,17 @@ namespace Wox.Infrastructure.Storage
|
||||
try
|
||||
{
|
||||
storage = JsonConvert.DeserializeObject<T>(json);
|
||||
OnAfterLoadConfig(storage);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//no-op
|
||||
LoadDefaultConfig();
|
||||
storage = LoadDefaultConfig();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadDefaultConfig();
|
||||
storage = LoadDefaultConfig();
|
||||
}
|
||||
|
||||
OnAfterLoadConfig(storage);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Wox.Infrastructure.Storage.UserSettings
|
||||
get { return "config"; }
|
||||
}
|
||||
|
||||
protected override void LoadDefaultConfig()
|
||||
protected override UserSettingStorage LoadDefaultConfig()
|
||||
{
|
||||
Theme = "Dark";
|
||||
ReplaceWinR = true;
|
||||
@@ -157,6 +157,8 @@ namespace Wox.Infrastructure.Storage.UserSettings
|
||||
OpacityMode = OpacityMode.Normal;
|
||||
LeaveCmdOpen = false;
|
||||
HideWhenDeactive = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected override void OnAfterLoadConfig(UserSettingStorage storage)
|
||||
|
||||
Reference in New Issue
Block a user