Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Flow.Launcher.Core.Plugin
/// Represent the plugin that using JsonPRC
/// every JsonRPC plugin should has its own plugin instance
/// </summary>
internal abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable
public abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable
{
protected PluginInitContext Context;
public const string JsonRPC = "JsonRPC";
Expand Down Expand Up @@ -157,6 +157,11 @@ public void Save()
Settings?.Save();
}

public bool NeedCreateSettingPanel()
{
return Settings.NeedCreateSettingPanel();
}

public Control CreateSettingPanel()
{
return Settings.CreateSettingPanel();
Expand Down
9 changes: 7 additions & 2 deletions Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,15 @@ public void Save()
_storage.Save();
}

public bool NeedCreateSettingPanel()
{
// If there are no settings or the settings configuration is empty, return null
return Settings != null && Configuration != null && Configuration.Body.Count != 0;
}

public Control CreateSettingPanel()
{
if (Settings == null || Settings.Count == 0)
return null;
// No need to check if NeedCreateSettingPanel is true because CreateSettingPanel will only be called if it's true

var settingWindow = new UserControl();
var mainPanel = new Grid { Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center };
Expand Down
8 changes: 4 additions & 4 deletions Flow.Launcher/ViewModel/PluginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ public bool IsExpanded
private Control _bottomPart2;
public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginDisplayBottomData() : null;

public bool HasSettingControl => PluginPair.Plugin is ISettingProvider settingProvider && settingProvider.CreateSettingPanel() != null;
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider && (PluginPair.Plugin is not JsonRPCPluginBase jsonRPCPluginBase || jsonRPCPluginBase.NeedCreateSettingPanel());
public Control SettingControl
=> IsExpanded
? _settingControl
??= PluginPair.Plugin is not ISettingProvider settingProvider
? null
: settingProvider.CreateSettingPanel()
??= HasSettingControl
? ((ISettingProvider)PluginPair.Plugin).CreateSettingPanel()
: null
: null;
private ImageSource _image = ImageLoader.MissingImage;

Expand Down
Loading