mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add refresh plugin action keyword display when changed
This commit is contained in:
parent
34622d6bbf
commit
651e2a95b2
3 changed files with 20 additions and 9 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Flow.Launcher.Core.Plugin;
|
using Flow.Launcher.Core.Plugin;
|
||||||
using Flow.Launcher.Core.Resource;
|
using Flow.Launcher.Core.Resource;
|
||||||
using Flow.Launcher.Infrastructure.Exception;
|
using Flow.Launcher.Infrastructure.Exception;
|
||||||
using Flow.Launcher.Infrastructure.UserSettings;
|
using Flow.Launcher.Infrastructure.UserSettings;
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
|
using Flow.Launcher.ViewModel;
|
||||||
|
|
||||||
namespace Flow.Launcher
|
namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
|
|
@ -12,13 +13,14 @@ namespace Flow.Launcher
|
||||||
private PluginPair _plugin;
|
private PluginPair _plugin;
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
private readonly Internationalization _translater = InternationalizationManager.Instance;
|
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();
|
InitializeComponent();
|
||||||
_plugin = PluginManager.GetPluginForId(pluginId);
|
_plugin = PluginManager.GetPluginForId(pluginId);
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
if (_plugin == null)
|
this.pluginViewModel = pluginViewModel;
|
||||||
{
|
{
|
||||||
MessageBox.Show(_translater.GetTranslation("cannotFindSpecifiedPlugin"));
|
MessageBox.Show(_translater.GetTranslation("cannotFindSpecifiedPlugin"));
|
||||||
Close();
|
Close();
|
||||||
|
|
@ -41,10 +43,9 @@ namespace Flow.Launcher
|
||||||
var oldActionKeyword = _plugin.Metadata.ActionKeywords[0];
|
var oldActionKeyword = _plugin.Metadata.ActionKeywords[0];
|
||||||
var newActionKeyword = tbAction.Text.Trim();
|
var newActionKeyword = tbAction.Text.Trim();
|
||||||
newActionKeyword = newActionKeyword.Length > 0 ? newActionKeyword : "*";
|
newActionKeyword = newActionKeyword.Length > 0 ? newActionKeyword : "*";
|
||||||
if (!PluginManager.ActionKeywordRegistered(newActionKeyword))
|
if (!pluginViewModel.IsActionKeywordRegistered(newActionKeyword))
|
||||||
{
|
{
|
||||||
var id = _plugin.Metadata.ID;
|
pluginViewModel.ChangeActionKeyword(newActionKeyword, oldActionKeyword);
|
||||||
PluginManager.ReplaceActionKeyword(id, oldActionKeyword, newActionKeyword);
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
@ -214,7 +214,7 @@ namespace Flow.Launcher
|
||||||
if (e.ChangedButton == MouseButton.Left)
|
if (e.ChangedButton == MouseButton.Left)
|
||||||
{
|
{
|
||||||
var id = _viewModel.SelectedPlugin.PluginPair.Metadata.ID;
|
var id = _viewModel.SelectedPlugin.PluginPair.Metadata.ID;
|
||||||
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings);
|
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings, _viewModel.SelectedPlugin);
|
||||||
changeKeywordsWindow.ShowDialog();
|
changeKeywordsWindow.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
using Flow.Launcher.Core.Resource;
|
using Flow.Launcher.Core.Resource;
|
||||||
using Flow.Launcher.Infrastructure.Image;
|
using Flow.Launcher.Infrastructure.Image;
|
||||||
|
using Flow.Launcher.Core.Plugin;
|
||||||
|
|
||||||
namespace Flow.Launcher.ViewModel
|
namespace Flow.Launcher.ViewModel
|
||||||
{
|
{
|
||||||
|
|
@ -25,5 +26,14 @@ namespace Flow.Launcher.ViewModel
|
||||||
public string InitilizaTime => string.Format(_translator.GetTranslation("plugin_init_time"), PluginPair.Metadata.InitTime);
|
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 QueryTime => string.Format(_translator.GetTranslation("plugin_query_time"), PluginPair.Metadata.AvgQueryTime);
|
||||||
public string ActionKeywordsText => string.Join(Query.ActionKeywordSeperater, PluginPair.Metadata.ActionKeywords);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue