Skip to content

Commit 2a4b4de

Browse files
authored
Merge pull request #3595 from Flow-Launcher/explorer_plugin_code_quality
Remove obsolete TranslationConverter & project reference in Explorer plugin
2 parents b8afbd7 + 52fe90b commit 2a4b4de

File tree

7 files changed

+13
-32
lines changed

7 files changed

+13
-32
lines changed

Flow.Launcher.Core/Resource/TranslationConverter.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Text.Json.Serialization;
33
using System.Threading.Tasks;
4+
using CommunityToolkit.Mvvm.DependencyInjection;
5+
using Flow.Launcher.Plugin;
46

57
namespace Flow.Launcher.Infrastructure.UserSettings
68
{
@@ -53,6 +55,12 @@ public class BaseBuiltinShortcutModel : ShortcutBaseModel
5355
{
5456
public string Description { get; set; }
5557

58+
public string LocalizedDescription => API.GetTranslation(Description);
59+
60+
// We should not initialize API in static constructor because it will create another API instance
61+
private static IPublicAPI api = null;
62+
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
63+
5664
public BaseBuiltinShortcutModel(string key, string description)
5765
{
5866
Key = key;

Flow.Launcher/Resources/SettingWindowStyle.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<converters:BorderClipConverter x:Key="BorderClipConverter" />
77
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
88
<converters:TextConverter x:Key="TextConverter" />
9-
<core:TranslationConverter x:Key="TranslationConverter" />
109

1110
<!-- Icon for Theme Type Label -->
1211
<Geometry x:Key="circle_half_stroke_solid">F1 M512,512z M0,0z M448,256C448,150,362,64,256,64L256,448C362,448,448,362,448,256z M0,256A256,256,0,1,1,512,256A256,256,0,1,1,0,256z</Geometry>

Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@
427427
<GridViewColumn Width="430" Header="{DynamicResource builtinShortcutDescription}">
428428
<GridViewColumn.CellTemplate>
429429
<DataTemplate DataType="{x:Type userSettings:BuiltinShortcutModel}">
430-
<TextBlock Text="{Binding Description, Converter={StaticResource TranslationConverter}}" />
430+
<TextBlock Text="{Binding LocalizedDescription}" />
431431
</DataTemplate>
432432
</GridViewColumn.CellTemplate>
433433
</GridViewColumn>

Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@
4646

4747
<ItemGroup>
4848
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
49+
<PackageReference Include="Droplex" Version="1.7.0" />
4950
<!-- Do not upgrade System.Data.OleDb since we are .Net7.0 -->
5051
<PackageReference Include="System.Data.OleDb" Version="8.0.1" />
5152
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
5253
<PackageReference Include="tlbimp-Microsoft.Search.Interop" Version="1.0.0" />
5354
</ItemGroup>
5455

5556
<ItemGroup>
56-
<ProjectReference Include="..\..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />
57-
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
5857
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
5958
</ItemGroup>
6059

Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ internal ActionKeywordModel(Settings.ActionKeyword actionKeyword, string descrip
2424

2525
public string Description { get; private init; }
2626

27+
public string LocalizedDescription => Main.Context.API.GetTranslation(Description);
28+
2729
internal Settings.ActionKeyword KeywordProperty { get; }
2830

2931
private void OnPropertyChanged([CallerMemberName] string propertyName = "")

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:converters="clr-namespace:Flow.Launcher.Plugin.Explorer.Views.Converters"
6-
xmlns:core="clr-namespace:Flow.Launcher.Core.Resource;assembly=Flow.Launcher.Core"
76
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
87
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
98
xmlns:qa="clr-namespace:Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks"
@@ -24,7 +23,7 @@
2423
<TextBlock
2524
Margin="0 5 0 0"
2625
IsEnabled="{Binding Enabled}"
27-
Text="{Binding Description, Mode=OneTime, Converter={StaticResource TranslationConverter}}">
26+
Text="{Binding LocalizedDescription, Mode=OneTime}">
2827
<TextBlock.Style>
2928
<Style TargetType="{x:Type TextBlock}">
3029
<Style.Triggers>
@@ -76,7 +75,6 @@
7675
</Grid>
7776
</DataTemplate>
7877

79-
<core:TranslationConverter x:Key="TranslationConverter" />
8078
<converters:EnumNameConverter x:Key="EnumNameConverter" />
8179

8280
<Style x:Key="CustomExpanderStyle" TargetType="Expander">

0 commit comments

Comments
 (0)