Skip to content

IPluginHotkey Interface for Global Hotkey & Window Hotkey / Support Rename File & Folder by Hotkey or Context Menu #3770

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

Open
wants to merge 167 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
81d5065
Added function to convert rad to deg and vice versa
Koisu-unavailable Jun 19, 2025
4e03b76
cleanup
Koisu-unavailable Jun 19, 2025
0c34eb0
fix formatting
Koisu-unavailable Jun 19, 2025
762e1c7
Fix Typo
VictoriousRaptor Jun 20, 2025
60e8226
added new action keyword
Koisu-unavailable Jun 20, 2025
8d8388b
Merge branch 'dev' of https://github.com/Koisu-unavailable/Flow.Launc…
Koisu-unavailable Jun 20, 2025
9eb4e64
Revert "Fix Typo"
Koisu-unavailable Jun 20, 2025
3bc06ac
Reapply "Fix Typo"
Koisu-unavailable Jun 20, 2025
c116ea2
added new view
Koisu-unavailable Jun 20, 2025
91e3582
Revert "added new view"
Koisu-unavailable Jun 20, 2025
bfb2adf
Revert "Reapply "Fix Typo""
Koisu-unavailable Jun 20, 2025
670dd1c
added new view
Koisu-unavailable Jun 20, 2025
39366b7
Revert "Revert "added new view""
Koisu-unavailable Jun 20, 2025
459d85d
added new dialogue box for renaming files
Koisu-unavailable Jun 22, 2025
5ae6f97
renaming half-works
Koisu-unavailable Jun 22, 2025
8282304
basic features of renaming files works
Koisu-unavailable Jun 22, 2025
c943982
polishing changes
Koisu-unavailable Jun 22, 2025
502a50b
added keybind to open the renaming dialog
Koisu-unavailable Jun 23, 2025
f36ee61
feat: :sparkles: Added keybind to rename files
Koisu-unavailable Jun 24, 2025
e12c2be
polished ui
Koisu-unavailable Jun 24, 2025
efe6595
revert bad changes
Koisu-unavailable Jun 24, 2025
9f32814
removed unnesscasry stuff
Koisu-unavailable Jun 24, 2025
432f6da
fixed icon in hotkey settings
Koisu-unavailable Jun 24, 2025
657bde5
revert changes to calculator plugin
Koisu-unavailable Jun 24, 2025
8138158
refactoring
Koisu-unavailable Jun 24, 2025
518f883
Changed RenameDialog to modal and added exception logging
Koisu-unavailable Jun 24, 2025
781feeb
added default to RenameFileHotkey
Koisu-unavailable Jun 24, 2025
b0beaaf
formatting
Koisu-unavailable Jun 24, 2025
402d398
checks for reserved names
Koisu-unavailable Jun 24, 2025
b556dac
Refactoring
Koisu-unavailable Jun 24, 2025
a6f1981
removed fragile error handling
Koisu-unavailable Jun 24, 2025
7ae261e
fix typo
Koisu-unavailable Jun 24, 2025
a5ef0cb
fixed unreachable code
Koisu-unavailable Jun 24, 2025
a326a76
refactoring
Koisu-unavailable Jun 24, 2025
54f126a
removed dynamic type
Koisu-unavailable Jun 24, 2025
f991d91
Improved File Rename Feature and Icon Update
onesounds Jun 25, 2025
94f3746
Add plugin hotkey model
Jack251970 Jun 25, 2025
5f49c43
Display plugin hotkey setting
Jack251970 Jun 25, 2025
605837b
Add global key registeration
Jack251970 Jun 25, 2025
f841175
Fix log message issue
Jack251970 Jun 25, 2025
8abd531
Add window key registeration
Jack251970 Jun 25, 2025
4d77bad
Sort hotkey info list
Jack251970 Jun 25, 2025
8ed495d
Improve code quality
Jack251970 Jun 25, 2025
f7fa647
Use IPluginHotkey for explorer plugin
Jack251970 Jun 25, 2025
f2358a5
Fix hotkey control construction issue
Jack251970 Jun 25, 2025
30b9b1f
Add Visible api
Jack251970 Jun 25, 2025
f837b2a
Remove unused using
Jack251970 Jun 25, 2025
35f8ea3
Check hotkey mapper count
Jack251970 Jun 25, 2025
8da182d
Close window when escape pressed
Koisu-unavailable Jun 25, 2025
043bf3b
remove unused using
Koisu-unavailable Jun 25, 2025
0aff9e3
Merge branch 'rename-file' of https://github.com/Koisu-unavailable/Fl…
Jack251970 Jun 26, 2025
53e0bc3
Improve hotkey model
Jack251970 Jun 26, 2025
724b8a7
Support change window hotkey
Jack251970 Jun 26, 2025
c7de03b
Save & restore old command
Jack251970 Jun 26, 2025
b52c7e7
Check result null & Improve docuements
Jack251970 Jun 26, 2025
590ea61
Skip other commands if executed
Jack251970 Jun 26, 2025
ead9b1e
Return to skip other commands
Jack251970 Jun 26, 2025
030a7f3
Adjust margins
Jack251970 Jun 26, 2025
854f808
Use IPluginHotkey for plugin manager plugin
Jack251970 Jun 26, 2025
9f404aa
Use IPluginHotkey for program plugin
Jack251970 Jun 26, 2025
3fe1e50
Resolve context data for uwps
Jack251970 Jun 26, 2025
96b5eb3
Skip this plugin if all hotkeys are invisible
Jack251970 Jun 26, 2025
ddc890e
Skip invisible hotkeys
Jack251970 Jun 26, 2025
e9727c4
Add todo
Jack251970 Jun 26, 2025
95fadcb
Merge branch 'dev' into rename-file
Jack251970 Jun 27, 2025
cda33df
Make constructor protected
Koisu-unavailable Jun 27, 2025
96b3645
Merge branch 'rename-file' of https://github.com/Koisu-unavailable/Fl…
Koisu-unavailable Jun 27, 2025
7fddfd9
Merge branch 'dev' into rename-file
Jack251970 Jun 28, 2025
e087d33
Add hotkey id check
Jack251970 Jun 28, 2025
3b4698e
Use selected results
Jack251970 Jun 28, 2025
e24af14
Add hotkey ids for all results
Jack251970 Jun 28, 2025
73a232f
Fix clone issue
Jack251970 Jun 30, 2025
c9db3ec
Improve string resource
Jack251970 Jun 30, 2025
14310d2
Add code comments
Jack251970 Jul 1, 2025
b87f233
Code quality
Jack251970 Jul 1, 2025
afdb56d
Change RegisteredHotkeys to observable
Jack251970 Jul 2, 2025
1d2aa96
Add property changed for CustomPluginHotkey
Jack251970 Jul 2, 2025
989206b
Add is empty for HotkeyModel
Jack251970 Jul 2, 2025
5910d1d
Add property changed for RegisteredHotkeyData.Hotkey
Jack251970 Jul 2, 2025
2259d74
Add registered type, type, command, command parameter for RegisteredH…
Jack251970 Jul 2, 2025
3231b1d
Implement initialization model for plugin hotkeys
Jack251970 Jul 2, 2025
051af06
Add toggle cmmand for main view model
Jack251970 Jul 2, 2025
20f065a
Remove key bindings which will be registered in hotkey mapper
Jack251970 Jul 2, 2025
d332472
Add todo
Jack251970 Jul 2, 2025
43beef4
Use command & parameter for SetGlobalHotkeyWithChefKeys
Jack251970 Jul 2, 2025
39fa79b
Prepare to deprecation
Jack251970 Jul 2, 2025
6e94d16
Code quality
Jack251970 Jul 2, 2025
f36ca62
Fix typos
Jack251970 Jul 2, 2025
495e2c1
Revert "Add property changed for RegisteredHotkeyData.Hotkey"
Jack251970 Jul 2, 2025
40f1fc6
Allow setter for RegisteredHotkeyData.Hotkey
Jack251970 Jul 2, 2025
f63b8bd
Add ToString
Jack251970 Jul 2, 2025
e41eccc
Add initialization log information
Jack251970 Jul 2, 2025
3b1e014
Add change support for Flow Launcher hotkeys
Jack251970 Jul 2, 2025
2cf6bfb
Prepare for deprecation
Jack251970 Jul 2, 2025
730625c
Remove ChangeHotkey event & Remove deprecated functions
Jack251970 Jul 2, 2025
1c8a8d0
Code quality
Jack251970 Jul 2, 2025
e061f14
Check plugin modified state
Jack251970 Jul 2, 2025
1057f4d
Improve code quality
Jack251970 Jul 2, 2025
d46dedd
Remove Settings.CustomPluginHotkeys null check
Jack251970 Jul 2, 2025
fd3eef4
Add Equals & GetHashCode for CustomPluginHotkey
Jack251970 Jul 2, 2025
96e8eae
Revert "Add property changed for CustomPluginHotkey"
Jack251970 Jul 2, 2025
d0fc344
Explictly implement PropertyChanged
Jack251970 Jul 2, 2025
c4ce8fe
Add check for invalid query shortcuts
Jack251970 Jul 2, 2025
476ad9b
Add constructor for CustomPluginHotkey
Jack251970 Jul 2, 2025
42e2035
Improve string
Jack251970 Jul 2, 2025
ff99669
Refactor custom query hotkey setting window
Jack251970 Jul 2, 2025
5fa3bec
Add hotkey change events for custom query hotkeys
Jack251970 Jul 2, 2025
698fe79
Remove unused removing
Jack251970 Jul 2, 2025
7d0cf1f
Add plugin hotkey type
Jack251970 Jul 2, 2025
805b8ef
No need to check hotkey command when removing
Jack251970 Jul 2, 2025
503bc48
Add empty for hotkey model
Jack251970 Jul 2, 2025
db1c1b2
Use changed event for plugin hotkeys
Jack251970 Jul 2, 2025
c4fbb3d
Check count
Jack251970 Jul 2, 2025
dad681d
Use callback to check plugin hotkey change
Jack251970 Jul 2, 2025
8d26c1c
Add string resource
Jack251970 Jul 2, 2025
cd3eeba
Remove used functions
Jack251970 Jul 2, 2025
11c5b7c
Merge branch 'dev' into rename-file
Jack251970 Jul 2, 2025
e196aa4
Remove todos
Jack251970 Jul 2, 2025
e6fb766
Mark ActionContext as deprecated
Jack251970 Jul 2, 2025
f657494
Workaround for ActionContext compatibility
Jack251970 Jul 2, 2025
2625f6f
Make GetPluginsForInterface private
Jack251970 Jul 3, 2025
089c0fd
Initialize plugin enumerable after all plugins are initialized
Jack251970 Jul 3, 2025
2a52c28
Store plugin hotkey info
Jack251970 Jul 3, 2025
19c5cc3
Merge branch 'dev' into rename-file
Jack251970 Jul 6, 2025
515f24d
Merge branch 'dev' into rename-file
Jack251970 Jul 6, 2025
4874586
Fix build issue
Jack251970 Jul 6, 2025
1948711
Add hotkey get function
Jack251970 Jul 6, 2025
9b92061
Check modified & use IDictionary
Jack251970 Jul 6, 2025
89b454b
Fix typos
Jack251970 Jul 6, 2025
f52ef92
Fix string typos
Jack251970 Jul 6, 2025
5191780
Fix blank line change
Jack251970 Jul 6, 2025
4055e30
Use set hotkey function instead of setter
Jack251970 Jul 6, 2025
a693773
Improve code quality
Jack251970 Jul 6, 2025
d79272a
Cache reversed names
Jack251970 Jul 6, 2025
35474f2
Merge branch 'dev' into rename-file
Jack251970 Jul 7, 2025
9806997
Merge branch 'dev' into rename-file
Jack251970 Jul 10, 2025
c326901
Fix spelling
Jack251970 Jul 10, 2025
e8707ad
Unify error strings
Jack251970 Jul 10, 2025
40ba1ae
Do not validate key gesture for plugin hotkeys
Jack251970 Jul 10, 2025
c2c8a82
Restore plugin hotkey setting if it is not editable anymore
Jack251970 Jul 10, 2025
0dd2f5c
Fix typos
Jack251970 Jul 10, 2025
476d846
Improve code quality
Jack251970 Jul 10, 2025
3dcf22e
Use sorted info
Jack251970 Jul 10, 2025
0077856
Return for exceptions
Jack251970 Jul 10, 2025
ad81a3c
Fix hotkey string issue
Jack251970 Jul 10, 2025
96bf445
Fix action context hotkey event logic
Jack251970 Jul 10, 2025
2febc34
Merge branch 'dev' into rename-file
Jack251970 Jul 12, 2025
633e6d3
Redesign welcome page 3
Jack251970 Jul 12, 2025
b7db22a
Redesign hotkey page
Jack251970 Jul 12, 2025
4ad7ca9
Only use one string
Jack251970 Jul 12, 2025
0d4598b
Add property changed for OpenResultModifiers
Jack251970 Jul 12, 2025
6c21f74
Add Result Modifier Hotkeys changed event
Jack251970 Jul 12, 2025
28bd07d
Improve code quality
Jack251970 Jul 12, 2025
64cf1ed
Fix IsActionContextEvent logic
Jack251970 Jul 12, 2025
ada2af8
Fix open result command parameter issue
Jack251970 Jul 12, 2025
2acf9b4
Merge branch 'dev' into rename-file
Jack251970 Jul 14, 2025
98179eb
Merge branch 'dev' into rename-file
Jack251970 Jul 15, 2025
15e4a4f
Merge branch 'dev' into rename-file
Jack251970 Jul 19, 2025
45ed9fa
Merge branch 'dev' into rename-file
Jack251970 Jul 20, 2025
11e8a58
Add dialog jump hotkey
Jack251970 Jul 20, 2025
2ce4157
Fix build issue
Jack251970 Jul 20, 2025
2f71d0d
Fix key duplication
Jack251970 Jul 20, 2025
adb1adb
Do not execute when dialog jump is disabled
Jack251970 Jul 20, 2025
b88e2e9
Do not register dialog jump hotkey when dialog jump is disabled
Jack251970 Jul 20, 2025
912d5dd
Merge branch 'dev' into rename-file
Jack251970 Jul 24, 2025
d8d42b8
Merge branch 'dev' into rename-file
Jack251970 Jul 27, 2025
98816ac
Fix build issue
Jack251970 Jul 27, 2025
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
14 changes: 8 additions & 6 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public void Initialize()
{
// Initialize dependency injection instances after Ioc.Default is created
_stringMatcher = Ioc.Default.GetRequiredService<StringMatcher>();

Check warning on line 29 in Flow.Launcher.Infrastructure/UserSettings/Settings.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

Check warning on line 29 in Flow.Launcher.Infrastructure/UserSettings/Settings.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

// Initialize application resources after application is created
var settingWindowFont = new FontFamily(SettingWindowFont);
Expand Down Expand Up @@ -58,6 +58,7 @@
public string OpenHistoryHotkey { get; set; } = $"Ctrl+H";
public string CycleHistoryUpHotkey { get; set; } = $"{KeyConstant.Alt} + Up";
public string CycleHistoryDownHotkey { get; set; } = $"{KeyConstant.Alt} + Down";
public string RenameFileHotkey { get; set; } = $"F2";

private string _language = Constant.SystemLanguageCode;
public string Language
Expand Down Expand Up @@ -472,13 +473,14 @@
list.Add(new(CycleHistoryUpHotkey, "CycleHistoryUpHotkey", () => CycleHistoryUpHotkey = ""));
if (!string.IsNullOrEmpty(CycleHistoryDownHotkey))
list.Add(new(CycleHistoryDownHotkey, "CycleHistoryDownHotkey", () => CycleHistoryDownHotkey = ""));

if (!string.IsNullOrEmpty(RenameFileHotkey))
list.Add(new RegisteredHotkeyData(RenameFileHotkey, "RenameFileHotkey", () => RenameFileHotkey = ""));
// Custom Query Hotkeys
foreach (var customPluginHotkey in CustomPluginHotkeys)
{
if (!string.IsNullOrEmpty(customPluginHotkey.Hotkey))
list.Add(new(customPluginHotkey.Hotkey, "customQueryHotkey", () => customPluginHotkey.Hotkey = ""));
}
foreach (var customPluginHotkey in CustomPluginHotkeys)
{
if (!string.IsNullOrEmpty(customPluginHotkey.Hotkey))
list.Add(new(customPluginHotkey.Hotkey, "customQueryHotkey", () => customPluginHotkey.Hotkey = ""));
}

return list;
}
Expand Down
17 changes: 17 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,25 @@
/// <param name="query">Query string</param>
/// <param name="stringToCompare">The string that will be compared against the query</param>
/// <returns>Match results</returns>

MatchResult FuzzySearch(string query, string stringToCompare);

/// <summary>
/// Returns if the given name is valid file name even if it doesn't exist
/// </summary>
/// <param name="name">the name to check</param>
public bool IsValidFileName(string name);
/// <summary>
/// Returns if the given name is valid directory name even if it doesn't exist
/// </summary>
/// <param name="name">the name to check</param>
public bool IsValidDirectoryName(string name);
/// <summary>
/// Open A dialog to rename the given file or folder
/// </summary>
/// <param name="info">The directory or file info for the thing to rename. You must check if it actually exists or this will throw an exception</param>


/// <summary>
/// Http download the spefic url and return as string
/// </summary>
Expand All @@ -237,7 +254,7 @@
Task<string> HttpGetStringAsync(string url, CancellationToken token = default);

/// <summary>
/// Http download the spefic url and return as stream

Check warning on line 257 in Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`spefic` is not a recognized word. (unrecognized-spelling)

Check warning on line 257 in Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`spefic` is not a recognized word. (unrecognized-spelling)
/// </summary>
/// <param name="url">URL to call Http Get</param>
/// <param name="token">Cancellation Token</param>
Expand Down Expand Up @@ -393,7 +410,7 @@

/// <summary>
/// Reloads the query.
/// When current results are from context menu or history, it will go back to query results before requerying.

Check warning on line 413 in Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`requerying` is not a recognized word. (unrecognized-spelling)

Check warning on line 413 in Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`requerying` is not a recognized word. (unrecognized-spelling)
/// </summary>
/// <param name="reselect">Choose the first result after reload if true; keep the last selected result if false. Default is true.</param>
public void ReQuery(bool reselect = true);
Expand Down
16 changes: 14 additions & 2 deletions Flow.Launcher/HotkeyControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
Expand Down Expand Up @@ -110,12 +111,14 @@
SelectPrevItemHotkey,
SelectPrevItemHotkey2,
SelectNextItemHotkey,
SelectNextItemHotkey2
SelectNextItemHotkey2,
RenameFileHotkey

}

// We can initialize settings in static field because it has been constructed in App constuctor
// and it will not construct settings instances twice
private static readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();

Check warning on line 121 in Flow.Launcher/HotkeyControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

Check warning on line 121 in Flow.Launcher/HotkeyControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

private string hotkey = string.Empty;
public string Hotkey
Expand All @@ -142,6 +145,8 @@
HotkeyType.SelectPrevItemHotkey2 => _settings.SelectPrevItemHotkey2,
HotkeyType.SelectNextItemHotkey => _settings.SelectNextItemHotkey,
HotkeyType.SelectNextItemHotkey2 => _settings.SelectNextItemHotkey2,
HotkeyType.RenameFileHotkey => _settings.RenameFileHotkey,

_ => throw new System.NotImplementedException("Hotkey type not set")
};
}
Expand Down Expand Up @@ -201,6 +206,9 @@
case HotkeyType.SelectNextItemHotkey2:
_settings.SelectNextItemHotkey2 = value;
break;
case HotkeyType.RenameFileHotkey:
_settings.RenameFileHotkey = value;
break;
default:
throw new System.NotImplementedException("Hotkey type not set");
}
Expand Down Expand Up @@ -231,7 +239,7 @@

public string EmptyHotkey => App.API.GetTranslation("none");

public ObservableCollection<string> KeysToDisplay { get; set; } = new();
public ObservableCollection<string> KeysToDisplay { get; set; } = new ObservableCollection<string>();

public HotkeyModel CurrentHotkey { get; private set; } = new(false, false, false, false, Key.None);

Expand All @@ -258,10 +266,10 @@
case HotkeyControlDialog.EResultType.Cancel:
SetHotkey(Hotkey);
return;
case HotkeyControlDialog.EResultType.Save:

Check warning on line 269 in Flow.Launcher/HotkeyControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`EResult` is not a recognized word. (unrecognized-spelling)

Check warning on line 269 in Flow.Launcher/HotkeyControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`EResult` is not a recognized word. (unrecognized-spelling)
SetHotkey(dialog.ResultValue);
break;
case HotkeyControlDialog.EResultType.Delete:

Check warning on line 272 in Flow.Launcher/HotkeyControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`EResult` is not a recognized word. (unrecognized-spelling)

Check warning on line 272 in Flow.Launcher/HotkeyControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`EResult` is not a recognized word. (unrecognized-spelling)
Delete();
break;
}
Expand Down Expand Up @@ -308,6 +316,7 @@

private void SetKeysToDisplay(HotkeyModel? hotkey)
{

KeysToDisplay.Clear();

if (hotkey == null || hotkey == default(HotkeyModel))
Expand All @@ -318,8 +327,11 @@

foreach (var key in hotkey.Value.EnumerateDisplayKeys()!)
{

KeysToDisplay.Add(key);
}


}

public void SetHotkey(string? keyStr, bool triggerValidate = true)
Expand Down
5 changes: 5 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -555,4 +555,9 @@
<system:String x:Key="FileSize">File Size</system:String>
<system:String x:Key="Created">Created</system:String>
<system:String x:Key="LastModified">Last Modified</system:String>


<system:String x:Key="RenameFileHotkey">Rename a file/directory</system:String>
<system:String x:Key="AreTryingToRenameFile">Are you trying to rename a file?</system:String>
<system:String x:Key="ExplorerNeedsEnabledForRenameFile">"The explorer plugin needs to be enabled for the hotkey to rename files to work."</system:String>
</ResourceDictionary>
4 changes: 4 additions & 0 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
Key="{Binding CycleHistoryDownHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
Command="{Binding ForwardHistoryCommand}"
Modifiers="{Binding CycleHistoryDownHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
<KeyBinding
Key="{Binding RenameFileHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
Command="{Binding RenameFileCommand}"
Modifiers="{Binding RenameFileHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
</Window.InputBindings>

<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">
Expand Down
22 changes: 21 additions & 1 deletion Flow.Launcher/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using JetBrains.Annotations;
using Squirrel;
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
using Windows.Foundation.Metadata;

namespace Flow.Launcher
{
Expand All @@ -45,11 +46,11 @@

// Must use getter to avoid accessing Application.Current.Resources.MergedDictionaries so earlier in theme constructor
private Theme _theme;
private Theme Theme => _theme ??= Ioc.Default.GetRequiredService<Theme>();

Check warning on line 49 in Flow.Launcher/PublicAPIInstance.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

Check warning on line 49 in Flow.Launcher/PublicAPIInstance.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

// Must use getter to avoid circular dependency
private Updater _updater;
private Updater Updater => _updater ??= Ioc.Default.GetRequiredService<Updater>();

Check warning on line 53 in Flow.Launcher/PublicAPIInstance.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

Check warning on line 53 in Flow.Launcher/PublicAPIInstance.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Ioc` is not a recognized word. (unrecognized-spelling)

private readonly object _saveSettingsLock = new();

Expand Down Expand Up @@ -158,7 +159,7 @@
ShellCommand.Execute(startInfo);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "<Pending>")]

Check warning on line 162 in Flow.Launcher/PublicAPIInstance.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`VSTHRD` is not a recognized word. (unrecognized-spelling)

Check warning on line 162 in Flow.Launcher/PublicAPIInstance.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`VSTHRD` is not a recognized word. (unrecognized-spelling)
public async void CopyToClipboard(string stringToCopy, bool directCopy = false, bool showDefaultNotification = true)
{
if (string.IsNullOrEmpty(stringToCopy))
Expand Down Expand Up @@ -222,7 +223,26 @@
}
}
}

public bool IsValidFileName(string name)
{
if (name.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || name.Trim() == "")
{
return false;
}
return true;
}
public bool IsValidDirectoryName(string name)
{
List<char> invalidChars = Path.GetInvalidPathChars().ToList();
invalidChars.Add('/');
invalidChars.Add('\\');
if (name.IndexOfAny(invalidChars.ToArray()) >= 0 || name.Trim() == "")
{
return false;
}
return true;
}

private static async Task<Exception> RetryActionOnSTAThreadAsync(Action action, int retryCount = 6, int retryDelay = 150)
{
for (var i = 0; i < retryCount; i++)
Expand Down
9 changes: 9 additions & 0 deletions Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@
<cc:HotkeyDisplay Margin="4 0 0 0" Keys="Ctrl+Minus" />
</StackPanel>
</cc:Card>
<cc:Card
Title="{DynamicResource RenameFileHotkey}"
Icon="&#xe70f;"
Type="Inside">
<flowlauncher:HotkeyControl
DefaultHotkey=""
Type="RenameFileHotkey"
ValidateKeyGesture="True"/>
</cc:Card>
</StackPanel>
</cc:ExCard>

Expand Down
60 changes: 60 additions & 0 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
Expand All @@ -22,6 +23,7 @@
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Storage;
using Microsoft.VisualStudio.Threading;
using Svg;

namespace Flow.Launcher.ViewModel
{
Expand Down Expand Up @@ -60,6 +62,8 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable

#endregion



#region Constructor

public MainViewModel()
Expand Down Expand Up @@ -140,6 +144,9 @@ public MainViewModel()
case nameof(Settings.OpenHistoryHotkey):
OnPropertyChanged(nameof(OpenHistoryHotkey));
break;
case nameof(Settings.RenameFileHotkey):
OnPropertyChanged(nameof(Settings.RenameFileHotkey));
break;
}
};

Expand Down Expand Up @@ -596,6 +603,7 @@ public void CopyAlternative()
#endregion

#region ViewModel Properties


public Settings Settings { get; }
public string ClockText { get; private set; }
Expand Down Expand Up @@ -913,9 +921,60 @@ private static string VerifyOrSetDefaultHotkey(string hotkey, string defaultHotk
public string OpenHistoryHotkey => VerifyOrSetDefaultHotkey(Settings.OpenHistoryHotkey, "Ctrl+H");
public string CycleHistoryUpHotkey => VerifyOrSetDefaultHotkey(Settings.CycleHistoryUpHotkey, "Alt+Up");
public string CycleHistoryDownHotkey => VerifyOrSetDefaultHotkey(Settings.CycleHistoryDownHotkey, "Alt+Down");
public string RenameFileHotkey => VerifyOrSetDefaultHotkey(Settings.RenameFileHotkey, "F2");


public bool StartWithEnglishMode => Settings.AlwaysStartEn;

#region renamingFiles
private int timesTriedToRenameFileWithExplorerDisabled = 0;

[RelayCommand]
private void RenameFile()
{

const string explorerPluginID = "572be03c74c642baae319fc283e561a8";
// check if explorer plugin is enabled
IEnumerable<PluginPair> explorerPluginMatches = App.API.GetAllPlugins().Where(
plugin => plugin.Metadata.ID == explorerPluginID);

if (!explorerPluginMatches.Any() || explorerPluginMatches == null)
{

timesTriedToRenameFileWithExplorerDisabled++;
return;
}
else if ((!explorerPluginMatches.Any() || explorerPluginMatches == null) && timesTriedToRenameFileWithExplorerDisabled > 3)
{
App.API.ShowMsg(App.API.GetTranslation("AreTryingToRenameFile"), App.API.GetTranslation("ExplorerNeedsEnabledForRenameFile"));
timesTriedToRenameFileWithExplorerDisabled = 0;
return;
}
else
{
// at runtime the type of the will be <see cref="../../Plugins/Flow.Launcher.Plugin.Explorer/Main.cs" />
dynamic explorerPlugin = explorerPluginMatches.First(); // assuming there's only one match
string path = SelectedResults?.SelectedItem?.Result.SubTitle ?? "";
string name = SelectedResults?.SelectedItem?.Result.Title ?? "";
if (path.Trim() == "" || name.Trim() == "") return;
if (File.Exists(Path.Join(path, name)))
{
explorerPlugin.Plugin.RenameDialog(new FileInfo(Path.Join(path, name)), App.API);
return;
}
if (Directory.Exists(path))
{
explorerPlugin.Plugin.RenameDialog(new DirectoryInfo(path), App.API); // this feels kinda hacky
return;
}




}
}
#endregion

#endregion

#region Preview
Expand Down Expand Up @@ -1011,6 +1070,7 @@ private void TogglePreview()
_ = ShowPreviewAsync();
}
}


private async Task OpenExternalPreviewAsync(string path, bool sendFailToast = true)
{
Expand Down
31 changes: 31 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.Explorer.Helper;
using Flow.Launcher.Plugin.Explorer.ViewModels;
using Flow.Launcher.Plugin.Explorer.Views;
using System.Windows.Controls;

namespace Flow.Launcher.Plugin.Explorer
{
Expand Down Expand Up @@ -188,6 +190,35 @@ public List<Result> LoadContextMenus(Result selectedResult)
IcoPath = icoPath,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uf12b")
});
contextMenus.Add(new Result
{
Title = Context.API.GetTranslation("plugin_explorer_rename_a_file"),
SubTitle = Context.API.GetTranslation("plugin_explorer_rename_subtitle"),
Action = _ =>
{
RenameFile window;
switch (record.Type)
{
case ResultType.Folder:
window = new RenameFile(Context.API, new DirectoryInfo(record.FullPath));
break;
case ResultType.File:
window = new RenameFile(Context.API, new FileInfo(record.FullPath));
break;
default:
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_cannot_rename"));
return false;
}
window.ShowDialog();

return false;

},
// placeholder until real image is found
IcoPath = Constants.ShowContextMenuImagePath,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue70f")

});


if (record.Type is ResultType.File or ResultType.Folder)
Expand Down
Loading
Loading