From c1ca76dd15800ad72f540cffc521a9790493288d Mon Sep 17 00:00:00 2001 From: YFdyh000 Date: Sun, 29 Nov 2020 16:11:58 +0800 Subject: [PATCH 1/3] fix tray menu translation --- Flow.Launcher/MainWindow.xaml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 2c0beaaabcd..28ad80603cd 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -53,11 +53,12 @@ private void OnClosing(object sender, CancelEventArgs e) private void OnInitialized(object sender, EventArgs e) { // show notify icon when flowlauncher is hided - InitializeNotifyIcon(); } private void OnLoaded(object sender, RoutedEventArgs _) { + InitializeNotifyIcon(); + // todo is there a way to set blur only once? ThemeManager.Instance.SetBlurForWindow(); WindowsInteropHelper.DisableControlBox(this); From 5a9c631577cba212869cd6388fba57cd084f7dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Sun, 29 Nov 2020 20:50:28 +0800 Subject: [PATCH 2/3] Use PropertyChange event to change text when language has changed. --- .../Resource/Internationalization.cs | 3 ++- .../UserSettings/Settings.cs | 10 ++++++- Flow.Launcher/MainWindow.xaml.cs | 27 ++++++++++++++++--- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 1df6f2a049b..9c5bb9cc33b 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reflection; using System.Windows; +using Flow.Launcher; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Logger; @@ -88,7 +89,6 @@ public void ChangeLanguage(Language language) { language = language.NonNull(); - Settings.Language = language.LanguageCode; RemoveOldLanguageFiles(); if (language != AvailableLanguages.English) @@ -96,6 +96,7 @@ public void ChangeLanguage(Language language) LoadLanguage(language); } UpdatePluginMetadataTranslations(); + Settings.Language = language.LanguageCode; } diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 837fe3b7164..832b6fbfaf2 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -9,10 +9,18 @@ namespace Flow.Launcher.Infrastructure.UserSettings { public class Settings : BaseModel { + private string language = "en"; + public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}"; public string OpenResultModifiers { get; set; } = KeyConstant.Alt; public bool ShowOpenResultHotkey { get; set; } = true; - public string Language { get; set; } = "en"; + public string Language + { + get => language; set { + language = value; + OnPropertyChanged(); + } + } public string Theme { get; set; } = Constant.DefaultTheme; public bool UseDropShadowEffect { get; set; } = false; public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name; diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 28ad80603cd..5583887625d 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -52,11 +52,12 @@ private void OnClosing(object sender, CancelEventArgs e) private void OnInitialized(object sender, EventArgs e) { - // show notify icon when flowlauncher is hided + } private void OnLoaded(object sender, RoutedEventArgs _) { + // show notify icon when flowlauncher is hidden InitializeNotifyIcon(); // todo is there a way to set blur only once? @@ -88,11 +89,19 @@ private void OnLoaded(object sender, RoutedEventArgs _) }; _settings.PropertyChanged += (o, e) => { - if (e.PropertyName == nameof(Settings.HideNotifyIcon)) + switch (e.PropertyName) { - _notifyIcon.Visible = !_settings.HideNotifyIcon; + case nameof(Settings.HideNotifyIcon): + _notifyIcon.Visible = !_settings.HideNotifyIcon; + break; + case nameof(Settings.Language): + UpdateNotifyIconText(); + break; } }; + + + InitializePosition(); } @@ -104,6 +113,18 @@ private void InitializePosition() _settings.WindowLeft = Left; } + private void UpdateNotifyIconText() + { + var menu = _notifyIcon.ContextMenuStrip; + var open = menu.Items[0]; + var setting = menu.Items[1]; + var exit = menu.Items[2]; + + open.Text = InternationalizationManager.Instance.GetTranslation("iconTrayOpen"); + setting.Text = InternationalizationManager.Instance.GetTranslation("iconTraySettings"); + exit.Text = InternationalizationManager.Instance.GetTranslation("iconTrayExit"); + } + private void InitializeNotifyIcon() { _notifyIcon = new NotifyIcon From ac6dea1322a319e282c4233449ca02e0507d510a Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 30 Nov 2020 07:31:38 +1100 Subject: [PATCH 3/3] clear whitespaces, no code changes --- Flow.Launcher.Core/Resource/Internationalization.cs | 1 - Flow.Launcher/MainWindow.xaml.cs | 5 ----- 2 files changed, 6 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 9c5bb9cc33b..64b949cbbd2 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Reflection; using System.Windows; -using Flow.Launcher; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Logger; diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 5583887625d..993eb76c50b 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -100,8 +100,6 @@ private void OnLoaded(object sender, RoutedEventArgs _) } }; - - InitializePosition(); } @@ -201,7 +199,6 @@ private void OnPreviewMouseButtonDown(object sender, MouseButtonEventArgs e) } } - private void OnDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) @@ -316,7 +313,5 @@ private void OnTextChanged(object sender, TextChangedEventArgs e) _viewModel.QueryTextCursorMovedToEnd = false; } } - - } } \ No newline at end of file