mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
- Add i18n injection to Application.Resources for DynamicResource bindings - Create Avalonia settings views for plugins: - Explorer (ExplorerSettings + QuickAccessLinkSettings dialog) - BrowserBookmark (SettingsControl + CustomBrowserSettingWindow) - Calculator (CalculatorSettings) - ProcessKiller (SettingsControl) - PluginsManager (PluginsManagerSettings) - WebSearch (SettingsControl) - Shell (ShellSetting + converter) - Program (ProgramSetting) - Add IsAvalonia detection pattern for dual-framework dialog support - Update 11 plugin .csproj files with CopyToAvaloniaOutput targets - Add System.Threading.Tasks using for async RelayCommand support
87 lines
2.9 KiB
C#
87 lines
2.9 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Markup.Xaml;
|
|
using FluentAvalonia.UI.Controls;
|
|
using System;
|
|
|
|
namespace Flow.Launcher.Plugin.WebSearch.Views.Avalonia
|
|
{
|
|
public partial class SettingsControl : UserControl
|
|
{
|
|
private readonly PluginInitContext _context;
|
|
private readonly SettingsViewModel _viewModel;
|
|
|
|
public SettingsControl(PluginInitContext context, SettingsViewModel viewModel)
|
|
{
|
|
InitializeComponent();
|
|
_context = context;
|
|
_viewModel = viewModel;
|
|
DataContext = viewModel;
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
private async void OnAddSearchSourceClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var dialog = new ContentDialog
|
|
{
|
|
Title = "Add Search Source",
|
|
Content = "Adding search sources is not yet implemented in the Avalonia version.",
|
|
CloseButtonText = "OK"
|
|
};
|
|
|
|
if (VisualRoot is TopLevel topLevel)
|
|
{
|
|
await dialog.ShowAsync(topLevel);
|
|
}
|
|
}
|
|
|
|
private async void OnEditSearchSourceClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var dialog = new ContentDialog
|
|
{
|
|
Title = "Edit Search Source",
|
|
Content = "Editing search sources is not yet implemented in the Avalonia version.",
|
|
CloseButtonText = "OK"
|
|
};
|
|
|
|
if (VisualRoot is TopLevel topLevel)
|
|
{
|
|
await dialog.ShowAsync(topLevel);
|
|
}
|
|
}
|
|
|
|
private async void OnDeleteSearchSourceClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (_viewModel.Settings.SelectedSearchSource != null)
|
|
{
|
|
var selected = _viewModel.Settings.SelectedSearchSource;
|
|
var warning = _context.API.GetTranslation("flowlauncher_plugin_websearch_delete_warning");
|
|
var formatted = string.Format(warning, selected.Title);
|
|
|
|
var dialog = new ContentDialog
|
|
{
|
|
Title = "Delete Search Source",
|
|
Content = formatted,
|
|
PrimaryButtonText = "Yes",
|
|
CloseButtonText = "No"
|
|
};
|
|
|
|
if (VisualRoot is TopLevel topLevel)
|
|
{
|
|
var result = await dialog.ShowAsync(topLevel);
|
|
|
|
if (result == ContentDialogResult.Primary)
|
|
{
|
|
var id = _context.CurrentPluginMetadata.ID;
|
|
_context.API.RemoveActionKeyword(id, selected.ActionKeyword);
|
|
_viewModel.Settings.SearchSources.Remove(selected);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|