Skip to content

Commit ddc6af5

Browse files
committed
Allow modifying Setting via result
1 parent 05104a5 commit ddc6af5

File tree

2 files changed

+10
-48
lines changed

2 files changed

+10
-48
lines changed

Flow.Launcher.Core/Plugin/JsonPRCModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,7 @@ public class JsonRPCClientRequestModel : JsonRPCRequestModel
9090
public class JsonRPCResult : Result
9191
{
9292
public JsonRPCClientRequestModel JsonRPCAction { get; set; }
93+
94+
public Dictionary<string, object> SettingsChange { get; set; }
9395
}
9496
}

Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ private List<Result> ParseResults(JsonRPCQueryResponseModel queryResponseModel)
109109
{
110110
result.Action = c =>
111111
{
112+
if (result.SettingsChange is not null)
113+
{
114+
foreach (var (key, value) in result.SettingsChange)
115+
{
116+
Settings[key] = value;
117+
}
118+
}
119+
112120
if (result.JsonRPCAction == null) return false;
113121

114122
if (string.IsNullOrEmpty(result.JsonRPCAction.Method))
@@ -442,54 +450,6 @@ public Control CreateSettingPanel()
442450
panel.Children.Add(contentControl);
443451
mainPanel.Children.Add(panel);
444452
}
445-
446-
// foreach (var (key, value) in Settings)
447-
// {
448-
// var panel = new StackPanel
449-
// {
450-
// Orientation = Orientation.Horizontal, Margin = settingControlMargin
451-
// };
452-
// var name = new Label
453-
// {
454-
// Content = key, VerticalAlignment = VerticalAlignment.Center
455-
// };
456-
// UIElement content = null;
457-
// switch (value)
458-
// {
459-
// case int i:
460-
// case double d:
461-
// throw new TypeAccessException();
462-
// case string s:
463-
// var textBox = new TextBox
464-
// {
465-
// Text = s,
466-
// Margin = settingControlMargin,
467-
// VerticalAlignment = VerticalAlignment.Center
468-
// };
469-
// textBox.TextChanged += (_, _) =>
470-
// {
471-
// Settings[key] = textBox.Text;
472-
// };
473-
// content = textBox;
474-
// break;
475-
// case bool b:
476-
// var checkBox = new CheckBox
477-
// {
478-
// IsChecked = b,
479-
// Margin = settingControlMargin,
480-
// VerticalAlignment = VerticalAlignment.Center
481-
// };
482-
// checkBox.Click += (_, _) =>
483-
// {
484-
// Settings[key] = checkBox.IsChecked;
485-
// };
486-
// content = checkBox;
487-
// break;
488-
// default:
489-
// throw new ArgumentOutOfRangeException();
490-
// }
491-
//
492-
// }
493453
return settingWindow;
494454
}
495455
public void Save()

0 commit comments

Comments
 (0)