Skip to content

Commit 6b2a78e

Browse files
committed
- Add Uninstall / Update Btn
- Adjust Strings
1 parent b7e51e5 commit 6b2a78e

File tree

4 files changed

+51
-13
lines changed

4 files changed

+51
-13
lines changed

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@
8484
<system:String x:Key="plugin_query_time">Query time:</system:String>
8585
<system:String x:Key="plugin_query_version">| Version</system:String>
8686
<system:String x:Key="plugin_query_web">Website</system:String>
87-
<system:String x:Key="plugin_uninstall">Uninstall</system:String>
8887

8988

9089
<!-- Setting Plugin Store -->
9190
<system:String x:Key="pluginStore">Plugin Store</system:String>
9291
<system:String x:Key="refresh">Refresh</system:String>
93-
<system:String x:Key="install">Install</system:String>
92+
<system:String x:Key="installbtn">Install</system:String>
93+
<system:String x:Key="uninstallbtn">Uninstall</system:String>
94+
<system:String x:Key="updatebtn">Update</system:String>
9495
<system:String x:Key="LabelInstalled">Installed</system:String>
9596
<system:String x:Key="LabelInstalledToolTip">Plug-in already installed</system:String>
9697
<system:String x:Key="LabelNew">New</system:String>

Flow.Launcher/SettingWindow.xaml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@
13201320
FontSize="11"
13211321
Foreground="{DynamicResource PluginInfoColor}"
13221322
MouseUp="OnExternalPluginUninstallClick"
1323-
Text="{DynamicResource plugin_uninstall}"
1323+
Text="{DynamicResource uninstallbtn}"
13241324
TextDecorations="Underline" />
13251325

13261326
<TextBlock
@@ -1692,22 +1692,36 @@
16921692
</TextBlock>
16931693
</StackPanel>
16941694
</StackPanel>
1695-
<Border
1696-
Grid.Row="0"
1697-
Grid.Column="1"
1698-
Padding="0,0,0,0">
1695+
<Grid Grid.Row="0" Grid.Column="1">
1696+
<Button
1697+
MinHeight="40"
1698+
Margin="0,70,20,0"
1699+
Padding="15,5,15,5"
1700+
HorizontalAlignment="Right"
1701+
VerticalAlignment="Center"
1702+
Click="OnExternalPluginUninstallClick"
1703+
Content="{DynamicResource uninstallbtn}"
1704+
Visibility="{Binding LabelInstalled, Converter={StaticResource BoolToVisibilityConverter}}" />
16991705
<Button
1700-
Name="ShortCutButtonPrev"
17011706
MinHeight="40"
17021707
Margin="0,70,20,0"
17031708
Padding="15,5,15,5"
17041709
HorizontalAlignment="Right"
17051710
VerticalAlignment="Center"
17061711
Click="OnExternalPluginInstallClick"
1707-
Content="{DynamicResource install}"
1712+
Content="{DynamicResource installbtn}"
17081713
Visibility="{Binding LabelInstalled, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='!'}" />
1714+
<Button
1715+
MinHeight="40"
1716+
Margin="0,70,20,0"
1717+
Padding="15,5,15,5"
1718+
HorizontalAlignment="Right"
1719+
VerticalAlignment="Center"
1720+
Click="OnExternalPluginUpdateClick"
1721+
Content="{DynamicResource updatebtn}"
1722+
Visibility="{Binding UpdateBtn, Converter={StaticResource BoolToVisibilityConverter}}" />
17091723
<!-- Hide Install Button when installed Item -->
1710-
</Border>
1724+
</Grid>
17111725
</Grid>
17121726
</StackPanel>
17131727
</Grid>

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,5 +491,27 @@ private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs
491491
}
492492

493493
}
494+
495+
private void OnExternalPluginUninstallClick(object sender, RoutedEventArgs e)
496+
{
497+
if (sender is Button { DataContext: PluginStoreItemViewModel plugin })
498+
{
499+
var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7");
500+
var actionKeyword = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0];
501+
API.ChangeQuery($"{actionKeyword} uninstall {plugin.Name}");
502+
API.ShowMainWindow();
503+
}
504+
}
505+
506+
private void OnExternalPluginUpdateClick(object sender, RoutedEventArgs e)
507+
{
508+
if (sender is Button { DataContext: PluginStoreItemViewModel plugin })
509+
{
510+
var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7");
511+
var actionKeyword = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0];
512+
API.ChangeQuery($"{actionKeyword} update {plugin.Name}");
513+
API.ShowMainWindow();
514+
}
515+
}
494516
}
495517
}

Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ public PluginStoreItemViewModel(UserPlugin plugin)
2424
public string UrlDownload => _plugin.UrlDownload;
2525
public string UrlSourceCode => _plugin.UrlSourceCode;
2626
public string IcoPath => _plugin.IcoPath;
27-
28-
public bool LabelNew => _plugin.LatestReleaseDate-DateTime.Now < TimeSpan.FromDays(7);
27+
28+
public bool LabelNew => _plugin.LatestReleaseDate - DateTime.Now < TimeSpan.FromDays(7);
2929
public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null;
30-
public bool LabelUpdated => _plugin.DateAdded -DateTime.Now < TimeSpan.FromDays(5) && !LabelNew;
30+
public bool LabelUpdated => _plugin.DateAdded - DateTime.Now < TimeSpan.FromDays(5) && !LabelNew;
31+
public bool UpdateBtn => LabelUpdated && LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version;
3132
}
3233
}

0 commit comments

Comments
 (0)