Merge pull request #223 from taooceros/fixTrayMenuTranslation

fix tray menu translation
This commit is contained in:
Jeremy Wu 2020-11-30 07:35:18 +11:00 committed by GitHub
commit 920668db00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 9 deletions

View file

@ -88,7 +88,6 @@ namespace Flow.Launcher.Core.Resource
{
language = language.NonNull();
Settings.Language = language.LanguageCode;
RemoveOldLanguageFiles();
if (language != AvailableLanguages.English)
@ -96,6 +95,7 @@ namespace Flow.Launcher.Core.Resource
LoadLanguage(language);
}
UpdatePluginMetadataTranslations();
Settings.Language = language.LanguageCode;
}

View file

@ -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;

View file

@ -52,12 +52,14 @@ namespace Flow.Launcher
private void OnInitialized(object sender, EventArgs e)
{
// show notify icon when flowlauncher is hided
InitializeNotifyIcon();
}
private void OnLoaded(object sender, RoutedEventArgs _)
{
// show notify icon when flowlauncher is hidden
InitializeNotifyIcon();
// todo is there a way to set blur only once?
ThemeManager.Instance.SetBlurForWindow();
WindowsInteropHelper.DisableControlBox(this);
@ -87,11 +89,17 @@ namespace Flow.Launcher
};
_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();
}
@ -103,6 +111,18 @@ namespace Flow.Launcher
_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
@ -179,7 +199,6 @@ namespace Flow.Launcher
}
}
private void OnDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
@ -294,7 +313,5 @@ namespace Flow.Launcher
_viewModel.QueryTextCursorMovedToEnd = false;
}
}
}
}