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
16 changes: 11 additions & 5 deletions Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,15 @@ public interface IPublicAPI
Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath, Action<double> reportProgress = null, CancellationToken token = default);

/// <summary>
/// Add ActionKeyword and update action keyword metadata for specific plugin
/// Add ActionKeyword and update action keyword metadata for specific plugin.
/// Before adding, please check if action keyword is already assigned by <see cref="ActionKeywordAssigned"/>
/// </summary>
/// <param name="pluginId">ID for plugin that needs to add action keyword</param>
/// <param name="newActionKeyword">The actionkeyword that is supposed to be added</param>
/// <remarks>
/// If new action keyword contains any whitespace, FL will still add it but it will not work for users.
/// So plugin should check the whitespace before calling this function.
/// </remarks>
void AddActionKeyword(string pluginId, string newActionKeyword);

/// <summary>
Expand Down Expand Up @@ -280,9 +284,10 @@ public interface IPublicAPI
T LoadSettingJsonStorage<T>() where T : new();

/// <summary>
/// Save JsonStorage for current plugin's setting. This is the method used to save settings to json in Flow.Launcher
/// Save JsonStorage for current plugin's setting. This is the method used to save settings to json in Flow.
/// This method will save the original instance loaded with LoadJsonStorage.
/// This API call is for manually Save. Flow will automatically save all setting type that has called LoadSettingJsonStorage or SaveSettingJsonStorage previously.
/// This API call is for manually Save.
/// Flow will automatically save all setting type that has called <see cref="LoadSettingJsonStorage"/> or <see cref="SaveSettingJsonStorage"/> previously.
/// </summary>
/// <typeparam name="T">Type for Serialization</typeparam>
/// <returns></returns>
Expand Down Expand Up @@ -424,9 +429,10 @@ public interface IPublicAPI
Task<T> LoadCacheBinaryStorageAsync<T>(string cacheName, string cacheDirectory, T defaultData) where T : new();

/// <summary>
/// Save BinaryStorage for current plugin's cache. This is the method used to save cache to binary in Flow.Launcher
/// Save BinaryStorage for current plugin's cache. This is the method used to save cache to binary in Flow.
/// This method will save the original instance loaded with LoadCacheBinaryStorageAsync.
/// This API call is for manually Save. Flow will automatically save all cache type that has called LoadCacheBinaryStorageAsync or SaveCacheBinaryStorageAsync previously.
/// This API call is for manually Save.
/// Flow will automatically save all cache type that has called <see cref="LoadCacheBinaryStorageAsync"/> or <see cref="SaveCacheBinaryStorageAsync"/> previously.
/// </summary>
/// <typeparam name="T">Type for Serialization</typeparam>
/// <param name="cacheName">Cache file name</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
Width="135"
HorizontalAlignment="Left"
VerticalAlignment="Center"
DataObject.Pasting="TextBox_Pasting"
PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"
Text="{Binding ActionKeyword}" />
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Input;
Expand Down Expand Up @@ -85,7 +86,7 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
DialogResult = false;
Close();
}

private void TxtCurrentActionKeyword_OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
Expand All @@ -94,14 +95,34 @@ private void TxtCurrentActionKeyword_OnKeyDown(object sender, KeyEventArgs e)
OnDoneButtonClick(sender, e);
e.Handled = true;
}
if (e.Key == Key.Space)
{
e.Handled = true;
}
}


private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(DataFormats.Text))
{
string text = e.DataObject.GetData(DataFormats.Text) as string;
if (!string.IsNullOrEmpty(text) && text.Any(char.IsWhiteSpace))
{
e.CancelCommand();
}
}
else
{
e.CancelCommand();
}
}

public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

private bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value))
Expand Down
36 changes: 19 additions & 17 deletions Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
</Button>
</Grid>
</StackPanel>
<StackPanel Margin="26,12,26,0">
<StackPanel Margin="26 12 26 0">
<Grid>
<StackPanel>
<StackPanel Grid.Row="0" Margin="0,0,0,12">
<StackPanel Grid.Row="0" Margin="0 0 0 12">
<TextBlock
Grid.Column="0"
Margin="0,0,0,0"
Margin="0 0 0 0"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource flowlauncher_plugin_websearch_window_title}"
Expand All @@ -75,15 +75,15 @@
TextAlignment="Left"
TextWrapping="WrapWithOverflow" />
<TextBox
Margin="0,12,0,12"
Margin="0 12 0 12"
FontSize="14"
FontWeight="SemiBold"
IsReadOnly="True"
Text="{DynamicResource flowlauncher_plugin_websearch_guide_2}"
TextAlignment="Center"
TextWrapping="WrapWithOverflow" />
<TextBlock
Margin="0,0,0,14"
Margin="0 0 0 14"
FontSize="14"
Text="{DynamicResource flowlauncher_plugin_websearch_guide_3}"
TextAlignment="Left"
Expand All @@ -105,7 +105,7 @@
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="10,10,15,10"
Margin="10 10 15 10"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FontSize="14"
Expand All @@ -120,7 +120,7 @@
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="10,10,15,10"
Margin="10 10 15 10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Expand All @@ -131,21 +131,21 @@
Orientation="Horizontal">
<Button
Height="35"
Margin="10,0,0,0"
Margin="10 0 0 0"
VerticalAlignment="Center"
Click="OnSelectIconClick"
Content="{DynamicResource flowlauncher_plugin_websearch_select_icon}" />
<Image
Name="imgPreviewIcon"
Width="24"
Height="24"
Margin="14,0,0,0"
Margin="14 0 0 0"
VerticalAlignment="Center" />
</StackPanel>
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="10,10,15,10"
Margin="10 10 15 10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Expand All @@ -160,30 +160,32 @@
<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="10,10,15,10"
Margin="10 10 15 10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource flowlauncher_plugin_websearch_action_keyword}" />
<TextBox
Grid.Row="3"
Grid.Column="1"
Margin="10,0,10,0"
Margin="10 0 10 0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DataObject.Pasting="TextBox_Pasting"
PreviewKeyDown="TextBox_PreviewKeyDown"
Text="{Binding SearchSource.ActionKeyword}" />
<TextBlock
Grid.Row="4"
Grid.Column="0"
Margin="10,10,15,15"
Margin="10 10 15 15"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource flowlauncher_plugin_websearch_enabled_label}" />
<CheckBox
Grid.Row="4"
Grid.Column="1"
Margin="10,10,10,15"
Margin="10 10 10 15"
VerticalAlignment="Center"
IsChecked="{Binding SearchSource.Enabled}" />
</Grid>
Expand All @@ -196,16 +198,16 @@
Grid.Row="1"
Background="{DynamicResource PopupButtonAreaBGColor}"
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
BorderThickness="0,1,0,0">
BorderThickness="0 1 0 0">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button
MinWidth="140"
Margin="10,0,5,0"
Margin="10 0 5 0"
Click="OnCancelButtonClick"
Content="{DynamicResource flowlauncher_plugin_websearch_cancel}" />
<Button
MinWidth="140"
Margin="5,0,10,0"
Margin="5 0 10 0"
Click="OnConfirmButtonClick"
Content="{DynamicResource flowlauncher_plugin_websearch_confirm}"
Style="{DynamicResource AccentButtonStyle}" />
Expand Down
26 changes: 26 additions & 0 deletions Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using Microsoft.Win32;

namespace Flow.Launcher.Plugin.WebSearch
Expand Down Expand Up @@ -145,6 +147,30 @@ private async void OnSelectIconClick(object sender, RoutedEventArgs e)
}
}
}

//Block Space Input
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Space)
{
e.Handled = true;
}
}
private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(DataFormats.Text))
{
string text = e.DataObject.GetData(DataFormats.Text) as string;
if (!string.IsNullOrEmpty(text) && text.Any(char.IsWhiteSpace))
{
e.CancelCommand();
}
}
else
{
e.CancelCommand();
}
}
}

public enum Action
Expand Down
Loading