mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Support home state change & Add ui
This commit is contained in:
parent
d6704ed5da
commit
f2f4ebf0ac
7 changed files with 78 additions and 2 deletions
|
|
@ -221,6 +221,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
{
|
||||
API.LogException(ClassName, $"Fail to Init plugin: {pair.Metadata.Name}", e);
|
||||
pair.Metadata.Disabled = true;
|
||||
pair.Metadata.HomeDisabled = true;
|
||||
failedPlugins.Enqueue(pair);
|
||||
}
|
||||
}));
|
||||
|
|
@ -429,6 +430,11 @@ namespace Flow.Launcher.Core.Plugin
|
|||
return results;
|
||||
}
|
||||
|
||||
public static bool IsHomePlugin(string id)
|
||||
{
|
||||
return _homePlugins.Any(p => p.Metadata.ID == id);
|
||||
}
|
||||
|
||||
public static bool ActionKeywordRegistered(string actionKeyword)
|
||||
{
|
||||
// this method is only checking for action keywords (defined as not '*') registration
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
metadata.Disabled = settings.Disabled;
|
||||
metadata.Priority = settings.Priority;
|
||||
metadata.SearchDelayTime = settings.SearchDelayTime;
|
||||
metadata.HomeDisabled = settings.HomeDiabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -79,6 +80,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
DefaultActionKeywords = metadata.ActionKeywords, // metadata provides default values
|
||||
ActionKeywords = metadata.ActionKeywords, // use default value
|
||||
Disabled = metadata.Disabled,
|
||||
HomeDiabled = metadata.HomeDisabled,
|
||||
Priority = metadata.Priority,
|
||||
DefaultSearchDelayTime = metadata.SearchDelayTime, // metadata provides default values
|
||||
SearchDelayTime = metadata.SearchDelayTime, // use default value
|
||||
|
|
@ -128,5 +130,6 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
/// Used only to save the state of the plugin in settings
|
||||
/// </summary>
|
||||
public bool Disabled { get; set; }
|
||||
public bool HomeDiabled { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@ namespace Flow.Launcher.Plugin
|
|||
/// </summary>
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether plugin is disabled in home query.
|
||||
/// </summary>
|
||||
public bool HomeDisabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Plugin execute file path.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@
|
|||
<system:String x:Key="homePageToolTip">Show home page results when query text is empty.</system:String>
|
||||
<system:String x:Key="historyResultsForHomePage">Show History Results in Home Page</system:String>
|
||||
<system:String x:Key="historyResultsCountForHomePage">Maximum History Results Shown in Home Page</system:String>
|
||||
<system:String x:Key="homeToggleBoxToolTip">This can only be edited if plugin supports Home feature and Home Page is enabled.</system:String>
|
||||
|
||||
<!-- Setting Plugin -->
|
||||
<system:String x:Key="searchplugin">Search Plugin</system:String>
|
||||
|
|
@ -152,6 +153,7 @@
|
|||
<system:String x:Key="DisplayModeOnOff">Enabled</system:String>
|
||||
<system:String x:Key="DisplayModePriority">Priority</system:String>
|
||||
<system:String x:Key="DisplayModeSearchDelay">Search Delay</system:String>
|
||||
<system:String x:Key="DisplayModeHomeOnOff">Home Page</system:String>
|
||||
<system:String x:Key="currentPriority">Current Priority</system:String>
|
||||
<system:String x:Key="newPriority">New Priority</system:String>
|
||||
<system:String x:Key="priority">Priority</system:String>
|
||||
|
|
@ -405,6 +407,10 @@
|
|||
<system:String x:Key="searchDelayTimeTitle">Search Delay Time Setting</system:String>
|
||||
<system:String x:Key="searchDelayTimeTips">Input the search delay time in ms you like to use for the plugin. Input empty if you don't want to specify any, and the plugin will use default search delay time.</system:String>
|
||||
|
||||
<!-- Search Delay Settings Dialog -->
|
||||
<system:String x:Key="homeTitle">Home Page</system:String>
|
||||
<system:String x:Key="homeTips">Enable the plugin home page state if you like to show the plugin results when query is empty.</system:String>
|
||||
|
||||
<!-- Custom Query Hotkey Dialog -->
|
||||
<system:String x:Key="customeQueryHotkeyTitle">Custom Query Hotkey</system:String>
|
||||
<system:String x:Key="customeQueryHotkeyTips">Press a custom hotkey to open Flow Launcher and input the specified query automatically.</system:String>
|
||||
|
|
|
|||
|
|
@ -100,10 +100,19 @@
|
|||
ToolTipService.InitialShowDelay="0"
|
||||
ToolTipService.ShowOnDisabled="True"
|
||||
Value="{Binding PluginSearchDelayTime, Mode=TwoWay}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<!-- Put OnOffControl after PriorityControl & SearchDelayControl so that it can display correctly -->
|
||||
<ui:ToggleSwitch
|
||||
x:Name="HomeOnOffControl"
|
||||
Margin="0 0 8 0"
|
||||
IsEnabled="{Binding HomeEnabled}"
|
||||
IsOn="{Binding PluginHomeState}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
ToolTip="{DynamicResource homeToggleBoxToolTip}"
|
||||
Visibility="{Binding DataContext.IsHomeOnOffSelected, RelativeSource={RelativeSource AncestorType=ListBox}, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
|
||||
<ui:ToggleSwitch
|
||||
x:Name="OnOffControl"
|
||||
Margin="0 0 8 0"
|
||||
|
|
|
|||
|
|
@ -80,6 +80,20 @@ public partial class SettingsPanePluginsViewModel : BaseModel
|
|||
}
|
||||
}
|
||||
|
||||
private bool _isHomeOnOffSelected;
|
||||
public bool IsHomeOnOffSelected
|
||||
{
|
||||
get => _isHomeOnOffSelected;
|
||||
set
|
||||
{
|
||||
if (_isHomeOnOffSelected != value)
|
||||
{
|
||||
_isHomeOnOffSelected = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsPanePluginsViewModel(Settings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
|
|
@ -152,6 +166,18 @@ public partial class SettingsPanePluginsViewModel : BaseModel
|
|||
{
|
||||
Text = (string)Application.Current.Resources["searchDelayTimeTips"],
|
||||
TextWrapping = TextWrapping.Wrap
|
||||
},
|
||||
new TextBlock
|
||||
{
|
||||
Text = (string)Application.Current.Resources["homeTitle"],
|
||||
FontSize = 18,
|
||||
Margin = new Thickness(0, 24, 0, 10),
|
||||
TextWrapping = TextWrapping.Wrap
|
||||
},
|
||||
new TextBlock
|
||||
{
|
||||
Text = (string)Application.Current.Resources["homeTips"],
|
||||
TextWrapping = TextWrapping.Wrap
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -176,16 +202,25 @@ public partial class SettingsPanePluginsViewModel : BaseModel
|
|||
IsOnOffSelected = false;
|
||||
IsPrioritySelected = true;
|
||||
IsSearchDelaySelected = false;
|
||||
IsHomeOnOffSelected = false;
|
||||
break;
|
||||
case DisplayMode.SearchDelay:
|
||||
IsOnOffSelected = false;
|
||||
IsPrioritySelected = false;
|
||||
IsSearchDelaySelected = true;
|
||||
IsHomeOnOffSelected = false;
|
||||
break;
|
||||
case DisplayMode.HomeOnOff:
|
||||
IsOnOffSelected = false;
|
||||
IsPrioritySelected = false;
|
||||
IsSearchDelaySelected = false;
|
||||
IsHomeOnOffSelected = true;
|
||||
break;
|
||||
default:
|
||||
IsOnOffSelected = true;
|
||||
IsPrioritySelected = false;
|
||||
IsSearchDelaySelected = false;
|
||||
IsHomeOnOffSelected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -195,5 +230,6 @@ public enum DisplayMode
|
|||
{
|
||||
OnOff,
|
||||
Priority,
|
||||
SearchDelay
|
||||
SearchDelay,
|
||||
HomeOnOff
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,16 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
public bool PluginHomeState
|
||||
{
|
||||
get => !PluginPair.Metadata.HomeDisabled;
|
||||
set
|
||||
{
|
||||
PluginPair.Metadata.HomeDisabled = !value;
|
||||
PluginSettingsObject.HomeDiabled = !value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => _isExpanded;
|
||||
|
|
@ -154,6 +164,7 @@ namespace Flow.Launcher.ViewModel
|
|||
public Infrastructure.UserSettings.Plugin PluginSettingsObject{ get; init; }
|
||||
public bool SearchDelayEnabled => Settings.SearchQueryResultsWithDelay;
|
||||
public string DefaultSearchDelay => Settings.SearchDelayTime.ToString();
|
||||
public bool HomeEnabled => Settings.ShowHomePage && PluginManager.IsHomePlugin(PluginPair.Metadata.ID);
|
||||
|
||||
public void OnActionKeywordsTextChanged()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue