Skip to content

Commit 20ba2b2

Browse files
committed
Add SavePluginSettings API, and call that api in PluginManager.Save();
1 parent d84eff7 commit 20ba2b2

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static void Save()
5151
var savable = plugin.Plugin as ISavable;
5252
savable?.Save();
5353
}
54+
API.SavePluginSettings();
5455
}
5556

5657
public static async Task ReloadData()

Flow.Launcher.Plugin/IPublicAPI.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public interface IPublicAPI
3434
/// </summary>
3535
void SaveAppAllSettings();
3636

37+
/// <summary>
38+
/// Save Flow's plugins settings
39+
/// </summary>
40+
void SavePluginSettings();
41+
3742
/// <summary>
3843
/// Reloads any Plugins that have the
3944
/// IReloadable implemented. It refeshes

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,25 @@ public void RestartApp()
7676

7777
public void SaveAppAllSettings()
7878
{
79-
SaveAllJsonStorage();
79+
SavePluginSettings();
8080
_mainVM.Save();
8181
_settingsVM.Save();
82-
PluginManager.Save();
8382
ImageLoader.Save();
8483
}
8584

8685
public Task ReloadAllPluginData() => PluginManager.ReloadData();
8786

88-
public void ShowMsgError(string title, string subTitle = "") => ShowMsg(title, subTitle, Constant.ErrorIcon, true);
87+
public void ShowMsgError(string title, string subTitle = "") =>
88+
ShowMsg(title, subTitle, Constant.ErrorIcon, true);
8989

90-
public void ShowMsg(string title, string subTitle = "", string iconPath = "") => ShowMsg(title, subTitle, iconPath, true);
90+
public void ShowMsg(string title, string subTitle = "", string iconPath = "") =>
91+
ShowMsg(title, subTitle, iconPath, true);
9192

9293
public void ShowMsg(string title, string subTitle, string iconPath, bool useMainWindowAsOwner = true)
9394
{
9495
Application.Current.Dispatcher.Invoke(() =>
9596
{
96-
var msg = useMainWindowAsOwner ? new Msg { Owner = Application.Current.MainWindow } : new Msg();
97+
var msg = useMainWindowAsOwner ? new Msg {Owner = Application.Current.MainWindow} : new Msg();
9798
msg.Show(title, subTitle, iconPath);
9899
});
99100
}
@@ -114,37 +115,46 @@ public void OpenSettingDialog()
114115

115116
public List<PluginPair> GetAllPlugins() => PluginManager.AllPlugins.ToList();
116117

117-
public MatchResult FuzzySearch(string query, string stringToCompare) => StringMatcher.FuzzySearch(query, stringToCompare);
118+
public MatchResult FuzzySearch(string query, string stringToCompare) =>
119+
StringMatcher.FuzzySearch(query, stringToCompare);
118120

119121
public Task<string> HttpGetStringAsync(string url, CancellationToken token = default) => Http.GetAsync(url);
120122

121-
public Task<Stream> HttpGetStreamAsync(string url, CancellationToken token = default) => Http.GetStreamAsync(url);
123+
public Task<Stream> HttpGetStreamAsync(string url, CancellationToken token = default) =>
124+
Http.GetStreamAsync(url);
122125

123-
public Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath, CancellationToken token = default) => Http.DownloadAsync(url, filePath, token);
126+
public Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath,
127+
CancellationToken token = default) => Http.DownloadAsync(url, filePath, token);
124128

125-
public void AddActionKeyword(string pluginId, string newActionKeyword) => PluginManager.AddActionKeyword(pluginId, newActionKeyword);
129+
public void AddActionKeyword(string pluginId, string newActionKeyword) =>
130+
PluginManager.AddActionKeyword(pluginId, newActionKeyword);
126131

127-
public void RemoveActionKeyword(string pluginId, string oldActionKeyword) => PluginManager.RemoveActionKeyword(pluginId, oldActionKeyword);
132+
public void RemoveActionKeyword(string pluginId, string oldActionKeyword) =>
133+
PluginManager.RemoveActionKeyword(pluginId, oldActionKeyword);
128134

129-
public void LogDebug(string className, string message, [CallerMemberName] string methodName = "") => Log.Debug(className, message, methodName);
135+
public void LogDebug(string className, string message, [CallerMemberName] string methodName = "") =>
136+
Log.Debug(className, message, methodName);
130137

131-
public void LogInfo(string className, string message, [CallerMemberName] string methodName = "") => Log.Info(className, message, methodName);
138+
public void LogInfo(string className, string message, [CallerMemberName] string methodName = "") =>
139+
Log.Info(className, message, methodName);
132140

133-
public void LogWarn(string className, string message, [CallerMemberName] string methodName = "") => Log.Warn(className, message, methodName);
141+
public void LogWarn(string className, string message, [CallerMemberName] string methodName = "") =>
142+
Log.Warn(className, message, methodName);
134143

135-
public void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "") => Log.Exception(className, message, e, methodName);
144+
public void LogException(string className, string message, Exception e,
145+
[CallerMemberName] string methodName = "") => Log.Exception(className, message, e, methodName);
136146

137147
private readonly Dictionary<Type, object> _pluginJsonStorages = new();
138148

139-
private void SaveAllJsonStorage()
149+
public void SavePluginSettings()
140150
{
141151
foreach (var value in _pluginJsonStorages.Values)
142152
{
143153
var method = value.GetType().GetMethod("Save");
144154
method?.Invoke(value, null);
145155
}
146156
}
147-
157+
148158
public T LoadSettingJsonStorage<T>() where T : new()
149159
{
150160
var type = typeof(T);
@@ -181,11 +191,12 @@ private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, Spe
181191
{
182192
if (GlobalKeyboardEvent != null)
183193
{
184-
return GlobalKeyboardEvent((int)keyevent, vkcode, state);
194+
return GlobalKeyboardEvent((int) keyevent, vkcode, state);
185195
}
196+
186197
return true;
187198
}
188199

189200
#endregion
190201
}
191-
}
202+
}

0 commit comments

Comments
 (0)