Skip to content

Commit 4aae101

Browse files
committed
Merge Binding
2 parents dc6babe + c4f9dcb commit 4aae101

File tree

15 files changed

+137
-96
lines changed

15 files changed

+137
-96
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using Flow.Launcher.Infrastructure.Http;
2+
using Flow.Launcher.Infrastructure.Logger;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text.Json;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace Flow.Launcher.Core.ExternalPlugins
10+
{
11+
public static class PluginsManifest
12+
{
13+
static PluginsManifest()
14+
{
15+
UpdateTask = UpdateManifestAsync();
16+
}
17+
18+
public static List<UserPlugin> UserPlugins { get; private set; } = new List<UserPlugin>();
19+
20+
public static Task UpdateTask { get; private set; }
21+
22+
private static readonly SemaphoreSlim manifestUpdateLock = new(1);
23+
24+
public static Task UpdateManifestAsync()
25+
{
26+
if (manifestUpdateLock.CurrentCount == 0)
27+
{
28+
return UpdateTask;
29+
}
30+
31+
return UpdateTask = DownloadManifestAsync();
32+
}
33+
34+
private async static Task DownloadManifestAsync()
35+
{
36+
try
37+
{
38+
await manifestUpdateLock.WaitAsync().ConfigureAwait(false);
39+
40+
await using var jsonStream = await Http.GetStreamAsync("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json")
41+
.ConfigureAwait(false);
42+
43+
UserPlugins = await JsonSerializer.DeserializeAsync<List<UserPlugin>>(jsonStream).ConfigureAwait(false);
44+
}
45+
catch (Exception e)
46+
{
47+
Log.Exception("|PluginManagement.GetManifest|Encountered error trying to download plugins manifest", e);
48+
49+
UserPlugins = new List<UserPlugin>();
50+
}
51+
finally
52+
{
53+
manifestUpdateLock.Release();
54+
}
55+
}
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-

2-
namespace Flow.Launcher.Plugin.PluginsManager.Models
1+
namespace Flow.Launcher.Core.ExternalPlugins
32
{
4-
public class UserPlugin
3+
public record UserPlugin
54
{
65
public string ID { get; set; }
76
public string Name { get; set; }
@@ -12,5 +11,6 @@ public class UserPlugin
1211
public string Website { get; set; }
1312
public string UrlDownload { get; set; }
1413
public string UrlSourceCode { get; set; }
14+
public string IcoPath { get; set; }
1515
}
1616
}

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public ResourceDictionary GetResourceDictionary()
176176
dict["ItemSubTitleStyle"] is Style resultSubItemStyle &&
177177
dict["ItemSubTitleSelectedStyle"] is Style resultSubItemSelectedStyle &&
178178
dict["ItemTitleSelectedStyle"] is Style resultItemSelectedStyle &&
179+
dict["ItemHotkeyStyle"] is Style resultHotkeyItemStyle &&
179180
dict["ItemHotkeySelectedStyle"] is Style resultHotkeyItemSelectedStyle)
180181
{
181182
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(Settings.ResultFont));
@@ -184,7 +185,9 @@ public ResourceDictionary GetResourceDictionary()
184185
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.ResultFontStretch));
185186

186187
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
187-
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle, resultHotkeyItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
188+
Array.ForEach(
189+
new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
190+
=> Array.ForEach(setters, p => o.Setters.Add(p)));
188191
}
189192

190193
var windowStyle = dict["WindowStyle"] as Style;

Flow.Launcher/Helper/HotKeyMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey)
110110
return;
111111

112112
mainViewModel.MainWindowVisibility = Visibility.Visible;
113-
mainViewModel.ChangeQueryText(hotkey.ActionKeyword);
113+
mainViewModel.ChangeQueryText(hotkey.ActionKeyword, true);
114114
});
115115
}
116116

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@ public PublicAPIInstance(SettingWindowViewModel settingsVM, MainViewModel mainVM
4848

4949
public void ChangeQuery(string query, bool requery = false)
5050
{
51-
_mainVM.ChangeQueryText(query);
52-
}
53-
54-
public void ChangeQueryText(string query, bool selectAll = false)
55-
{
56-
_mainVM.ChangeQueryText(query);
51+
_mainVM.ChangeQueryText(query, requery);
5752
}
5853

5954
public void RestartApp()

Flow.Launcher/SettingWindow.xaml

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -689,28 +689,28 @@
689689
ToolTip="Change Plugin Results Priority"
690690
Margin="5 0 0 0" Cursor="Hand"
691691
Click="OnPluginPriorityClick">
692-
<!--#region Priority Button Style-->
692+
<!--#region Priority Button Style-->
693693
<Button.Resources>
694694
<Style TargetType="Border">
695695
<Setter Property="CornerRadius" Value="2"/>
696696
</Style>
697697
</Button.Resources>
698698
<Button.Style>
699-
<Style TargetType="Button">
700-
<Setter Property="Padding" Value="12 8 12 8" />
701-
<Setter Property="BorderThickness" Value="0" />
702-
<Setter Property="FontWeight" Value="DemiBold" />
703-
<Setter Property="Foreground" Value="Black" />
699+
<Style TargetType="Button">
700+
<Setter Property="Padding" Value="12 8 12 8" />
701+
<Setter Property="BorderThickness" Value="0" />
702+
<Setter Property="FontWeight" Value="DemiBold" />
703+
<Setter Property="Foreground" Value="Black" />
704704
<Style.Triggers>
705705
<DataTrigger Binding="{Binding ElementName=PriorityButton, UpdateSourceTrigger=PropertyChanged, Path=Content}" Value="0">
706706
<Setter Property="Foreground" Value="#878787" />
707707
<Setter Property="FontWeight" Value="Normal" />
708708
</DataTrigger>
709709
</Style.Triggers>
710-
</Style>
711-
</Button.Style>
712-
<!--#endregion-->
713-
</Button>
710+
</Style>
711+
</Button.Style>
712+
<!--#endregion-->
713+
</Button>
714714
</Border>
715715
</StackPanel>
716716
<ui:ToggleSwitch Grid.Column="4" OffContent="{DynamicResource disable}"
@@ -735,15 +735,15 @@
735735
Style="{DynamicResource SettingTitleLabel}"
736736
Margin="0 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Left" DockPanel.Dock="Left"/>
737737

738-
739-
<Button Grid.Column="2" Content="{Binding ActionKeywordsText}"
738+
739+
<Button Grid.Column="2" Content="{Binding ActionKeywordsText}"
740740
DockPanel.Dock="Right"
741741
Visibility="{Binding ActionKeywordsVisibility}"
742742
ToolTip="Change Action Keywords"
743743
Margin="5 0 0 0" Cursor="Hand" FontWeight="Bold"
744744
Click="OnPluginActionKeywordsClick" HorizontalAlignment="Right"
745745
Width="100" Height="40">
746-
746+
747747
<Button.Resources>
748748
<Style TargetType="Border">
749749
<Setter Property="CornerRadius" Value="2"/>
@@ -762,7 +762,7 @@
762762

763763
<StackPanel>
764764

765-
765+
766766
<Border Background="White" Padding="0"
767767
BorderThickness="0 1 0 0" BorderBrush="#e6e6e6"
768768
VerticalAlignment="Center" HorizontalAlignment="Stretch">
@@ -785,8 +785,8 @@
785785
Content="{Binding SettingControl}"
786786
Padding="1" Margin="0" VerticalAlignment="Stretch"
787787
MaxWidth="750" MaxHeight="550">
788-
</ContentControl>
789-
788+
</ContentControl>
789+
790790
</StackPanel>
791791

792792
<StackPanel>
@@ -826,7 +826,7 @@
826826
MouseUp="OnPluginDirecotyClick" Foreground="Blue"
827827
HorizontalAlignment="Right" FontSize="12" VerticalAlignment="Center"/>
828828
</StackPanel>
829-
829+
830830
</ItemsControl>
831831
</Border>
832832

@@ -872,15 +872,18 @@
872872
</Border>
873873
<Border Grid.Column="0" Grid.Row="1" Background="#f3f3f3" Padding="0 0 0 0">
874874
<ListBox x:Name="StoreListBox"
875-
ItemsSource="{Binding PluginViewModels}"
876-
Margin="5, 1, 0, 0" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
875+
ItemsSource="{Binding ExternalPlugins}"
876+
Margin="6, 0, 0, 0" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
877877
ItemContainerStyle="{StaticResource StoreList}"
878878
ScrollViewer.IsDeferredScrollingEnabled="True" ScrollViewer.CanContentScroll="False"
879879
Padding="0 0 0 0" Width="Auto" VerticalContentAlignment="Center" HorizontalAlignment="Stretch">
880880
<ListBox.ItemsPanel>
881881
<ItemsPanelTemplate>
882882
<UniformGrid IsItemsHost="True" HorizontalAlignment="Left" Columns="2" Margin="0 0 6 18" VerticalAlignment="Top" SnapsToDevicePixels="True"/>
883883
</ItemsPanelTemplate>
884+
885+
886+
884887
</ListBox.ItemsPanel>
885888
<ListBox.ItemTemplate>
886889
<DataTemplate>
@@ -903,10 +906,10 @@
903906
</Style.Triggers>
904907
</Style>
905908
</StackPanel.Style>
906-
<Image Source="{Binding Image, IsAsync=True}"
907-
Width="32" Height="32" Margin="8 0 6 0"
908-
VerticalAlignment="Center"/>
909-
</StackPanel>
909+
<Image Source="{Binding IcoPath, IsAsync=True}"
910+
Width="32" Height="32" Margin="8 0 6 0"
911+
VerticalAlignment="Center"/>
912+
</StackPanel>
910913
<StackPanel Grid.Column="1" Margin="0 0 8 0" VerticalAlignment="Center" Panel.ZIndex="0">
911914
<StackPanel.Style>
912915
<Style>
@@ -918,11 +921,11 @@
918921
</Style.Triggers>
919922
</Style>
920923
</StackPanel.Style>
921-
<TextBlock Text="{Binding PluginPair.Metadata.Name}"
924+
<TextBlock Text="{Binding Name}"
922925
TextWrapping="WrapWithOverflow" Padding="0 0 20 0"
923-
ToolTip="{Binding PluginPair.Metadata.Version}" />
926+
ToolTip="{Binding Version}" />
924927
<TextBlock Opacity="0.5" TextWrapping="WrapWithOverflow" Margin="0 2 0 0" Padding="0 0 20 0">
925-
<Run Text="{Binding PluginPair.Metadata.Description}" FontSize="12" />
928+
<Run Text="{Binding Description}" FontSize="12" />
926929
</TextBlock>
927930

928931
</StackPanel >
@@ -946,18 +949,18 @@
946949
<Grid.ColumnDefinitions>
947950
<ColumnDefinition Width="{Binding ActualWidth,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}}" />
948951
</Grid.ColumnDefinitions>
949-
952+
950953
<StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch">
951954
<StackPanel Orientation="Horizontal">
952-
<TextBlock Text="{Binding PluginPair.Metadata.Name}" FontWeight="Bold"
955+
<TextBlock Text="{Binding Name}" FontWeight="Bold"
953956
TextWrapping="WrapWithOverflow" Padding="0 0 0 0" Margin="20 0 0 0"
954-
ToolTip="{Binding PluginPair.Metadata.Name}" />
955-
<TextBlock Text="{Binding PluginPair.Metadata.Version}"
957+
ToolTip="{Binding Name}" />
958+
<TextBlock Text="{Binding Version}"
956959
TextWrapping="WrapWithOverflow" Padding="0 0 20 0" Margin="10 0 0 0"
957-
ToolTip="{Binding PluginPair.Metadata.Version}" />
960+
ToolTip="{Binding Version}" />
958961
</StackPanel>
959962
<TextBlock Opacity="0.5" TextWrapping="Wrap" Margin="20 2 0 0" Padding="0 0 20 0" >
960-
<Run Text="{Binding PluginPair.Metadata.Author}" FontSize="12" />
963+
<Run Text="{Binding Author}" FontSize="12" />
961964
</TextBlock>
962965
</StackPanel>
963966

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,17 @@ public string QueryText
285285
/// but we don't want to move cursor to end when query is updated from TextBox
286286
/// </summary>
287287
/// <param name="queryText"></param>
288-
public void ChangeQueryText(string queryText)
288+
public void ChangeQueryText(string queryText, bool reQuery = false)
289289
{
290-
QueryText = queryText;
290+
if (QueryText!=queryText)
291+
{
292+
// re-query is done in QueryText's setter method
293+
QueryText = queryText;
294+
}
295+
else if (reQuery)
296+
{
297+
Query();
298+
}
291299
QueryTextCursorMovedToEnd = true;
292300
}
293301

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Windows.Media.Imaging;
1010
using Flow.Launcher.Core;
1111
using Flow.Launcher.Core.Configuration;
12+
using Flow.Launcher.Core.ExternalPlugins;
1213
using Flow.Launcher.Core.Plugin;
1314
using Flow.Launcher.Core.Resource;
1415
using Flow.Launcher.Helper;
@@ -237,6 +238,14 @@ public IList<PluginViewModel> PluginViewModels
237238
}
238239
}
239240

241+
public IList<UserPlugin> ExternalPlugins
242+
{
243+
get
244+
{
245+
return PluginsManifest.UserPlugins;
246+
}
247+
}
248+
240249
public Control SettingProvider
241250
{
242251
get

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal static class IndexSearch
1717
{
1818

1919
// Reserved keywords in oleDB
20-
private const string reservedStringPattern = @"^[`\@\#\^,\&\/\\\$\%_]+$";
20+
private const string reservedStringPattern = @"^[`\@\#\^,\&\/\\\$\%_;\[\]]+$";
2121

2222
internal static async Task<List<Result>> ExecuteWindowsIndexSearchAsync(string indexQueryString, string connectionString, Query query, CancellationToken token)
2323
{

Plugins/Flow.Launcher.Plugin.Explorer/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Name": "Explorer",
1111
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
1212
"Author": "Jeremy Wu",
13-
"Version": "1.9.0",
13+
"Version": "1.9.1",
1414
"Language": "csharp",
1515
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1616
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",

0 commit comments

Comments
 (0)