mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3988 from Flow-Launcher/default_browser_explorer_translation
Add Default Browser & File Explorer & New Profile Translation & Ignore index change for -1
This commit is contained in:
commit
820304ce19
13 changed files with 69 additions and 45 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
|
||||
namespace Flow.Launcher.Infrastructure.UserSettings
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using Flow.Launcher.Infrastructure.Logger;
|
|||
using Flow.Launcher.Infrastructure.Storage;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedModels;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
namespace Flow.Launcher.Infrastructure.UserSettings
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -904,5 +904,19 @@ namespace Flow.Launcher.Infrastructure
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region File / Folder Dialog
|
||||
|
||||
public static string SelectFile()
|
||||
{
|
||||
var dlg = new OpenFileDialog();
|
||||
var result = dlg.ShowDialog();
|
||||
if (result == true)
|
||||
return dlg.FileName;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
namespace Flow.Launcher
|
||||
|
|
@ -31,7 +32,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedFilePath = _viewModel.SelectFile();
|
||||
var selectedFilePath = Win32Helper.SelectFile();
|
||||
|
||||
if (!string.IsNullOrEmpty(selectedFilePath))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
SelectedIndex="{Binding SelectedCustomExplorerIndex}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<TextBlock Text="{Binding DisplayName}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
namespace Flow.Launcher
|
||||
|
|
@ -32,13 +33,13 @@ namespace Flow.Launcher
|
|||
|
||||
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
_viewModel.OpenUrl(e.Uri.AbsoluteUri);
|
||||
App.API.OpenUrl(e.Uri.AbsoluteUri);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedFilePath = _viewModel.SelectFile();
|
||||
var selectedFilePath = Win32Helper.SelectFile();
|
||||
|
||||
if (!string.IsNullOrEmpty(selectedFilePath))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -17,8 +17,13 @@ public partial class SelectBrowserViewModel : BaseModel
|
|||
get => selectedCustomBrowserIndex;
|
||||
set
|
||||
{
|
||||
selectedCustomBrowserIndex = value;
|
||||
OnPropertyChanged(nameof(CustomBrowser));
|
||||
// When one custom browser is selected and removed, the index will become -1, so we need to ignore this change
|
||||
if (value < 0) return;
|
||||
if (selectedCustomBrowserIndex != value)
|
||||
{
|
||||
selectedCustomBrowserIndex = value;
|
||||
OnPropertyChanged(nameof(CustomBrowser));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,22 +45,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ public partial class SelectFileManagerViewModel : BaseModel
|
|||
get => selectedCustomExplorerIndex;
|
||||
set
|
||||
{
|
||||
// When one custom file manager is selected and removed, the index will become -1, so we need to ignore this change
|
||||
if (value < 0) return;
|
||||
if (selectedCustomExplorerIndex != value)
|
||||
{
|
||||
selectedCustomExplorerIndex = value;
|
||||
|
|
@ -98,27 +100,12 @@ public partial class SelectFileManagerViewModel : BaseModel
|
|||
}
|
||||
}
|
||||
|
||||
internal void OpenUrl(string absoluteUri)
|
||||
{
|
||||
App.API.OpenUrl(absoluteUri);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
CustomExplorers.Add(new()
|
||||
{
|
||||
Name = "New Profile"
|
||||
Name = App.API.GetTranslation("defaultBrowser_new_profile")
|
||||
});
|
||||
SelectedCustomExplorerIndex = CustomExplorers.Count - 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue