diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 50eb30998..2a4b22bf3 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -112,7 +112,7 @@ namespace Flow.Launcher.Core.Plugin public Control CreateSettingPanel() { if (Settings == null || Settings.Count == 0) - return new(); + return null; var settingWindow = new UserControl(); var mainPanel = new Grid { Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center }; diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs index 81e7600b8..1bd6ee95b 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs @@ -13,14 +13,14 @@ namespace Flow.Launcher public partial class CustomQueryHotkeySetting : Window { private SettingWindow _settingWidow; + private readonly Settings _settings; private bool update; private CustomPluginHotkey updateCustomHotkey; - public Settings Settings { get; } public CustomQueryHotkeySetting(SettingWindow settingWidow, Settings settings) { _settingWidow = settingWidow; - Settings = settings; + _settings = settings; InitializeComponent(); } @@ -33,13 +33,13 @@ namespace Flow.Launcher { if (!update) { - Settings.CustomPluginHotkeys ??= new ObservableCollection(); + _settings.CustomPluginHotkeys ??= new ObservableCollection(); var pluginHotkey = new CustomPluginHotkey { Hotkey = HotkeyControl.CurrentHotkey.ToString(), ActionKeyword = tbAction.Text }; - Settings.CustomPluginHotkeys.Add(pluginHotkey); + _settings.CustomPluginHotkeys.Add(pluginHotkey); HotKeyMapper.SetCustomQueryHotkey(pluginHotkey); } @@ -59,7 +59,7 @@ namespace Flow.Launcher public void UpdateItem(CustomPluginHotkey item) { - updateCustomHotkey = Settings.CustomPluginHotkeys.FirstOrDefault(o => + updateCustomHotkey = _settings.CustomPluginHotkeys.FirstOrDefault(o => o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey); if (updateCustomHotkey == null) { @@ -77,8 +77,7 @@ namespace Flow.Launcher private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e) { App.API.ChangeQuery(tbAction.Text); - Application.Current.MainWindow.Show(); - Application.Current.MainWindow.Opacity = 1; + App.API.ShowMainWindow(); Application.Current.MainWindow.Focus(); } diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs index dec3506eb..05d4d3d83 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml.cs +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -65,8 +65,7 @@ namespace Flow.Launcher private void BtnTestShortcut_OnClick(object sender, RoutedEventArgs e) { App.API.ChangeQuery(tbExpand.Text); - Application.Current.MainWindow.Show(); - Application.Current.MainWindow.Opacity = 1; + App.API.ShowMainWindow(); Application.Current.MainWindow.Focus(); } } diff --git a/Flow.Launcher/ViewModel/PluginViewModel.cs b/Flow.Launcher/ViewModel/PluginViewModel.cs index 4ce8bd470..a46b98d64 100644 --- a/Flow.Launcher/ViewModel/PluginViewModel.cs +++ b/Flow.Launcher/ViewModel/PluginViewModel.cs @@ -90,7 +90,7 @@ namespace Flow.Launcher.ViewModel private Control _bottomPart2; public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginDisplayBottomData() : null; - public bool HasSettingControl => PluginPair.Plugin is ISettingProvider; + public bool HasSettingControl => PluginPair.Plugin is ISettingProvider settingProvider && settingProvider.CreateSettingPanel() != null; public Control SettingControl => IsExpanded ? _settingControl diff --git a/Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj b/Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj index 3db0cd0cb..6d338733e 100644 --- a/Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj +++ b/Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj @@ -42,7 +42,6 @@ - diff --git a/Plugins/Flow.Launcher.Plugin.Url/Main.cs b/Plugins/Flow.Launcher.Plugin.Url/Main.cs index 80425a8ff..03516636d 100644 --- a/Plugins/Flow.Launcher.Plugin.Url/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Url/Main.cs @@ -1,11 +1,10 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; -using System.Windows.Controls; namespace Flow.Launcher.Plugin.Url { - public class Main : ISettingProvider,IPlugin, IPluginI18n + public class Main : IPlugin, IPluginI18n { //based on https://gist.github.com/dperini/729294 private const string urlPattern = "^" + @@ -43,7 +42,6 @@ namespace Flow.Launcher.Plugin.Url Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); private PluginInitContext context; private Settings _settings; - public List Query(Query query) { @@ -82,12 +80,6 @@ namespace Flow.Launcher.Plugin.Url return new List(0); } - - public Control CreateSettingPanel() - { - return new SettingsControl(context.API,_settings); - } - public bool IsURL(string raw) { raw = raw.ToLower(); diff --git a/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml b/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml deleted file mode 100644 index 8ff7b5ab5..000000000 --- a/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml.cs b/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml.cs deleted file mode 100644 index f68d1bb2d..000000000 --- a/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Windows.Controls; - -namespace Flow.Launcher.Plugin.Url -{ - public partial class SettingsControl : UserControl - { - private Settings _settings; - private IPublicAPI _flowlauncherAPI; - - public SettingsControl(IPublicAPI flowlauncherAPI,Settings settings) - { - InitializeComponent(); - _settings = settings; - _flowlauncherAPI = flowlauncherAPI; - - } - } -}