mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add translation for default items & new profile item for explorer & browser window
This commit is contained in:
parent
2dd416028d
commit
1fea8edb74
9 changed files with 49 additions and 22 deletions
|
|
@ -1,11 +1,18 @@
|
|||
using System.Text.Json.Serialization;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Plugin;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Flow.Launcher.Infrastructure.UserSettings
|
||||
{
|
||||
public class CustomBrowserViewModel : BaseModel
|
||||
{
|
||||
// We should not initialize API in static constructor because it will create another API instance
|
||||
private static IPublicAPI api = null;
|
||||
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
|
||||
|
||||
public string Name { get; set; }
|
||||
[JsonIgnore]
|
||||
public string DisplayName => Name == "Default" ? API.GetTranslation("defaultBrowser_default") : Name;
|
||||
public string Path { get; set; }
|
||||
public string PrivateArg { get; set; }
|
||||
public bool EnablePrivate { get; set; }
|
||||
|
|
@ -26,8 +33,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
Editable = Editable
|
||||
};
|
||||
}
|
||||
|
||||
public void OnDisplayNameChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(DisplayName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
using Flow.Launcher.Plugin;
|
||||
using System.Text.Json.Serialization;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
||||
namespace Flow.Launcher.ViewModel
|
||||
{
|
||||
public class CustomExplorerViewModel : BaseModel
|
||||
{
|
||||
// We should not initialize API in static constructor because it will create another API instance
|
||||
private static IPublicAPI api = null;
|
||||
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
|
||||
|
||||
public string Name { get; set; }
|
||||
[JsonIgnore]
|
||||
public string DisplayName => Name == "Explorer" ? API.GetTranslation("fileManagerExplorer") : Name;
|
||||
public string Path { get; set; }
|
||||
public string FileArgument { get; set; } = "\"%d\"";
|
||||
public string DirectoryArgument { get; set; } = "\"%d\"";
|
||||
|
|
@ -21,5 +29,10 @@ namespace Flow.Launcher.ViewModel
|
|||
Editable = Editable
|
||||
};
|
||||
}
|
||||
|
||||
public void OnDisplayNameChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(DisplayName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -487,6 +487,7 @@
|
|||
<system:String x:Key="fileManager_file_arg">Arg For File</system:String>
|
||||
<system:String x:Key="fileManagerPathNotFound">The file manager '{0}' could not be located at '{1}'. Would you like to continue?</system:String>
|
||||
<system:String x:Key="fileManagerPathError">File Manager Path Error</system:String>
|
||||
<system:String x:Key="fileManagerExplorer">File Explorer</system:String>
|
||||
|
||||
<!-- DefaultBrowser Setting Dialog -->
|
||||
<system:String x:Key="defaultBrowserTitle">Default Web Browser</system:String>
|
||||
|
|
@ -497,6 +498,8 @@
|
|||
<system:String x:Key="defaultBrowser_newWindow">New Window</system:String>
|
||||
<system:String x:Key="defaultBrowser_newTab">New Tab</system:String>
|
||||
<system:String x:Key="defaultBrowser_parameter">Private Mode</system:String>
|
||||
<system:String x:Key="defaultBrowser_default">Default</system:String>
|
||||
<system:String x:Key="defaultBrowser_new_profile">New Profile</system:String>
|
||||
|
||||
<!-- Priority Setting Dialog -->
|
||||
<system:String x:Key="changePriorityWindow">Change Priority</system:String>
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
SelectedIndex="{Binding SelectedCustomBrowserIndex}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<TextBlock Text="{Binding DisplayName}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedFilePath = _viewModel.SelectFile();
|
||||
var selectedFilePath = SelectFile();
|
||||
|
||||
if (!string.IsNullOrEmpty(selectedFilePath))
|
||||
{
|
||||
|
|
@ -41,5 +41,15 @@ namespace Flow.Launcher
|
|||
((Button)sender).Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private static string SelectFile()
|
||||
{
|
||||
var dlg = new Microsoft.Win32.OpenFileDialog();
|
||||
var result = dlg.ShowDialog();
|
||||
if (result == true)
|
||||
return dlg.FileName;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
SelectedIndex="{Binding SelectedCustomExplorerIndex}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<TextBlock Text="{Binding DisplayName}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
|
@ -219,6 +219,8 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
DropdownDataGeneric<DialogJumpFileResultBehaviours>.UpdateLabels(DialogJumpFileResultBehaviours);
|
||||
// Since we are using Binding instead of DynamicResource, we need to manually trigger the update
|
||||
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
|
||||
Settings.CustomExplorer.OnDisplayNameChanged();
|
||||
Settings.CustomBrowser.OnDisplayNameChanged();
|
||||
}
|
||||
|
||||
public string Language
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@
|
|||
MaxWidth="250"
|
||||
Margin="10 0 0 0"
|
||||
Command="{Binding SelectFileManagerCommand}"
|
||||
Content="{Binding Settings.CustomExplorer.Name}" />
|
||||
Content="{Binding Settings.CustomExplorer.DisplayName}" />
|
||||
</cc:Card>
|
||||
|
||||
<cc:Card
|
||||
|
|
@ -415,7 +415,7 @@
|
|||
MaxWidth="250"
|
||||
Margin="10 0 0 0"
|
||||
Command="{Binding SelectBrowserCommand}"
|
||||
Content="{Binding Settings.CustomBrowser.Name}" />
|
||||
Content="{Binding Settings.CustomBrowser.DisplayName}" />
|
||||
</cc:Card>
|
||||
|
||||
<cc:Card Title="{DynamicResource pythonFilePath}" Margin="0 14 0 0">
|
||||
|
|
|
|||
|
|
@ -40,22 +40,12 @@ public partial class SelectBrowserViewModel : BaseModel
|
|||
return true;
|
||||
}
|
||||
|
||||
internal string SelectFile()
|
||||
{
|
||||
var dlg = new Microsoft.Win32.OpenFileDialog();
|
||||
var result = dlg.ShowDialog();
|
||||
if (result == true)
|
||||
return dlg.FileName;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Add()
|
||||
{
|
||||
CustomBrowsers.Add(new()
|
||||
{
|
||||
Name = "New Profile"
|
||||
Name = App.API.GetTranslation("defaultBrowser_new_profile")
|
||||
});
|
||||
SelectedCustomBrowserIndex = CustomBrowsers.Count - 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue