Skip to content

Commit c848fab

Browse files
authored
Merge branch 'dev' into settings_panel
2 parents 20d0ed1 + bfdf565 commit c848fab

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Flow.Launcher.Core.Plugin
3434
/// Represent the plugin that using JsonPRC
3535
/// every JsonRPC plugin should has its own plugin instance
3636
/// </summary>
37-
internal abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable
37+
public abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable
3838
{
3939
protected PluginInitContext Context;
4040
public const string JsonRPC = "JsonRPC";
@@ -157,6 +157,11 @@ public void Save()
157157
Settings?.Save();
158158
}
159159

160+
public bool NeedCreateSettingPanel()
161+
{
162+
return Settings.NeedCreateSettingPanel();
163+
}
164+
160165
public Control CreateSettingPanel()
161166
{
162167
return Settings.CreateSettingPanel();

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,16 @@ public void Save()
136136
{
137137
_storage.Save();
138138
}
139-
140-
public Control? CreateSettingPanel()
139+
140+
public bool NeedCreateSettingPanel()
141141
{
142142
// If there are no settings or the settings configuration is empty, return null
143-
if (Configuration == null || Settings == null || Configuration.Body.Count == 0)
144-
{
145-
return null;
146-
}
143+
return Settings != null && Configuration != null && Configuration.Body.Count != 0;
144+
}
145+
146+
public Control CreateSettingPanel()
147+
{
148+
// No need to check if NeedCreateSettingPanel is true because CreateSettingPanel will only be called if it's true
147149

148150
// Create main grid with two columns (Column 1: Auto, Column 2: *)
149151
var mainPanel = new Grid { Margin = SettingPanelMargin, VerticalAlignment = VerticalAlignment.Center };

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ public bool IsExpanded
9090
private Control _bottomPart2;
9191
public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginDisplayBottomData() : null;
9292

93-
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider settingProvider && settingProvider.CreateSettingPanel() != null;
93+
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider && (PluginPair.Plugin is not JsonRPCPluginBase jsonRPCPluginBase || jsonRPCPluginBase.NeedCreateSettingPanel());
9494
public Control SettingControl
9595
=> IsExpanded
9696
? _settingControl
97-
??= PluginPair.Plugin is not ISettingProvider settingProvider
98-
? null
99-
: settingProvider.CreateSettingPanel()
97+
??= HasSettingControl
98+
? ((ISettingProvider)PluginPair.Plugin).CreateSettingPanel()
99+
: null
100100
: null;
101101
private ImageSource _image = ImageLoader.MissingImage;
102102

0 commit comments

Comments
 (0)