Merge branch 'Flow-Launcher:dev' into multiple_keywords

This commit is contained in:
Jack Ye 2025-02-21 12:19:56 +08:00 committed by GitHub
commit 26b2b593c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 10 additions and 56 deletions

View file

@ -112,7 +112,7 @@ namespace Flow.Launcher.Core.Plugin
public Control CreateSettingPanel()
{
if (Settings == null || Settings.Count == 0)
return new();
return null;
var settingWindow = new UserControl();
var mainPanel = new Grid { Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center };

View file

@ -13,14 +13,14 @@ namespace Flow.Launcher
public partial class CustomQueryHotkeySetting : Window
{
private SettingWindow _settingWidow;
private readonly Settings _settings;
private bool update;
private CustomPluginHotkey updateCustomHotkey;
public Settings Settings { get; }
public CustomQueryHotkeySetting(SettingWindow settingWidow, Settings settings)
{
_settingWidow = settingWidow;
Settings = settings;
_settings = settings;
InitializeComponent();
}
@ -33,13 +33,13 @@ namespace Flow.Launcher
{
if (!update)
{
Settings.CustomPluginHotkeys ??= new ObservableCollection<CustomPluginHotkey>();
_settings.CustomPluginHotkeys ??= new ObservableCollection<CustomPluginHotkey>();
var pluginHotkey = new CustomPluginHotkey
{
Hotkey = HotkeyControl.CurrentHotkey.ToString(), ActionKeyword = tbAction.Text
};
Settings.CustomPluginHotkeys.Add(pluginHotkey);
_settings.CustomPluginHotkeys.Add(pluginHotkey);
HotKeyMapper.SetCustomQueryHotkey(pluginHotkey);
}
@ -59,7 +59,7 @@ namespace Flow.Launcher
public void UpdateItem(CustomPluginHotkey item)
{
updateCustomHotkey = Settings.CustomPluginHotkeys.FirstOrDefault(o =>
updateCustomHotkey = _settings.CustomPluginHotkeys.FirstOrDefault(o =>
o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey);
if (updateCustomHotkey == null)
{
@ -77,8 +77,7 @@ namespace Flow.Launcher
private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e)
{
App.API.ChangeQuery(tbAction.Text);
Application.Current.MainWindow.Show();
Application.Current.MainWindow.Opacity = 1;
App.API.ShowMainWindow();
Application.Current.MainWindow.Focus();
}

View file

@ -65,8 +65,7 @@ namespace Flow.Launcher
private void BtnTestShortcut_OnClick(object sender, RoutedEventArgs e)
{
App.API.ChangeQuery(tbExpand.Text);
Application.Current.MainWindow.Show();
Application.Current.MainWindow.Opacity = 1;
App.API.ShowMainWindow();
Application.Current.MainWindow.Focus();
}
}

View file

@ -90,7 +90,7 @@ namespace Flow.Launcher.ViewModel
private Control _bottomPart2;
public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginDisplayBottomData() : null;
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider;
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider settingProvider && settingProvider.CreateSettingPanel() != null;
public Control SettingControl
=> IsExpanded
? _settingControl

View file

@ -42,7 +42,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup>

View file

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Controls;
namespace Flow.Launcher.Plugin.Url
{
public class Main : ISettingProvider,IPlugin, IPluginI18n
public class Main : IPlugin, IPluginI18n
{
//based on https://gist.github.com/dperini/729294
private const string urlPattern = "^" +
@ -43,7 +42,6 @@ namespace Flow.Launcher.Plugin.Url
Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
private PluginInitContext context;
private Settings _settings;
public List<Result> Query(Query query)
{
@ -82,12 +80,6 @@ namespace Flow.Launcher.Plugin.Url
return new List<Result>(0);
}
public Control CreateSettingPanel()
{
return new SettingsControl(context.API,_settings);
}
public bool IsURL(string raw)
{
raw = raw.ToLower();

View file

@ -1,17 +0,0 @@
<UserControl
x:Class="Flow.Launcher.Plugin.Url.SettingsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Height="0"
d:DesignHeight="300"
d:DesignWidth="500"
mc:Ignorable="d">
<Grid Margin="40,40,10,0">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</UserControl>

View file

@ -1,18 +0,0 @@
using System.Windows.Controls;
namespace Flow.Launcher.Plugin.Url
{
public partial class SettingsControl : UserControl
{
private Settings _settings;
private IPublicAPI _flowlauncherAPI;
public SettingsControl(IPublicAPI flowlauncherAPI,Settings settings)
{
InitializeComponent();
_settings = settings;
_flowlauncherAPI = flowlauncherAPI;
}
}
}