Flow.Launcher
Flow.Launcher copied to clipboard
IPluginHotkey Interface for Global Hotkey & Window Hotkey / Support Rename File & Folder by Hotkey or Context Menu
Context
Windows system has a default context menu for doing some operations to one specific object like exe file, pdf file, etc. And some operations can have some hotkeys like ctrl-c for copy, etc. Since Flow provides many results like them, we should add context menu for them.
Flow designed context menu is good, but currently, for hotkey event binding in context menu, Flow introduces action context (ActionContext parameter in Action and AsyncAction in Result class) like ctrl, alt, win key with the enter hotkey event (this is the key to open the action in one result) which means Flow need to regard ctrl+enter key event as enter event so that ctrl key will be passed with enter key.
This can lead many possible problems:
- Code quality issue: All events will be put in one action delegate with if sentences to check the action context.
- Window hotkey binding complexity: Flow needs to bind many preset hotkeys like ctrl-enter which can lead to complexity to hotkey management.
- Plugin hotkey registration difficulty: Plugin can only register hotkeys to one results with enter key, and it cannot register other hotkeys like F2 or something else.
- Plugin result confusion: Using alt+enter or ctrl+enter will trigger enter event for those results without specific handler for action context.
Considering these issues, I would like to deprecate the action context API and introduce IPluginHotkey interface which can help plugins to register any hotkeys for their results. Additionally, plugins can return results with their supported hotkeys. And we need to find a workaround to ensure the compatibility for action context and I think we can fully deprecate it in future.
In future, if plugins can register their hotkeys and specific supported hotkeys for their results. And we can look forward to a command bar like what does as Raycast. It will tell users what commands are available for the selected result. And it looks very nice for me, and I really enjoy this design.
Changes:
- New Interface
IPluginHotkeyto register global & search window hotkeys for one plugins.
/// <summary>
/// Represent plugins that support global hotkey or search window hotkey.
/// </summary>
public interface IPluginHotkey : IFeatures
{
/// <summary>
/// Get the list of plugin hotkeys which will be registered in the settings page.
/// </summary>
/// <returns></returns>
List<BasePluginHotkey> GetPuginHotkeys();
}
- Plugin hotkey setting UI
- Add an item to the context menu for the explorer plugin that allow you to rename files/directories. It opens a dialog.
- Add a hotkey (defaults to F2) that also opens the dialog when a file is selected
-
Hotkey registration refactor for both global hotkeys and main window hotkeys (KeyBinding): Now we are using call back function to register / unregister global and main window hotkeys which can improve code quality (Put all codes related to hotkey in
HotkeyMapper.cs) -
Redesign welcome page 3: Removed Ctrl+Enter & Ctrl+Shift+Enter hotkeys since it will be deprated API and added more preset hotkeys.
- Redesign hotkey page: Removed Ctrl+Enter & Ctrl+Shift+Enter hotkeys since it will be deprated API and added all Flow hotkeys.
Resolve #1614.
TODOS:
- [x] Organize main window hotkeys, like Ctrl+Enter to open results.
- [x] Specific commands id in Result class.
- [x] Check if plugin is modified before querying (#3791).
- [x] Workaround for ActionContext compatibility.
- [x] Redesign welcome page 3.
- [x] Organize main window hotkeys in hotkey pages.
- [x] Improve plugin hotkey setting UI.
- [x] Initialize plugin hotkey & Update plugin info translations for
HotKeyMapper.Initialize();(#3854). - [ ] Fix // TODO: Do it after administrator mode PR after #3573.
Future:
- Command bar like Raycast with those commands (Not sure, need discussion)
Test:
- Welcome page hotkey can be changed.
- All preset hotkeys in Hotkey page can be changed.
- Result modifier can work.
- Custom Query Hotkey can be added, deleted and edited.
- Plugin global and window hotkey can be registered and edited.
- Original API ActionContext can work.
- Dialog Jump hotkey can be changed / enabled / disabled.