mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into settings_panel
This commit is contained in:
commit
c848fab2d4
3 changed files with 18 additions and 11 deletions
|
|
@ -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";
|
||||
|
|
@ -157,6 +157,11 @@ namespace Flow.Launcher.Core.Plugin
|
|||
Settings?.Save();
|
||||
}
|
||||
|
||||
public bool NeedCreateSettingPanel()
|
||||
{
|
||||
return Settings.NeedCreateSettingPanel();
|
||||
}
|
||||
|
||||
public Control CreateSettingPanel()
|
||||
{
|
||||
return Settings.CreateSettingPanel();
|
||||
|
|
|
|||
|
|
@ -136,14 +136,16 @@ namespace Flow.Launcher.Core.Plugin
|
|||
{
|
||||
_storage.Save();
|
||||
}
|
||||
|
||||
public Control? CreateSettingPanel()
|
||||
|
||||
public bool NeedCreateSettingPanel()
|
||||
{
|
||||
// If there are no settings or the settings configuration is empty, return null
|
||||
if (Configuration == null || Settings == null || Configuration.Body.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return Settings != null && Configuration != null && Configuration.Body.Count != 0;
|
||||
}
|
||||
|
||||
public Control CreateSettingPanel()
|
||||
{
|
||||
// No need to check if NeedCreateSettingPanel is true because CreateSettingPanel will only be called if it's true
|
||||
|
||||
// Create main grid with two columns (Column 1: Auto, Column 2: *)
|
||||
var mainPanel = new Grid { Margin = SettingPanelMargin, VerticalAlignment = VerticalAlignment.Center };
|
||||
|
|
|
|||
|
|
@ -90,13 +90,13 @@ namespace Flow.Launcher.ViewModel
|
|||
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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue