Skip to content

Commit 5cea434

Browse files
committed
Merge branch '250412-ImportThemePreset' of https://github.com/onesounds/Flow.Launcher into 250412-ImportThemePreset
2 parents 1cd6998 + d045c49 commit 5cea434

File tree

5 files changed

+81
-25
lines changed

5 files changed

+81
-25
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,15 @@ public interface IPublicAPI
223223
Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath, Action<double> reportProgress = null, CancellationToken token = default);
224224

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

233237
/// <summary>
@@ -280,9 +284,10 @@ public interface IPublicAPI
280284
T LoadSettingJsonStorage<T>() where T : new();
281285

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

426431
/// <summary>
427-
/// Save BinaryStorage for current plugin's cache. This is the method used to save cache to binary in Flow.Launcher
432+
/// Save BinaryStorage for current plugin's cache. This is the method used to save cache to binary in Flow.
428433
/// This method will save the original instance loaded with LoadCacheBinaryStorageAsync.
429-
/// This API call is for manually Save. Flow will automatically save all cache type that has called LoadCacheBinaryStorageAsync or SaveCacheBinaryStorageAsync previously.
434+
/// This API call is for manually Save.
435+
/// Flow will automatically save all cache type that has called <see cref="LoadCacheBinaryStorageAsync"/> or <see cref="SaveCacheBinaryStorageAsync"/> previously.
430436
/// </summary>
431437
/// <typeparam name="T">Type for Serialization</typeparam>
432438
/// <param name="cacheName">Cache file name</param>

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
Width="135"
8181
HorizontalAlignment="Left"
8282
VerticalAlignment="Center"
83+
DataObject.Pasting="TextBox_Pasting"
8384
PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"
8485
Text="{Binding ActionKeyword}" />
8586
</StackPanel>

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.ComponentModel;
3+
using System.Linq;
34
using System.Runtime.CompilerServices;
45
using System.Windows;
56
using System.Windows.Input;
@@ -85,7 +86,7 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
8586
DialogResult = false;
8687
Close();
8788
}
88-
89+
8990
private void TxtCurrentActionKeyword_OnKeyDown(object sender, KeyEventArgs e)
9091
{
9192
if (e.Key == Key.Enter)
@@ -94,14 +95,34 @@ private void TxtCurrentActionKeyword_OnKeyDown(object sender, KeyEventArgs e)
9495
OnDoneButtonClick(sender, e);
9596
e.Handled = true;
9697
}
98+
if (e.Key == Key.Space)
99+
{
100+
e.Handled = true;
101+
}
97102
}
98-
103+
104+
private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
105+
{
106+
if (e.DataObject.GetDataPresent(DataFormats.Text))
107+
{
108+
string text = e.DataObject.GetData(DataFormats.Text) as string;
109+
if (!string.IsNullOrEmpty(text) && text.Any(char.IsWhiteSpace))
110+
{
111+
e.CancelCommand();
112+
}
113+
}
114+
else
115+
{
116+
e.CancelCommand();
117+
}
118+
}
119+
99120
public event PropertyChangedEventHandler PropertyChanged;
100121
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
101122
{
102123
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
103124
}
104-
125+
105126
private bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
106127
{
107128
if (EqualityComparer<T>.Default.Equals(field, value))

Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@
5656
</Button>
5757
</Grid>
5858
</StackPanel>
59-
<StackPanel Margin="26,12,26,0">
59+
<StackPanel Margin="26 12 26 0">
6060
<Grid>
6161
<StackPanel>
62-
<StackPanel Grid.Row="0" Margin="0,0,0,12">
62+
<StackPanel Grid.Row="0" Margin="0 0 0 12">
6363
<TextBlock
6464
Grid.Column="0"
65-
Margin="0,0,0,0"
65+
Margin="0 0 0 0"
6666
FontSize="20"
6767
FontWeight="SemiBold"
6868
Text="{DynamicResource flowlauncher_plugin_websearch_window_title}"
@@ -75,15 +75,15 @@
7575
TextAlignment="Left"
7676
TextWrapping="WrapWithOverflow" />
7777
<TextBox
78-
Margin="0,12,0,12"
78+
Margin="0 12 0 12"
7979
FontSize="14"
8080
FontWeight="SemiBold"
8181
IsReadOnly="True"
8282
Text="{DynamicResource flowlauncher_plugin_websearch_guide_2}"
8383
TextAlignment="Center"
8484
TextWrapping="WrapWithOverflow" />
8585
<TextBlock
86-
Margin="0,0,0,14"
86+
Margin="0 0 0 14"
8787
FontSize="14"
8888
Text="{DynamicResource flowlauncher_plugin_websearch_guide_3}"
8989
TextAlignment="Left"
@@ -105,7 +105,7 @@
105105
<TextBlock
106106
Grid.Row="0"
107107
Grid.Column="0"
108-
Margin="10,10,15,10"
108+
Margin="10 10 15 10"
109109
HorizontalAlignment="Stretch"
110110
VerticalAlignment="Center"
111111
FontSize="14"
@@ -120,7 +120,7 @@
120120
<TextBlock
121121
Grid.Row="1"
122122
Grid.Column="0"
123-
Margin="10,10,15,10"
123+
Margin="10 10 15 10"
124124
HorizontalAlignment="Left"
125125
VerticalAlignment="Center"
126126
FontSize="14"
@@ -131,21 +131,21 @@
131131
Orientation="Horizontal">
132132
<Button
133133
Height="35"
134-
Margin="10,0,0,0"
134+
Margin="10 0 0 0"
135135
VerticalAlignment="Center"
136136
Click="OnSelectIconClick"
137137
Content="{DynamicResource flowlauncher_plugin_websearch_select_icon}" />
138138
<Image
139139
Name="imgPreviewIcon"
140140
Width="24"
141141
Height="24"
142-
Margin="14,0,0,0"
142+
Margin="14 0 0 0"
143143
VerticalAlignment="Center" />
144144
</StackPanel>
145145
<TextBlock
146146
Grid.Row="2"
147147
Grid.Column="0"
148-
Margin="10,10,15,10"
148+
Margin="10 10 15 10"
149149
HorizontalAlignment="Left"
150150
VerticalAlignment="Center"
151151
FontSize="14"
@@ -160,30 +160,32 @@
160160
<TextBlock
161161
Grid.Row="3"
162162
Grid.Column="0"
163-
Margin="10,10,15,10"
163+
Margin="10 10 15 10"
164164
HorizontalAlignment="Left"
165165
VerticalAlignment="Center"
166166
FontSize="14"
167167
Text="{DynamicResource flowlauncher_plugin_websearch_action_keyword}" />
168168
<TextBox
169169
Grid.Row="3"
170170
Grid.Column="1"
171-
Margin="10,0,10,0"
171+
Margin="10 0 10 0"
172172
HorizontalAlignment="Stretch"
173173
VerticalAlignment="Center"
174+
DataObject.Pasting="TextBox_Pasting"
175+
PreviewKeyDown="TextBox_PreviewKeyDown"
174176
Text="{Binding SearchSource.ActionKeyword}" />
175177
<TextBlock
176178
Grid.Row="4"
177179
Grid.Column="0"
178-
Margin="10,10,15,15"
180+
Margin="10 10 15 15"
179181
HorizontalAlignment="Left"
180182
VerticalAlignment="Center"
181183
FontSize="14"
182184
Text="{DynamicResource flowlauncher_plugin_websearch_enabled_label}" />
183185
<CheckBox
184186
Grid.Row="4"
185187
Grid.Column="1"
186-
Margin="10,10,10,15"
188+
Margin="10 10 10 15"
187189
VerticalAlignment="Center"
188190
IsChecked="{Binding SearchSource.Enabled}" />
189191
</Grid>
@@ -196,16 +198,16 @@
196198
Grid.Row="1"
197199
Background="{DynamicResource PopupButtonAreaBGColor}"
198200
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
199-
BorderThickness="0,1,0,0">
201+
BorderThickness="0 1 0 0">
200202
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
201203
<Button
202204
MinWidth="140"
203-
Margin="10,0,5,0"
205+
Margin="10 0 5 0"
204206
Click="OnCancelButtonClick"
205207
Content="{DynamicResource flowlauncher_plugin_websearch_cancel}" />
206208
<Button
207209
MinWidth="140"
208-
Margin="5,0,10,0"
210+
Margin="5 0 10 0"
209211
Click="OnConfirmButtonClick"
210212
Content="{DynamicResource flowlauncher_plugin_websearch_confirm}"
211213
Style="{DynamicResource AccentButtonStyle}" />

Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using System.Windows;
4+
using System.Windows.Input;
35
using Microsoft.Win32;
46

57
namespace Flow.Launcher.Plugin.WebSearch
@@ -145,6 +147,30 @@ private async void OnSelectIconClick(object sender, RoutedEventArgs e)
145147
}
146148
}
147149
}
150+
151+
//Block Space Input
152+
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
153+
{
154+
if (e.Key == Key.Space)
155+
{
156+
e.Handled = true;
157+
}
158+
}
159+
private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
160+
{
161+
if (e.DataObject.GetDataPresent(DataFormats.Text))
162+
{
163+
string text = e.DataObject.GetData(DataFormats.Text) as string;
164+
if (!string.IsNullOrEmpty(text) && text.Any(char.IsWhiteSpace))
165+
{
166+
e.CancelCommand();
167+
}
168+
}
169+
else
170+
{
171+
e.CancelCommand();
172+
}
173+
}
148174
}
149175

150176
public enum Action

0 commit comments

Comments
 (0)