Skip to content

Fix Custom Query Hotkey / Shortcuts Preview Issue #3248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ namespace Flow.Launcher
public partial class CustomQueryHotkeySetting : Window
{
private SettingWindow _settingWidow;
private readonly Settings _settings;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to change this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code quality.😂 I prefer _ prefix for readonly properties and majority of codes in FL uses this way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this is a field instead of property (maybe it worth to figure out the difference). For here, I think it's fine.

private bool update;
private CustomPluginHotkey updateCustomHotkey;
public Settings Settings { get; }

public CustomQueryHotkeySetting(SettingWindow settingWidow, Settings settings)
{
_settingWidow = settingWidow;
Settings = settings;
_settings = settings;
InitializeComponent();
}

Expand All @@ -33,13 +33,13 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
if (!update)
{
Settings.CustomPluginHotkeys ??= new ObservableCollection<CustomPluginHotkey>();
_settings.CustomPluginHotkeys ??= new ObservableCollection<CustomPluginHotkey>();

var pluginHotkey = new CustomPluginHotkey
{
Hotkey = HotkeyControl.CurrentHotkey.ToString(), ActionKeyword = tbAction.Text
};
Settings.CustomPluginHotkeys.Add(pluginHotkey);
_settings.CustomPluginHotkeys.Add(pluginHotkey);

HotKeyMapper.SetCustomQueryHotkey(pluginHotkey);
}
Expand All @@ -59,7 +59,7 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e)

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)
{
Expand All @@ -77,8 +77,7 @@ public void UpdateItem(CustomPluginHotkey item)
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();
}

Expand Down
3 changes: 1 addition & 2 deletions Flow.Launcher/CustomShortcutSetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
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();
}
}
Expand Down
Loading