77using System . Windows . Input ;
88using System . Windows . Controls ;
99using Flow . Launcher . Core ;
10+ using Flow . Launcher . ViewModel ;
1011
1112namespace Flow . Launcher
1213{
1314 public partial class CustomQueryHotkeySetting : Window
1415 {
1516 private SettingWindow _settingWidow ;
17+ private readonly Settings _settings ;
18+ private readonly MainViewModel _mainViewModel ;
1619 private bool update ;
1720 private CustomPluginHotkey updateCustomHotkey ;
18- public Settings Settings { get ; }
1921
20- public CustomQueryHotkeySetting ( SettingWindow settingWidow , Settings settings )
22+ public CustomQueryHotkeySetting ( SettingWindow settingWidow , Settings settings , MainViewModel mainVM )
2123 {
2224 _settingWidow = settingWidow ;
23- Settings = settings ;
25+ _settings = settings ;
26+ _mainViewModel = mainVM ;
2427 InitializeComponent ( ) ;
2528 }
2629
@@ -33,13 +36,13 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e)
3336 {
3437 if ( ! update )
3538 {
36- Settings . CustomPluginHotkeys ??= new ObservableCollection < CustomPluginHotkey > ( ) ;
39+ _settings . CustomPluginHotkeys ??= new ObservableCollection < CustomPluginHotkey > ( ) ;
3740
3841 var pluginHotkey = new CustomPluginHotkey
3942 {
4043 Hotkey = HotkeyControl . CurrentHotkey . ToString ( ) , ActionKeyword = tbAction . Text
4144 } ;
42- Settings . CustomPluginHotkeys . Add ( pluginHotkey ) ;
45+ _settings . CustomPluginHotkeys . Add ( pluginHotkey ) ;
4346
4447 HotKeyMapper . SetCustomQueryHotkey ( pluginHotkey ) ;
4548 }
@@ -59,7 +62,7 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e)
5962
6063 public void UpdateItem ( CustomPluginHotkey item )
6164 {
62- updateCustomHotkey = Settings . CustomPluginHotkeys . FirstOrDefault ( o =>
65+ updateCustomHotkey = _settings . CustomPluginHotkeys . FirstOrDefault ( o =>
6366 o . ActionKeyword == item . ActionKeyword && o . Hotkey == item . Hotkey ) ;
6467 if ( updateCustomHotkey == null )
6568 {
@@ -77,8 +80,7 @@ public void UpdateItem(CustomPluginHotkey item)
7780 private void BtnTestActionKeyword_OnClick ( object sender , RoutedEventArgs e )
7881 {
7982 App . API . ChangeQuery ( tbAction . Text ) ;
80- Application . Current . MainWindow . Show ( ) ;
81- Application . Current . MainWindow . Opacity = 1 ;
83+ _mainViewModel . Show ( false ) ;
8284 Application . Current . MainWindow . Focus ( ) ;
8385 }
8486
0 commit comments