Skip to content

Commit f4e19a6

Browse files
Jack251970TBM13
authored andcommitted
Merge pull request Flow-Launcher#3988 from Flow-Launcher/default_browser_explorer_translation
Add Default Browser & File Explorer & New Profile Translation & Ignore index change for -1
1 parent 1245bbb commit f4e19a6

13 files changed

+67
-42
lines changed

Flow.Launcher.Infrastructure/UserSettings/CustomBrowserViewModel.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
using System.Text.Json.Serialization;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
13
using Flow.Launcher.Plugin;
2-
using System.Text.Json.Serialization;
34

45
namespace Flow.Launcher.Infrastructure.UserSettings
56
{
67
public class CustomBrowserViewModel : BaseModel
78
{
9+
// We should not initialize API in static constructor because it will create another API instance
10+
private static IPublicAPI api = null;
11+
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
12+
813
public string Name { get; set; }
14+
[JsonIgnore]
15+
public string DisplayName => Name == "Default" ? API.GetTranslation("defaultBrowser_default") : Name;
916
public string Path { get; set; }
1017
public string PrivateArg { get; set; }
1118
public bool EnablePrivate { get; set; }
@@ -26,8 +33,10 @@ public CustomBrowserViewModel Copy()
2633
Editable = Editable
2734
};
2835
}
36+
37+
public void OnDisplayNameChanged()
38+
{
39+
OnPropertyChanged(nameof(DisplayName));
40+
}
2941
}
3042
}
31-
32-
33-

Flow.Launcher.Infrastructure/UserSettings/CustomExplorerViewModel.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
using Flow.Launcher.Plugin;
1+
using System.Text.Json.Serialization;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
3+
using Flow.Launcher.Plugin;
24

3-
namespace Flow.Launcher.ViewModel
5+
namespace Flow.Launcher.Infrastructure.UserSettings
46
{
57
public class CustomExplorerViewModel : BaseModel
68
{
9+
// We should not initialize API in static constructor because it will create another API instance
10+
private static IPublicAPI api = null;
11+
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
12+
713
public string Name { get; set; }
14+
[JsonIgnore]
15+
public string DisplayName => Name == "Explorer" ? API.GetTranslation("fileManagerExplorer") : Name;
816
public string Path { get; set; }
917
public string FileArgument { get; set; } = "\"%d\"";
1018
public string DirectoryArgument { get; set; } = "\"%d\"";
@@ -21,5 +29,10 @@ public CustomExplorerViewModel Copy()
2129
Editable = Editable
2230
};
2331
}
32+
33+
public void OnDisplayNameChanged()
34+
{
35+
OnPropertyChanged(nameof(DisplayName));
36+
}
2437
}
2538
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Flow.Launcher.Infrastructure.Storage;
1010
using Flow.Launcher.Plugin;
1111
using Flow.Launcher.Plugin.SharedModels;
12-
using Flow.Launcher.ViewModel;
1312

1413
namespace Flow.Launcher.Infrastructure.UserSettings
1514
{

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Windows.Markup;
1313
using System.Windows.Media;
1414
using Flow.Launcher.Plugin.SharedModels;
15+
using Microsoft.Win32;
1516
using Windows.Win32;
1617
using Windows.Win32.Foundation;
1718
using Windows.Win32.Graphics.Dwm;
@@ -537,5 +538,19 @@ public static void EnableWin32DarkMode(string colorScheme)
537538
}
538539

539540
#endregion
541+
542+
#region File / Folder Dialog
543+
544+
public static string SelectFile()
545+
{
546+
var dlg = new OpenFileDialog();
547+
var result = dlg.ShowDialog();
548+
if (result == true)
549+
return dlg.FileName;
550+
551+
return string.Empty;
552+
}
553+
554+
#endregion
540555
}
541556
}

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@
461461
<system:String x:Key="fileManager_file_arg">Arg For File</system:String>
462462
<system:String x:Key="fileManagerPathNotFound">The file manager '{0}' could not be located at '{1}'. Would you like to continue?</system:String>
463463
<system:String x:Key="fileManagerPathError">File Manager Path Error</system:String>
464+
<system:String x:Key="fileManagerExplorer">File Explorer</system:String>
464465

465466
<!-- DefaultBrowser Setting Dialog -->
466467
<system:String x:Key="defaultBrowserTitle">Default Web Browser</system:String>
@@ -471,6 +472,8 @@
471472
<system:String x:Key="defaultBrowser_newWindow">New Window</system:String>
472473
<system:String x:Key="defaultBrowser_newTab">New Tab</system:String>
473474
<system:String x:Key="defaultBrowser_parameter">Private Mode</system:String>
475+
<system:String x:Key="defaultBrowser_default">Default</system:String>
476+
<system:String x:Key="defaultBrowser_new_profile">New Profile</system:String>
474477

475478
<!-- Priority Setting Dialog -->
476479
<system:String x:Key="changePriorityWindow">Change Priority</system:String>

Flow.Launcher/SelectBrowserWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
SelectedIndex="{Binding SelectedCustomBrowserIndex}">
9393
<ComboBox.ItemTemplate>
9494
<DataTemplate>
95-
<TextBlock Text="{Binding Name}" />
95+
<TextBlock Text="{Binding DisplayName}" />
9696
</DataTemplate>
9797
</ComboBox.ItemTemplate>
9898
</ComboBox>

Flow.Launcher/SelectBrowserWindow.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Windows;
22
using System.Windows.Controls;
33
using CommunityToolkit.Mvvm.DependencyInjection;
4+
using Flow.Launcher.Infrastructure;
45
using Flow.Launcher.ViewModel;
56

67
namespace Flow.Launcher
@@ -31,7 +32,7 @@ private void btnDone_Click(object sender, RoutedEventArgs e)
3132

3233
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
3334
{
34-
var selectedFilePath = _viewModel.SelectFile();
35+
var selectedFilePath = Win32Helper.SelectFile();
3536

3637
if (!string.IsNullOrEmpty(selectedFilePath))
3738
{

Flow.Launcher/SelectFileManagerWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
SelectedIndex="{Binding SelectedCustomExplorerIndex}">
103103
<ComboBox.ItemTemplate>
104104
<DataTemplate>
105-
<TextBlock Text="{Binding Name}" />
105+
<TextBlock Text="{Binding DisplayName}" />
106106
</DataTemplate>
107107
</ComboBox.ItemTemplate>
108108
</ComboBox>

Flow.Launcher/SelectFileManagerWindow.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Windows.Controls;
33
using System.Windows.Navigation;
44
using CommunityToolkit.Mvvm.DependencyInjection;
5+
using Flow.Launcher.Infrastructure;
56
using Flow.Launcher.ViewModel;
67

78
namespace Flow.Launcher
@@ -32,7 +33,7 @@ private void btnDone_Click(object sender, RoutedEventArgs e)
3233

3334
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
3435
{
35-
var selectedFilePath = _viewModel.SelectFile();
36+
var selectedFilePath = Win32Helper.SelectFile();
3637

3738
if (!string.IsNullOrEmpty(selectedFilePath))
3839
{

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ private void UpdateEnumDropdownLocalizations()
6060
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
6161
// Since we are using Binding instead of DynamicResource, we need to manually trigger the update
6262
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
63+
Settings.CustomExplorer.OnDisplayNameChanged();
64+
Settings.CustomBrowser.OnDisplayNameChanged();
6365
}
6466

6567
public string Language

0 commit comments

Comments
 (0)