mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into jsonrpc_connection_loss
This commit is contained in:
commit
983d53a180
17 changed files with 75 additions and 110 deletions
|
|
@ -205,7 +205,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(nameof(PluginManager), $"Fail to Init plugin: {pair.Metadata.Name}", e);
|
||||
Log.Exception(ClassName, $"Fail to Init plugin: {pair.Metadata.Name}", e);
|
||||
pair.Metadata.Disabled = true;
|
||||
failedPlugins.Enqueue(pair);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
|
||||
namespace Flow.Launcher.Core.Resource
|
||||
{
|
||||
[Obsolete("InternationalizationManager.Instance is obsolete. Use Ioc.Default.GetRequiredService<Internationalization>() instead.")]
|
||||
public static class InternationalizationManager
|
||||
{
|
||||
public static Internationalization Instance
|
||||
=> Ioc.Default.GetRequiredService<Internationalization>();
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,6 @@ using System.Text.Json.Serialization;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Http;
|
||||
|
|
@ -131,7 +129,7 @@ namespace Flow.Launcher.Core
|
|||
|
||||
await using var jsonStream = await Http.GetStreamAsync(api).ConfigureAwait(false);
|
||||
|
||||
var releases = await System.Text.Json.JsonSerializer.DeserializeAsync<List<GithubRelease>>(jsonStream).ConfigureAwait(false);
|
||||
var releases = await JsonSerializer.DeserializeAsync<List<GithubRelease>>(jsonStream).ConfigureAwait(false);
|
||||
var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First();
|
||||
var latestUrl = latest.HtmlUrl.Replace("/tag/", "/download/");
|
||||
|
||||
|
|
@ -146,10 +144,9 @@ namespace Flow.Launcher.Core
|
|||
return manager;
|
||||
}
|
||||
|
||||
private static string NewVersionTips(string version)
|
||||
private string NewVersionTips(string version)
|
||||
{
|
||||
var translator = Ioc.Default.GetRequiredService<Internationalization>();
|
||||
var tips = string.Format(translator.GetTranslation("newVersionTips"), version);
|
||||
var tips = string.Format(_api.GetTranslation("newVersionTips"), version);
|
||||
|
||||
return tips;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
using System.Windows;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using Flow.Launcher.Core;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
|
@ -10,20 +8,19 @@ namespace Flow.Launcher
|
|||
{
|
||||
public partial class ActionKeywords
|
||||
{
|
||||
private readonly PluginPair plugin;
|
||||
private readonly Internationalization translater = InternationalizationManager.Instance;
|
||||
private readonly PluginViewModel pluginViewModel;
|
||||
private readonly PluginPair _plugin;
|
||||
private readonly PluginViewModel _pluginViewModel;
|
||||
|
||||
public ActionKeywords(PluginViewModel pluginViewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
plugin = pluginViewModel.PluginPair;
|
||||
this.pluginViewModel = pluginViewModel;
|
||||
_plugin = pluginViewModel.PluginPair;
|
||||
_pluginViewModel = pluginViewModel;
|
||||
}
|
||||
|
||||
private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeparator, plugin.Metadata.ActionKeywords.ToArray());
|
||||
tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeparator, _plugin.Metadata.ActionKeywords.ToArray());
|
||||
tbAction.Focus();
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +31,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void btnDone_OnClick(object sender, RoutedEventArgs _)
|
||||
{
|
||||
var oldActionKeywords = plugin.Metadata.ActionKeywords;
|
||||
var oldActionKeywords = _plugin.Metadata.ActionKeywords;
|
||||
|
||||
var newActionKeywords = tbAction.Text.Split(Query.ActionKeywordSeparator).ToList();
|
||||
newActionKeywords.RemoveAll(string.IsNullOrEmpty);
|
||||
|
|
@ -48,7 +45,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
if (oldActionKeywords.Count != newActionKeywords.Count)
|
||||
{
|
||||
ReplaceActionKeyword(plugin.Metadata.ID, removedActionKeywords, addedActionKeywords);
|
||||
ReplaceActionKeyword(_plugin.Metadata.ID, removedActionKeywords, addedActionKeywords);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -58,18 +55,16 @@ namespace Flow.Launcher
|
|||
if (sortedOldActionKeywords.SequenceEqual(sortedNewActionKeywords))
|
||||
{
|
||||
// User just changes the sequence of action keywords
|
||||
var msg = translater.GetTranslation("newActionKeywordsSameAsOld");
|
||||
MessageBoxEx.Show(msg);
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("newActionKeywordsSameAsOld"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplaceActionKeyword(plugin.Metadata.ID, removedActionKeywords, addedActionKeywords);
|
||||
ReplaceActionKeyword(_plugin.Metadata.ID, removedActionKeywords, addedActionKeywords);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = translater.GetTranslation("newActionKeywordsHasBeenAssigned");
|
||||
App.API.ShowMsgBox(msg);
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("newActionKeywordsHasBeenAssigned"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +80,7 @@ namespace Flow.Launcher
|
|||
}
|
||||
|
||||
// Update action keywords text and close window
|
||||
pluginViewModel.OnActionKeywordsChanged();
|
||||
_pluginViewModel.OnActionKeywordsChanged();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ namespace Flow.Launcher
|
|||
|
||||
public void OnSecondAppStarted()
|
||||
{
|
||||
Ioc.Default.GetRequiredService<MainViewModel>().Show();
|
||||
API.ShowMainWindow();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
namespace Flow.Launcher.Converters;
|
||||
|
|
@ -23,7 +22,7 @@ public class TextConverter : IValueConverter
|
|||
if (translationKey is null)
|
||||
return id;
|
||||
|
||||
return InternationalizationManager.Instance.GetTranslation(translationKey);
|
||||
return App.API.GetTranslation(translationKey);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new InvalidOperationException();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
|
@ -53,14 +52,13 @@ namespace Flow.Launcher
|
|||
Close();
|
||||
}
|
||||
|
||||
|
||||
public void UpdateItem(CustomPluginHotkey item)
|
||||
{
|
||||
updateCustomHotkey = _settings.CustomPluginHotkeys.FirstOrDefault(o =>
|
||||
o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey);
|
||||
if (updateCustomHotkey == null)
|
||||
{
|
||||
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("invalidPluginHotkey"));
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
|
@ -68,7 +66,7 @@ namespace Flow.Launcher
|
|||
tbAction.Text = updateCustomHotkey.ActionKeyword;
|
||||
HotkeyControl.SetHotkey(updateCustomHotkey.Hotkey, false);
|
||||
update = true;
|
||||
lblAdd.Text = InternationalizationManager.Instance.GetTranslation("update");
|
||||
lblAdd.Text = App.API.GetTranslation("update");
|
||||
}
|
||||
|
||||
private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
using Flow.Launcher.Core.Resource;
|
||||
using System;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Flow.Launcher.SettingPages.ViewModels;
|
||||
using Flow.Launcher.Core;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
|
|
@ -41,15 +39,15 @@ namespace Flow.Launcher
|
|||
|
||||
private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
|
||||
if (string.IsNullOrEmpty(Key) || string.IsNullOrEmpty(Value))
|
||||
{
|
||||
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("emptyShortcut"));
|
||||
return;
|
||||
}
|
||||
// Check if key is modified or adding a new one
|
||||
if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key))
|
||||
{
|
||||
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("duplicateShortcut"));
|
||||
return;
|
||||
}
|
||||
DialogResult = !update || originalKey != Key || originalValue != Value;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ using Flow.Launcher.Infrastructure.UserSettings;
|
|||
using System;
|
||||
using NHotkey;
|
||||
using NHotkey.Wpf;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using ChefKeys;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
|
|
@ -56,9 +55,9 @@ internal static class HotKeyMapper
|
|||
string.Format("|HotkeyMapper.SetWithChefKeys|Error registering hotkey: {0} \nStackTrace:{1}",
|
||||
e.Message,
|
||||
e.StackTrace));
|
||||
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
||||
string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle");
|
||||
MessageBoxEx.Show(errorMsg, errorMsgTitle);
|
||||
string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
||||
string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle");
|
||||
App.API.ShowMsgBox(errorMsg, errorMsgTitle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,8 +81,8 @@ internal static class HotKeyMapper
|
|||
e.Message,
|
||||
e.StackTrace,
|
||||
hotkeyStr));
|
||||
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
||||
string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle");
|
||||
string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
||||
string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle");
|
||||
App.API.ShowMsgBox(errorMsg, errorMsgTitle);
|
||||
}
|
||||
}
|
||||
|
|
@ -107,9 +106,9 @@ internal static class HotKeyMapper
|
|||
string.Format("|HotkeyMapper.RemoveHotkey|Error removing hotkey: {0} \nStackTrace:{1}",
|
||||
e.Message,
|
||||
e.StackTrace));
|
||||
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("unregisterHotkeyFailed"), hotkeyStr);
|
||||
string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle");
|
||||
MessageBoxEx.Show(errorMsg, errorMsgTitle);
|
||||
string errorMsg = string.Format(App.API.GetTranslation("unregisterHotkeyFailed"), hotkeyStr);
|
||||
string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle");
|
||||
App.API.ShowMsgBox(errorMsg, errorMsgTitle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,8 +136,8 @@ internal static class HotKeyMapper
|
|||
if (_mainViewModel.ShouldIgnoreHotkeys())
|
||||
return;
|
||||
|
||||
_mainViewModel.Show();
|
||||
_mainViewModel.ChangeQueryText(hotkey.ActionKeyword, true);
|
||||
App.API.ShowMainWindow();
|
||||
App.API.ChangeQuery(hotkey.ActionKeyword, true);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System.Threading.Tasks;
|
|||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
|
|
@ -65,7 +64,6 @@ namespace Flow.Launcher
|
|||
hotkeyControl.RefreshHotkeyInterface(hotkeyControl.Hotkey);
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty ChangeHotkeyProperty = DependencyProperty.Register(
|
||||
nameof(ChangeHotkey),
|
||||
typeof(ICommand),
|
||||
|
|
@ -79,7 +77,6 @@ namespace Flow.Launcher
|
|||
set { SetValue(ChangeHotkeyProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(
|
||||
nameof(Type),
|
||||
typeof(HotkeyType),
|
||||
|
|
@ -227,19 +224,18 @@ namespace Flow.Launcher
|
|||
private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) =>
|
||||
hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey);
|
||||
|
||||
public string EmptyHotkey => InternationalizationManager.Instance.GetTranslation("none");
|
||||
public string EmptyHotkey => App.API.GetTranslation("none");
|
||||
|
||||
public ObservableCollection<string> KeysToDisplay { get; set; } = new();
|
||||
|
||||
public HotkeyModel CurrentHotkey { get; private set; } = new(false, false, false, false, Key.None);
|
||||
|
||||
|
||||
public void GetNewHotkey(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenHotkeyDialog();
|
||||
_ = OpenHotkeyDialogAsync();
|
||||
}
|
||||
|
||||
private async Task OpenHotkeyDialog()
|
||||
private async Task OpenHotkeyDialogAsync()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Hotkey))
|
||||
{
|
||||
|
|
@ -262,12 +258,11 @@ namespace Flow.Launcher
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
|
||||
{
|
||||
if (triggerValidate)
|
||||
{
|
||||
bool hotkeyAvailable = false;
|
||||
bool hotkeyAvailable;
|
||||
// TODO: This is a temporary way to enforce changing only the open flow hotkey to Win, and will be removed by PR #3157
|
||||
if (keyModel.ToString() == "LWin" || keyModel.ToString() == "RWin")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System.Windows;
|
|||
using System.Windows.Input;
|
||||
using ChefKeys;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
|
|
@ -34,7 +33,7 @@ public partial class HotkeyControlDialog : ContentDialog
|
|||
|
||||
public EResultType ResultType { get; private set; } = EResultType.Cancel;
|
||||
public string ResultValue { get; private set; } = string.Empty;
|
||||
public static string EmptyHotkey => InternationalizationManager.Instance.GetTranslation("none");
|
||||
public static string EmptyHotkey => App.API.GetTranslation("none");
|
||||
|
||||
private static bool isOpenFlowHotkey;
|
||||
|
||||
|
|
@ -42,7 +41,7 @@ public partial class HotkeyControlDialog : ContentDialog
|
|||
{
|
||||
WindowTitle = windowTitle switch
|
||||
{
|
||||
"" or null => InternationalizationManager.Instance.GetTranslation("hotkeyRegTitle"),
|
||||
"" or null => App.API.GetTranslation("hotkeyRegTitle"),
|
||||
_ => windowTitle
|
||||
};
|
||||
DefaultHotkey = defaultHotkey;
|
||||
|
|
@ -141,14 +140,14 @@ public partial class HotkeyControlDialog : ContentDialog
|
|||
if (_hotkeySettings.RegisteredHotkeys.FirstOrDefault(v => v.Hotkey == hotkey) is { } registeredHotkeyData)
|
||||
{
|
||||
var description = string.Format(
|
||||
InternationalizationManager.Instance.GetTranslation(registeredHotkeyData.DescriptionResourceKey),
|
||||
App.API.GetTranslation(registeredHotkeyData.DescriptionResourceKey),
|
||||
registeredHotkeyData.DescriptionFormatVariables
|
||||
);
|
||||
Alert.Visibility = Visibility.Visible;
|
||||
if (registeredHotkeyData.RemoveHotkey is not null)
|
||||
{
|
||||
tbMsg.Text = string.Format(
|
||||
InternationalizationManager.Instance.GetTranslation("hotkeyUnavailableEditable"),
|
||||
App.API.GetTranslation("hotkeyUnavailableEditable"),
|
||||
description
|
||||
);
|
||||
SaveBtn.IsEnabled = false;
|
||||
|
|
@ -160,7 +159,7 @@ public partial class HotkeyControlDialog : ContentDialog
|
|||
else
|
||||
{
|
||||
tbMsg.Text = string.Format(
|
||||
InternationalizationManager.Instance.GetTranslation("hotkeyUnavailableUneditable"),
|
||||
App.API.GetTranslation("hotkeyUnavailableUneditable"),
|
||||
description
|
||||
);
|
||||
SaveBtn.IsEnabled = false;
|
||||
|
|
@ -176,7 +175,7 @@ public partial class HotkeyControlDialog : ContentDialog
|
|||
|
||||
if (!CheckHotkeyAvailability(hotkey.Value, true))
|
||||
{
|
||||
tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable");
|
||||
tbMsg.Text = App.API.GetTranslation("hotkeyUnavailable");
|
||||
Alert.Visibility = Visibility.Visible;
|
||||
SaveBtn.IsEnabled = false;
|
||||
SaveBtn.Visibility = Visibility.Visible;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ namespace Flow.Launcher.Resources.Pages
|
|||
Ioc.Default.GetRequiredService<WelcomeViewModel>().PageNum = 1;
|
||||
InitializeComponent();
|
||||
}
|
||||
private Internationalization _translater => InternationalizationManager.Instance;
|
||||
|
||||
private readonly Internationalization _translater = Ioc.Default.GetRequiredService<Internationalization>();
|
||||
|
||||
public List<Language> Languages => _translater.LoadAvailableLanguages();
|
||||
|
||||
public Settings Settings { get; set; }
|
||||
|
|
@ -30,12 +32,11 @@ namespace Flow.Launcher.Resources.Pages
|
|||
}
|
||||
set
|
||||
{
|
||||
InternationalizationManager.Instance.ChangeLanguage(value);
|
||||
_translater.ChangeLanguage(value);
|
||||
|
||||
if (InternationalizationManager.Instance.PromptShouldUsePinyin(value))
|
||||
if (_translater.PromptShouldUsePinyin(value))
|
||||
Settings.ShouldUsePinyin = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Flow.Launcher.Core;
|
||||
using Flow.Launcher.Core.Configuration;
|
||||
|
|
@ -19,12 +17,14 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
public Settings Settings { get; }
|
||||
private readonly Updater _updater;
|
||||
private readonly IPortable _portable;
|
||||
private readonly Internationalization _translater;
|
||||
|
||||
public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortable portable)
|
||||
public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortable portable, Internationalization translater)
|
||||
{
|
||||
Settings = settings;
|
||||
_updater = updater;
|
||||
_portable = portable;
|
||||
_translater = translater;
|
||||
UpdateEnumDropdownLocalizations();
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +32,6 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
|
||||
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
|
||||
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
|
||||
|
||||
|
||||
public bool StartFlowLauncherOnSystemStartup
|
||||
{
|
||||
|
|
@ -61,8 +60,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"),
|
||||
e.Message);
|
||||
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -89,8 +87,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"),
|
||||
e.Message);
|
||||
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -121,7 +118,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
}
|
||||
|
||||
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
|
||||
private bool _portableMode = DataLocation.PortableDataLocationInUse();
|
||||
private static bool _portableMode = DataLocation.PortableDataLocationInUse();
|
||||
|
||||
public bool PortableMode
|
||||
{
|
||||
|
|
@ -173,9 +170,9 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
get => Settings.Language;
|
||||
set
|
||||
{
|
||||
InternationalizationManager.Instance.ChangeLanguage(value);
|
||||
_translater.ChangeLanguage(value);
|
||||
|
||||
if (InternationalizationManager.Instance.PromptShouldUsePinyin(value))
|
||||
if (_translater.PromptShouldUsePinyin(value))
|
||||
ShouldUsePinyin = true;
|
||||
|
||||
UpdateEnumDropdownLocalizations();
|
||||
|
|
@ -188,14 +185,14 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
set => Settings.ShouldUsePinyin = value;
|
||||
}
|
||||
|
||||
public List<Language> Languages => InternationalizationManager.Instance.LoadAvailableLanguages();
|
||||
public List<Language> Languages => _translater.LoadAvailableLanguages();
|
||||
|
||||
public string AlwaysPreviewToolTip => string.Format(
|
||||
InternationalizationManager.Instance.GetTranslation("AlwaysPreviewToolTip"),
|
||||
App.API.GetTranslation("AlwaysPreviewToolTip"),
|
||||
Settings.PreviewHotkey
|
||||
);
|
||||
|
||||
private string GetFileFromDialog(string title, string filter = "")
|
||||
private static string GetFileFromDialog(string title, string filter = "")
|
||||
{
|
||||
var dlg = new OpenFileDialog
|
||||
{
|
||||
|
|
@ -237,7 +234,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
private void SelectPython()
|
||||
{
|
||||
var selectedFile = GetFileFromDialog(
|
||||
InternationalizationManager.Instance.GetTranslation("selectPythonExecutable"),
|
||||
App.API.GetTranslation("selectPythonExecutable"),
|
||||
"Python|pythonw.exe"
|
||||
);
|
||||
|
||||
|
|
@ -249,7 +246,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
private void SelectNode()
|
||||
{
|
||||
var selectedFile = GetFileFromDialog(
|
||||
InternationalizationManager.Instance.GetTranslation("selectNodeExecutable"),
|
||||
App.API.GetTranslation("selectNodeExecutable"),
|
||||
"node|*.exe"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System.Linq;
|
||||
using System.Windows;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
|
|
@ -41,15 +40,15 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
|||
var item = SelectedCustomPluginHotkey;
|
||||
if (item is null)
|
||||
{
|
||||
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("pleaseSelectAnItem"));
|
||||
return;
|
||||
}
|
||||
|
||||
var result = App.API.ShowMsgBox(
|
||||
string.Format(
|
||||
InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey
|
||||
App.API.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey
|
||||
),
|
||||
InternationalizationManager.Instance.GetTranslation("delete"),
|
||||
App.API.GetTranslation("delete"),
|
||||
MessageBoxButton.YesNo
|
||||
);
|
||||
|
||||
|
|
@ -66,7 +65,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
|||
var item = SelectedCustomPluginHotkey;
|
||||
if (item is null)
|
||||
{
|
||||
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("pleaseSelectAnItem"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -87,15 +86,15 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
|||
var item = SelectedCustomShortcut;
|
||||
if (item is null)
|
||||
{
|
||||
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("pleaseSelectAnItem"));
|
||||
return;
|
||||
}
|
||||
|
||||
var result = App.API.ShowMsgBox(
|
||||
string.Format(
|
||||
InternationalizationManager.Instance.GetTranslation("deleteCustomShortcutWarning"), item.Key, item.Value
|
||||
App.API.GetTranslation("deleteCustomShortcutWarning"), item.Key, item.Value
|
||||
),
|
||||
InternationalizationManager.Instance.GetTranslation("delete"),
|
||||
App.API.GetTranslation("delete"),
|
||||
MessageBoxButton.YesNo
|
||||
);
|
||||
|
||||
|
|
@ -111,7 +110,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
|||
var item = SelectedCustomShortcut;
|
||||
if (item is null)
|
||||
{
|
||||
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("pleaseSelectAnItem"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System.Net;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Flow.Launcher.Core;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ public partial class SettingsPaneProxyViewModel : BaseModel
|
|||
private void OnTestProxyClicked()
|
||||
{
|
||||
var message = TestProxy();
|
||||
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation(message));
|
||||
App.API.ShowMsgBox(App.API.GetTranslation(message));
|
||||
}
|
||||
|
||||
private string TestProxy()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Core;
|
||||
using Flow.Launcher.Core.Configuration;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.SettingPages.ViewModels;
|
||||
|
||||
|
|
@ -18,7 +19,8 @@ public partial class SettingsPaneGeneral
|
|||
var settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
var updater = Ioc.Default.GetRequiredService<Updater>();
|
||||
var portable = Ioc.Default.GetRequiredService<Portable>();
|
||||
_viewModel = new SettingsPaneGeneralViewModel(settings, updater, portable);
|
||||
var translater = Ioc.Default.GetRequiredService<Internationalization>();
|
||||
_viewModel = new SettingsPaneGeneralViewModel(settings, updater, portable, translater);
|
||||
DataContext = _viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ using CommunityToolkit.Mvvm.Input;
|
|||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Infrastructure.Image;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.Storage;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
|
|
@ -275,7 +274,7 @@ namespace Flow.Launcher.ViewModel
|
|||
Hide();
|
||||
|
||||
await PluginManager.ReloadDataAsync().ConfigureAwait(false);
|
||||
Notification.Show(App.API.GetTranslation("success"),
|
||||
App.API.ShowMsg(App.API.GetTranslation("success"),
|
||||
App.API.GetTranslation("completedSuccessfully"));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue