Skip to content

Commit 820304c

Browse files
authored
Merge pull request #3988 from Flow-Launcher/default_browser_explorer_translation
Add Default Browser & File Explorer & New Profile Translation & Ignore index change for -1
2 parents 2dd4160 + 1017501 commit 820304c

13 files changed

+69
-45
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.Diagnostics;
@@ -904,5 +904,19 @@ public static void EnableWin32DarkMode(string colorScheme)
904904
}
905905

906906
#endregion
907+
908+
#region File / Folder Dialog
909+
910+
public static string SelectFile()
911+
{
912+
var dlg = new OpenFileDialog();
913+
var result = dlg.ShowDialog();
914+
if (result == true)
915+
return dlg.FileName;
916+
917+
return string.Empty;
918+
}
919+
920+
#endregion
907921
}
908922
}

Flow.Launcher/Languages/en.xaml

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

491492
<!-- DefaultBrowser Setting Dialog -->
492493
<system:String x:Key="defaultBrowserTitle">Default Web Browser</system:String>
@@ -497,6 +498,8 @@
497498
<system:String x:Key="defaultBrowser_newWindow">New Window</system:String>
498499
<system:String x:Key="defaultBrowser_newTab">New Tab</system:String>
499500
<system:String x:Key="defaultBrowser_parameter">Private Mode</system:String>
501+
<system:String x:Key="defaultBrowser_default">Default</system:String>
502+
<system:String x:Key="defaultBrowser_new_profile">New Profile</system:String>
500503

501504
<!-- Priority Setting Dialog -->
502505
<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: 3 additions & 2 deletions
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,13 +33,13 @@ private void btnDone_Click(object sender, RoutedEventArgs e)
3233

3334
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
3435
{
35-
_viewModel.OpenUrl(e.Uri.AbsoluteUri);
36+
App.API.OpenUrl(e.Uri.AbsoluteUri);
3637
e.Handled = true;
3738
}
3839

3940
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
4041
{
41-
var selectedFilePath = _viewModel.SelectFile();
42+
var selectedFilePath = Win32Helper.SelectFile();
4243

4344
if (!string.IsNullOrEmpty(selectedFilePath))
4445
{

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Windows.Forms;
@@ -219,6 +219,8 @@ private void UpdateEnumDropdownLocalizations()
219219
DropdownDataGeneric<DialogJumpFileResultBehaviours>.UpdateLabels(DialogJumpFileResultBehaviours);
220220
// Since we are using Binding instead of DynamicResource, we need to manually trigger the update
221221
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
222+
Settings.CustomExplorer.OnDisplayNameChanged();
223+
Settings.CustomBrowser.OnDisplayNameChanged();
222224
}
223225

224226
public string Language

0 commit comments

Comments
 (0)