Skip to content

Commit 52b3579

Browse files
committed
Implement Install & Refresh Button
- Add ShowMainWindow API for IPublicAPI
1 parent 1ce3150 commit 52b3579

File tree

5 files changed

+53
-18
lines changed

5 files changed

+53
-18
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ public interface IPublicAPI
5959
/// <param name="subTitle">Optional message subtitle</param>
6060
void ShowMsgError(string title, string subTitle = "");
6161

62+
/// <summary>
63+
/// Show the MainWindow when hiding
64+
/// </summary>
65+
void ShowMainWindow();
66+
6267
/// <summary>
6368
/// Show message box
6469
/// </summary>

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public void RestartApp()
6868

6969
public void RestarApp() => RestartApp();
7070

71+
public void ShowMainWindow() => _mainVM.MainWindowVisibility = Visibility.Visible;
72+
7173
public void CheckForNewUpdate() => _settingsVM.UpdateApp();
7274

7375
public void SaveAppAllSettings()

Flow.Launcher/SettingWindow.xaml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</CollectionViewSource.SortDescriptions>
3838
</CollectionViewSource>
3939

40-
40+
4141
<Style x:Key="SettingGrid" TargetType="ItemsControl">
4242
<Setter Property="Focusable" Value="False" />
4343
<Setter Property="Margin" Value="0" />
@@ -63,7 +63,7 @@
6363
<Setter Property="Margin" Value="0 5 0 0" />
6464
<Setter Property="Padding" Value="0 15 0 15" />
6565
<Setter Property="SnapsToDevicePixels" Value="True" />
66-
66+
6767
</Style>
6868
<Style x:Key="SettingTitleLabel" TargetType="{x:Type TextBlock}">
6969
<Setter Property="Margin" Value="0 0 0 0" />
@@ -362,7 +362,7 @@
362362
</Window.Resources>
363363

364364

365-
<TabControl Height="auto" SelectedIndex="1" TabStripPlacement="Left" Background="#f3f3f3">
365+
<TabControl Height="auto" SelectedIndex="1" TabStripPlacement="Left" Background="#f3f3f3">
366366
<TabItem Style="{DynamicResource logo}">
367367
<TabItem.Header>
368368
<Grid Margin="0 18 0 0">
@@ -378,7 +378,8 @@
378378
</Grid>
379379
</TabItem.Header>
380380
</TabItem>
381-
<TabItem> <!-- LEFT TAB WIDTH -->
381+
<TabItem>
382+
<!-- LEFT TAB WIDTH -->
382383
<TabItem.Header>
383384
<Grid>
384385
<Grid.ColumnDefinitions>
@@ -881,7 +882,16 @@
881882
<TextBlock Text="Plugin Store" TextAlignment="left" FontSize="30" Margin="0 5 0 5"/>
882883
</Border>
883884
<Border Grid.Row="0" Grid.Column="1" Background="#f3f3f3" Padding="5 18 32 0">
884-
<Button Content="Refresh" FontSize="13" Margin="0 5 0 5" HorizontalAlignment="Right" Background="#ffffff" Padding="12 4 12 4" Height="34" BorderBrush="#cecece" BorderThickness="1 1 1 2"/>
885+
<Button Content="Refresh"
886+
FontSize="13"
887+
Margin="0 5 0 5"
888+
HorizontalAlignment="Right"
889+
Background="#ffffff"
890+
Padding="12 4 12 4"
891+
Height="34"
892+
BorderBrush="#cecece"
893+
Click="OnPluginStoreRefreshClick"
894+
BorderThickness="1 1 1 2"/>
885895
</Border>
886896
<Border Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Background="#f3f3f3" Padding="0 0 0 0">
887897
<ListBox x:Name="StoreListBox"
@@ -905,18 +915,9 @@
905915
<ToggleButton.Template>
906916
<ControlTemplate TargetType="{x:Type ButtonBase}">
907917
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
908-
<ControlTemplate.Triggers>
909-
</ControlTemplate.Triggers>
918+
<ControlTemplate.Triggers/>
910919
</ControlTemplate>
911920
</ToggleButton.Template>
912-
<ToggleButton.Style>
913-
<Style TargetType="{x:Type ToggleButton}">
914-
<Style.Triggers>
915-
<Trigger Property="IsChecked" Value="True">
916-
</Trigger>
917-
</Style.Triggers>
918-
</Style>
919-
</ToggleButton.Style>
920921

921922
<Grid HorizontalAlignment="Left" VerticalAlignment="Stretch">
922923
<Grid.ColumnDefinitions>
@@ -998,7 +999,10 @@
998999
</StackPanel>
9991000
</StackPanel>
10001001
<Border Padding="0 0 20 0">
1001-
<Button Foreground="Black" Name="ShortCutButtonPrev" Content="Install" Width="90" MinHeight="40" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1" Margin="0 0 0 0">
1002+
<Button Foreground="Black" Name="ShortCutButtonPrev" Content="Install"
1003+
Click="OnExternalPluginInstallClick"
1004+
Width="90" MinHeight="40" HorizontalAlignment="Right"
1005+
VerticalAlignment="Center" Grid.Column="1" Margin="0 0 0 0">
10021006
</Button>
10031007
</Border>
10041008
</Grid>
@@ -1079,7 +1083,7 @@
10791083
<Border Margin="0 0 0 0" Grid.Row="1">
10801084
<Rectangle Width="Auto" HorizontalAlignment="Stretch"
10811085
Style="{DynamicResource SeparatorStyle}"
1082-
Visibility="visible" />
1086+
Visibility="Visible" />
10831087
</Border>
10841088

10851089
<ContentControl Grid.Row="2">
@@ -1112,7 +1116,7 @@
11121116
</ItemsControl>
11131117
</Border>
11141118
</StackPanel>
1115-
1119+
11161120
<StackPanel Grid.Row="3">
11171121
<Border Style="{DynamicResource SettingGroupBox}" Margin="0 8 0 0" Padding="0"
11181122
HorizontalAlignment="Stretch">

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Flow.Launcher.ViewModel;
1515
using Flow.Launcher.Helper;
1616
using System.Windows.Controls;
17+
using Flow.Launcher.Core.ExternalPlugins;
1718

1819
namespace Flow.Launcher
1920
{
@@ -264,6 +265,22 @@ private void OpenPluginFolder(object sender, RoutedEventArgs e)
264265
FilesFolders.OpenPath(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
265266
}
266267

268+
private void OnPluginStoreRefreshClick(object sender, RoutedEventArgs e)
269+
{
270+
_ = viewModel.RefreshExternalPluginsAsync();
271+
}
272+
273+
private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e)
274+
{
275+
if(sender is Button { DataContext: UserPlugin plugin })
276+
{
277+
var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7");
278+
var actionKeywrod = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0];
279+
API.ChangeQuery($"{actionKeywrod} install {plugin.Name}");
280+
API.ShowMainWindow();
281+
}
282+
}
283+
267284
/*
268285
private void OnPluginActionKeywordsClick(object sender, RoutedEventArgs e)
269286
{

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Net;
6+
using System.Threading.Tasks;
67
using System.Windows;
78
using System.Windows.Controls;
89
using System.Windows.Media;
@@ -265,6 +266,12 @@ public Control SettingProvider
265266
}
266267
}
267268

269+
public async Task RefreshExternalPluginsAsync()
270+
{
271+
await PluginsManifest.UpdateManifestAsync();
272+
OnPropertyChanged(nameof(ExternalPlugins));
273+
}
274+
268275

269276

270277
#endregion

0 commit comments

Comments
 (0)