diff --git a/Flow.Launcher/ActionKeywords.xaml b/Flow.Launcher/ActionKeywords.xaml index 39574964ba3..9d032efd9cb 100644 --- a/Flow.Launcher/ActionKeywords.xaml +++ b/Flow.Launcher/ActionKeywords.xaml @@ -1,4 +1,4 @@ - + Height="250" Width="500"> - + - + - - - Old ActionKeywords: - - - + + + + - + - - diff --git a/Flow.Launcher/ActionKeywords.xaml.cs b/Flow.Launcher/ActionKeywords.xaml.cs index d902731478d..4a236834748 100644 --- a/Flow.Launcher/ActionKeywords.xaml.cs +++ b/Flow.Launcher/ActionKeywords.xaml.cs @@ -4,30 +4,33 @@ using Flow.Launcher.Infrastructure.Exception; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; +using Flow.Launcher.ViewModel; namespace Flow.Launcher { public partial class ActionKeywords : Window { - private PluginPair _plugin; - private Settings _settings; - private readonly Internationalization _translater = InternationalizationManager.Instance; + private readonly PluginPair plugin; + private Settings settings; + private readonly Internationalization translater = InternationalizationManager.Instance; + private readonly PluginViewModel pluginViewModel; - public ActionKeywords(string pluginId, Settings settings) + public ActionKeywords(string pluginId, Settings settings, PluginViewModel pluginViewModel) { InitializeComponent(); - _plugin = PluginManager.GetPluginForId(pluginId); - _settings = settings; - if (_plugin == null) + plugin = PluginManager.GetPluginForId(pluginId); + this.settings = settings; + this.pluginViewModel = pluginViewModel; + if (plugin == null) { - MessageBox.Show(_translater.GetTranslation("cannotFindSpecifiedPlugin")); + MessageBox.Show(translater.GetTranslation("cannotFindSpecifiedPlugin")); Close(); } } private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e) { - tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeperater, _plugin.Metadata.ActionKeywords.ToArray()); + tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeperater, plugin.Metadata.ActionKeywords.ToArray()); tbAction.Focus(); } @@ -38,19 +41,17 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e) private void btnDone_OnClick(object sender, RoutedEventArgs _) { - var oldActionKeyword = _plugin.Metadata.ActionKeywords[0]; + var oldActionKeyword = plugin.Metadata.ActionKeywords[0]; var newActionKeyword = tbAction.Text.Trim(); newActionKeyword = newActionKeyword.Length > 0 ? newActionKeyword : "*"; - if (!PluginManager.ActionKeywordRegistered(newActionKeyword)) + if (!pluginViewModel.IsActionKeywordRegistered(newActionKeyword)) { - var id = _plugin.Metadata.ID; - PluginManager.ReplaceActionKeyword(id, oldActionKeyword, newActionKeyword); - MessageBox.Show(_translater.GetTranslation("success")); + pluginViewModel.ChangeActionKeyword(newActionKeyword, oldActionKeyword); Close(); } else { - string msg = _translater.GetTranslation("newActionKeywordsHasBeenAssigned"); + string msg = translater.GetTranslation("newActionKeywordsHasBeenAssigned"); MessageBox.Show(msg); } } diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml b/Flow.Launcher/CustomQueryHotkeySetting.xaml index 0eb0da1da93..5f4cdff19e4 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml @@ -1,4 +1,4 @@ - + + + + + + @@ -18,7 +24,7 @@ - + @@ -29,9 +35,9 @@ - diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs index 441bba5097b..bf5c7d7691c 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs @@ -1,13 +1,13 @@ -using System; -using System.Collections.Generic; +using Flow.Launcher.Core.Resource; +using Flow.Launcher.Infrastructure.Hotkey; +using Flow.Launcher.Infrastructure.UserSettings; +using NHotkey; +using NHotkey.Wpf; +using System; using System.Collections.ObjectModel; using System.Linq; using System.Windows; -using NHotkey; -using NHotkey.Wpf; -using Flow.Launcher.Core.Resource; -using Flow.Launcher.Infrastructure.Hotkey; -using Flow.Launcher.Infrastructure.UserSettings; +using System.Windows.Input; namespace Flow.Launcher { @@ -125,5 +125,10 @@ private void SetHotkey(HotkeyModel hotkey, EventHandler action) MessageBox.Show(errorMsg); } } + + private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e) + { + Close(); + } } } diff --git a/Flow.Launcher/Languages/da.xaml b/Flow.Launcher/Languages/da.xaml index 296f6aa8bca..19e1951d846 100644 --- a/Flow.Launcher/Languages/da.xaml +++ b/Flow.Launcher/Languages/da.xaml @@ -36,8 +36,8 @@ Nøgleord Plugin bibliotek Forfatter - Initaliseringstid: {0}ms - Søgetid: {0}ms + Initaliseringstid: + Søgetid: Tema diff --git a/Flow.Launcher/Languages/de.xaml b/Flow.Launcher/Languages/de.xaml index 91b7c79829f..39dc9b3779f 100644 --- a/Flow.Launcher/Languages/de.xaml +++ b/Flow.Launcher/Languages/de.xaml @@ -1,4 +1,4 @@ - @@ -36,8 +36,8 @@ Aktionsschlüsselwörter Pluginordner Autor - Initialisierungszeit: {0}ms - Abfragezeit: {0}ms + Initialisierungszeit: + Abfragezeit: Theme diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 1b69c1b90f2..0bf211bd9a5 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -1,4 +1,4 @@ - @@ -40,11 +40,13 @@ Plugin Find more plugins Disable - Action keywords + Action keyword: + Current action keyword: + New action keyword: Plugin Directory Author - Init time: {0}ms - Query time: {0}ms + Init time: + Query time: Theme diff --git a/Flow.Launcher/Languages/fr.xaml b/Flow.Launcher/Languages/fr.xaml index f43cbb49894..a8f280bd168 100644 --- a/Flow.Launcher/Languages/fr.xaml +++ b/Flow.Launcher/Languages/fr.xaml @@ -40,8 +40,8 @@ Mot-clé d'action : Répertoire Auteur - Chargement : {0}ms - Utilisation : {0}ms + Chargement : + Utilisation : Thèmes diff --git a/Flow.Launcher/Languages/it.xaml b/Flow.Launcher/Languages/it.xaml index aa29a889179..e85e49933c6 100644 --- a/Flow.Launcher/Languages/it.xaml +++ b/Flow.Launcher/Languages/it.xaml @@ -1,4 +1,4 @@ - @@ -40,8 +40,8 @@ Parole chiave Cartella Plugin Autore - Tempo di avvio: {0}ms - Tempo ricerca: {0}ms + Tempo di avvio: + Tempo ricerca: Tema diff --git a/Flow.Launcher/Languages/ja.xaml b/Flow.Launcher/Languages/ja.xaml index 34c38edf45d..937a1e504bc 100644 --- a/Flow.Launcher/Languages/ja.xaml +++ b/Flow.Launcher/Languages/ja.xaml @@ -1,4 +1,4 @@ - @@ -41,8 +41,8 @@ キーワード プラグイン・ディレクトリ 作者 - 初期化時間: {0}ms - クエリ時間: {0}ms + 初期化時間: + クエリ時間: テーマ diff --git a/Flow.Launcher/Languages/ko.xaml b/Flow.Launcher/Languages/ko.xaml index 21f1f027372..6c755dbae24 100644 --- a/Flow.Launcher/Languages/ko.xaml +++ b/Flow.Launcher/Languages/ko.xaml @@ -1,4 +1,4 @@ - @@ -40,8 +40,8 @@ 액션 키워드 플러그인 디렉토리 저자 - 초기화 시간: {0}ms - 쿼리 시간: {0}ms + 초기화 시간: + 쿼리 시간: 테마 diff --git a/Flow.Launcher/Languages/nb-NO.xaml b/Flow.Launcher/Languages/nb-NO.xaml index 1dbfcf5d41b..19f6cc36bc1 100644 --- a/Flow.Launcher/Languages/nb-NO.xaml +++ b/Flow.Launcher/Languages/nb-NO.xaml @@ -40,8 +40,8 @@ Handlingsnøkkelord Utvidelseskatalog Forfatter - Oppstartstid: {0}ms - Spørringstid: {0}ms + Oppstartstid: + Spørringstid: Tema diff --git a/Flow.Launcher/Languages/nl.xaml b/Flow.Launcher/Languages/nl.xaml index 7d24d90679b..ca7fed180ba 100644 --- a/Flow.Launcher/Languages/nl.xaml +++ b/Flow.Launcher/Languages/nl.xaml @@ -1,4 +1,4 @@ - @@ -36,8 +36,8 @@ Action terfwoorden Plugin map Auteur - Init tijd: {0}ms - Query tijd: {0}ms + Init tijd: + Query tijd: Thema diff --git a/Flow.Launcher/Languages/pl.xaml b/Flow.Launcher/Languages/pl.xaml index 4f26cfaaf04..4f3042be33f 100644 --- a/Flow.Launcher/Languages/pl.xaml +++ b/Flow.Launcher/Languages/pl.xaml @@ -1,4 +1,4 @@ - @@ -36,8 +36,8 @@ Wyzwalacze Folder wtyczki Autor - Czas ładowania: {0}ms - Czas zapytania: {0}ms + Czas ładowania: + Czas zapytania: Skórka diff --git a/Flow.Launcher/Languages/pt-br.xaml b/Flow.Launcher/Languages/pt-br.xaml index 11d8b839e89..dce921ff7f7 100644 --- a/Flow.Launcher/Languages/pt-br.xaml +++ b/Flow.Launcher/Languages/pt-br.xaml @@ -1,4 +1,4 @@ - @@ -40,8 +40,8 @@ Palavras-chave de ação Diretório de Plugins Autor - Tempo de inicialização: {0}ms - Tempo de consulta: {0}ms + Tempo de inicialização: + Tempo de consulta: Tema diff --git a/Flow.Launcher/Languages/ru.xaml b/Flow.Launcher/Languages/ru.xaml index b86fcf377a1..d0d6ff0e59f 100644 --- a/Flow.Launcher/Languages/ru.xaml +++ b/Flow.Launcher/Languages/ru.xaml @@ -1,4 +1,4 @@ - @@ -36,8 +36,8 @@ Ключевое слово Папка Автор - Инициализация: {0}ms - Запрос: {0}ms + Инициализация: + Запрос: Темы diff --git a/Flow.Launcher/Languages/sk.xaml b/Flow.Launcher/Languages/sk.xaml index 4ddbd839d25..a2ff5926dc6 100644 --- a/Flow.Launcher/Languages/sk.xaml +++ b/Flow.Launcher/Languages/sk.xaml @@ -1,4 +1,4 @@ - @@ -41,8 +41,8 @@ Skratka akcie Priečinok s pluginmy Autor - Čas inic.: {0}ms - Čas dopytu: {0}ms + Čas inic.: + Čas dopytu: Motív diff --git a/Flow.Launcher/Languages/sr.xaml b/Flow.Launcher/Languages/sr.xaml index 41f112af6f5..0394b398d64 100644 --- a/Flow.Launcher/Languages/sr.xaml +++ b/Flow.Launcher/Languages/sr.xaml @@ -1,4 +1,4 @@ - @@ -40,8 +40,8 @@ Ključne reči Plugin direktorijum Autor - Vreme inicijalizacije: {0}ms - Vreme upita: {0}ms + Vreme inicijalizacije: + Vreme upita: Tema diff --git a/Flow.Launcher/Languages/tr.xaml b/Flow.Launcher/Languages/tr.xaml index 9e2624cc2f3..421375df9a4 100644 --- a/Flow.Launcher/Languages/tr.xaml +++ b/Flow.Launcher/Languages/tr.xaml @@ -1,4 +1,4 @@ - @@ -42,8 +42,8 @@ Anahtar Kelimeler Eklenti Klasörü Yapımcı - Açılış Süresi: {0}ms - Sorgu Süresi: {0}ms + Açılış Süresi: + Sorgu Süresi: Temalar diff --git a/Flow.Launcher/Languages/uk-UA.xaml b/Flow.Launcher/Languages/uk-UA.xaml index 0343f9d0f6b..b57676f8d62 100644 --- a/Flow.Launcher/Languages/uk-UA.xaml +++ b/Flow.Launcher/Languages/uk-UA.xaml @@ -1,4 +1,4 @@ - @@ -36,8 +36,8 @@ Ключове слово Директорія плагіну Автор - Ініціалізація: {0}ms - Запит: {0}ms + Ініціалізація: + Запит: Теми diff --git a/Flow.Launcher/Languages/zh-cn.xaml b/Flow.Launcher/Languages/zh-cn.xaml index c8bdc68909e..92ce60e7f2e 100644 --- a/Flow.Launcher/Languages/zh-cn.xaml +++ b/Flow.Launcher/Languages/zh-cn.xaml @@ -1,4 +1,4 @@ - @@ -41,8 +41,8 @@ 触发关键字 插件目录 作者 - 加载耗时 {0}ms - 查询耗时 {0}ms + 加载耗时 + 查询耗时 主题 diff --git a/Flow.Launcher/Languages/zh-tw.xaml b/Flow.Launcher/Languages/zh-tw.xaml index 322eaf32f83..294add207ee 100644 --- a/Flow.Launcher/Languages/zh-tw.xaml +++ b/Flow.Launcher/Languages/zh-tw.xaml @@ -1,4 +1,4 @@ - @@ -36,8 +36,8 @@ 觸發關鍵字 外掛資料夾 作者 - 載入耗時:{0}ms - 查詢耗時:{0}ms + 載入耗時: + 查詢耗時: 主題 diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 1708a517214..acd992b6c6d 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -175,14 +175,16 @@ + Margin="20 0 0 0"/> - - + + + + diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index aa54bb7c5f4..eb5fd7de09f 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System; using System.IO; using System.Windows; using System.Windows.Input; @@ -21,17 +20,17 @@ public partial class SettingWindow { private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; - public readonly IPublicAPI _api; - private Settings _settings; - private SettingWindowViewModel _viewModel; + public readonly IPublicAPI API; + private Settings settings; + private SettingWindowViewModel viewModel; public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel) { InitializeComponent(); - _settings = viewModel.Settings; + settings = viewModel.Settings; DataContext = viewModel; - _viewModel = viewModel; - _api = api; + this.viewModel = viewModel; + API = api; } #region General @@ -94,7 +93,7 @@ private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e) var pythonPath = Path.Combine(pythonDirectory, PluginsLoader.PythonExecutable); if (File.Exists(pythonPath)) { - _settings.PluginSettings.PythonDirectory = pythonDirectory; + settings.PluginSettings.PythonDirectory = pythonDirectory; MessageBox.Show("Remember to restart Flow Launcher use new Python path"); } else @@ -111,7 +110,7 @@ private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e) private void OnHotkeyControlLoaded(object sender, RoutedEventArgs e) { - HotkeyControl.SetHotkey(_viewModel.Settings.Hotkey, false); + HotkeyControl.SetHotkey(viewModel.Settings.Hotkey, false); } void OnHotkeyChanged(object sender, EventArgs e) @@ -129,8 +128,8 @@ void OnHotkeyChanged(object sender, EventArgs e) Application.Current.MainWindow.Visibility = Visibility.Hidden; } }); - RemoveHotkey(_settings.Hotkey); - _settings.Hotkey = HotkeyControl.CurrentHotkey.ToString(); + RemoveHotkey(settings.Hotkey); + settings.Hotkey = HotkeyControl.CurrentHotkey.ToString(); } } @@ -159,7 +158,7 @@ void RemoveHotkey(string hotkeyStr) private void OnDeleteCustomHotkeyClick(object sender, RoutedEventArgs e) { - var item = _viewModel.SelectedCustomPluginHotkey; + var item = viewModel.SelectedCustomPluginHotkey; if (item == null) { MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); @@ -173,17 +172,17 @@ private void OnDeleteCustomHotkeyClick(object sender, RoutedEventArgs e) MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { - _settings.CustomPluginHotkeys.Remove(item); + settings.CustomPluginHotkeys.Remove(item); RemoveHotkey(item.Hotkey); } } private void OnnEditCustomHotkeyClick(object sender, RoutedEventArgs e) { - var item = _viewModel.SelectedCustomPluginHotkey; + var item = viewModel.SelectedCustomPluginHotkey; if (item != null) { - CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this, _settings); + CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this, settings); window.UpdateItem(item); window.ShowDialog(); } @@ -195,7 +194,7 @@ private void OnnEditCustomHotkeyClick(object sender, RoutedEventArgs e) private void OnAddCustomeHotkeyClick(object sender, RoutedEventArgs e) { - new CustomQueryHotkeySetting(this, _settings).ShowDialog(); + new CustomQueryHotkeySetting(this, settings).ShowDialog(); } #endregion @@ -204,17 +203,17 @@ private void OnAddCustomeHotkeyClick(object sender, RoutedEventArgs e) private void OnPluginToggled(object sender, RoutedEventArgs e) { - var id = _viewModel.SelectedPlugin.PluginPair.Metadata.ID; + var id = viewModel.SelectedPlugin.PluginPair.Metadata.ID; // used to sync the current status from the plugin manager into the setting to keep consistency after save - _settings.PluginSettings.Plugins[id].Disabled = _viewModel.SelectedPlugin.PluginPair.Metadata.Disabled; + settings.PluginSettings.Plugins[id].Disabled = viewModel.SelectedPlugin.PluginPair.Metadata.Disabled; } private void OnPluginActionKeywordsClick(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) { - var id = _viewModel.SelectedPlugin.PluginPair.Metadata.ID; - ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings); + var id = viewModel.SelectedPlugin.PluginPair.Metadata.ID; + ActionKeywords changeKeywordsWindow = new ActionKeywords(id, settings, viewModel.SelectedPlugin); changeKeywordsWindow.ShowDialog(); } } @@ -223,7 +222,7 @@ private void OnPluginNameClick(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) { - var website = _viewModel.SelectedPlugin.PluginPair.Metadata.Website; + var website = viewModel.SelectedPlugin.PluginPair.Metadata.Website; if (!string.IsNullOrEmpty(website)) { var uri = new Uri(website); @@ -239,7 +238,7 @@ private void OnPluginDirecotyClick(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) { - var directory = _viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory; + var directory = viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory; if (!string.IsNullOrEmpty(directory)) FilesFolders.OpenPath(directory); } @@ -250,7 +249,7 @@ private void OnPluginDirecotyClick(object sender, MouseButtonEventArgs e) private void OnTestProxyClick(object sender, RoutedEventArgs e) { // TODO: change to command - var msg = _viewModel.TestProxy(); + var msg = viewModel.TestProxy(); MessageBox.Show(msg); // TODO: add message box service } @@ -258,7 +257,7 @@ private void OnTestProxyClick(object sender, RoutedEventArgs e) private async void OnCheckUpdates(object sender, RoutedEventArgs e) { - _viewModel.UpdateApp(); // TODO: change to command + viewModel.UpdateApp(); // TODO: change to command } private void OnRequestNavigate(object sender, RequestNavigateEventArgs e) @@ -269,7 +268,7 @@ private void OnRequestNavigate(object sender, RequestNavigateEventArgs e) private void OnClosed(object sender, EventArgs e) { - _viewModel.Save(); + viewModel.Save(); } private void OnCloseExecuted(object sender, ExecutedRoutedEventArgs e) diff --git a/Flow.Launcher/ViewModel/PluginViewModel.cs b/Flow.Launcher/ViewModel/PluginViewModel.cs index e7963677121..eb7e0054d10 100644 --- a/Flow.Launcher/ViewModel/PluginViewModel.cs +++ b/Flow.Launcher/ViewModel/PluginViewModel.cs @@ -1,8 +1,9 @@ -using System.Windows; +using System.Windows; using System.Windows.Media; using Flow.Launcher.Plugin; using Flow.Launcher.Core.Resource; using Flow.Launcher.Infrastructure.Image; +using Flow.Launcher.Core.Plugin; namespace Flow.Launcher.ViewModel { @@ -22,8 +23,17 @@ public bool PluginState } } public Visibility ActionKeywordsVisibility => PluginPair.Metadata.ActionKeywords.Count > 1 ? Visibility.Collapsed : Visibility.Visible; - public string InitilizaTime => string.Format(_translator.GetTranslation("plugin_init_time"), PluginPair.Metadata.InitTime); - public string QueryTime => string.Format(_translator.GetTranslation("plugin_query_time"), PluginPair.Metadata.AvgQueryTime); + public string InitilizaTime => PluginPair.Metadata.InitTime.ToString() + "ms"; + public string QueryTime => PluginPair.Metadata.AvgQueryTime + "ms"; public string ActionKeywordsText => string.Join(Query.ActionKeywordSeperater, PluginPair.Metadata.ActionKeywords); + + public void ChangeActionKeyword(string newActionKeyword, string oldActionKeyword) + { + PluginManager.ReplaceActionKeyword(PluginPair.Metadata.ID, oldActionKeyword, newActionKeyword); + + OnPropertyChanged(nameof(ActionKeywordsText)); + } + + public bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword); } }