Skip to content

Commit b7d5f4f

Browse files
authored
Merge pull request #782 from onesounds/FileManager
Default File manager
2 parents 362aa49 + b0cb8ad commit b7d5f4f

File tree

20 files changed

+691
-158
lines changed

20 files changed

+691
-158
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Flow.Launcher.Plugin;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Flow.Launcher.ViewModel
9+
{
10+
public class CustomExplorerViewModel : BaseModel
11+
{
12+
public string Name { get; set; }
13+
public string Path { get; set; }
14+
public string FileArgument { get; set; } = "\"%d\"";
15+
public string DirectoryArgument { get; set; } = "\"%d\"";
16+
public bool Editable { get; init; } = true;
17+
18+
public CustomExplorerViewModel Copy()
19+
{
20+
return new CustomExplorerViewModel
21+
{
22+
Name = Name,
23+
Path = Path,
24+
FileArgument = FileArgument,
25+
DirectoryArgument = DirectoryArgument,
26+
Editable = Editable
27+
};
28+
}
29+
}
30+
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Collections.ObjectModel;
34
using System.Drawing;
45
using System.Text.Json.Serialization;
56
using Flow.Launcher.Plugin;
67
using Flow.Launcher.Plugin.SharedModels;
78
using Flow.Launcher;
9+
using Flow.Launcher.ViewModel;
810

911
namespace Flow.Launcher.Infrastructure.UserSettings
1012
{
@@ -37,6 +39,49 @@ public string Language
3739
public string ResultFontStretch { get; set; }
3840
public bool UseGlyphIcons { get; set; } = true;
3941

42+
public int CustomExplorerIndex { get; set; } = 0;
43+
44+
[JsonIgnore]
45+
public CustomExplorerViewModel CustomExplorer
46+
{
47+
get => CustomExplorerList[CustomExplorerIndex < CustomExplorerList.Count ? CustomExplorerIndex : 0];
48+
set => CustomExplorerList[CustomExplorerIndex] = value;
49+
}
50+
51+
public List<CustomExplorerViewModel> CustomExplorerList { get; set; } = new()
52+
{
53+
new()
54+
{
55+
Name = "Explorer",
56+
Path = "explorer",
57+
DirectoryArgument = "\"%d\"",
58+
FileArgument = "/select, \"%f\"",
59+
Editable = false
60+
},
61+
new()
62+
{
63+
Name = "Total Commander",
64+
Path = @"C:\Program Files\totalcmd\TOTALCMD64.exe",
65+
DirectoryArgument = "/O /A /S /T \"%d\"",
66+
FileArgument = "/O /A /S /T \"%f\""
67+
},
68+
new()
69+
{
70+
Name = "Directory Opus",
71+
Path = @"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe",
72+
DirectoryArgument = "/cmd Go \"%d\" NEW",
73+
FileArgument = "/cmd Go \"%f\" NEW"
74+
75+
},
76+
new()
77+
{
78+
Name = "Files",
79+
Path = "Files",
80+
DirectoryArgument = "-select \"%d\"",
81+
FileArgument = "-select \"%f\""
82+
}
83+
};
84+
4085

4186
/// <summary>
4287
/// when false Alphabet static service will always return empty results

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,12 @@ public interface IPublicAPI
190190
/// <typeparam name="T">Type for Serialization</typeparam>
191191
/// <returns></returns>
192192
void SaveSettingJsonStorage<T>() where T : new();
193+
194+
/// <summary>
195+
/// Open directory in an explorer configured by user via Flow's Settings. The default is Windows Explorer
196+
/// </summary>
197+
/// <param name="DirectoryPath">Directory Path to open</param>
198+
/// <param name="FileName">Extra FileName Info</param>
199+
public void OpenDirectory(string DirectoryPath, string FileName = null);
193200
}
194201
}

Flow.Launcher/Languages/en.xaml

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:system="clr-namespace:System;assembly=mscorlib">
4-
<!--MainWindow-->
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:system="clr-namespace:System;assembly=mscorlib">
5+
<!-- MainWindow -->
56
<system:String x:Key="registerHotkeyFailed">Failed to register hotkey: {0}</system:String>
67
<system:String x:Key="couldnotStartCmd">Could not start {0}</system:String>
78
<system:String x:Key="invalidFlowLauncherPluginFileFormat">Invalid Flow Launcher plugin file format</system:String>
@@ -15,7 +16,7 @@
1516
<system:String x:Key="iconTrayExit">Exit</system:String>
1617
<system:String x:Key="closeWindow">Close</system:String>
1718

18-
<!--Setting General-->
19+
<!-- Setting General -->
1920
<system:String x:Key="flowlauncher_settings">Flow Launcher Settings</system:String>
2021
<system:String x:Key="general">General</system:String>
2122
<system:String x:Key="portableMode">Portable Mode</system:String>
@@ -33,6 +34,8 @@
3334
<system:String x:Key="maxShowResults">Maximum results shown</system:String>
3435
<system:String x:Key="ignoreHotkeysOnFullscreen">Ignore hotkeys in fullscreen mode</system:String>
3536
<system:String x:Key="ignoreHotkeysOnFullscreenToolTip">Disable Flow Launcher activation when a full screen application is active (Recommended for games).</system:String>
37+
<system:String x:Key="defaultFileManager">Default File Manager</system:String>
38+
<system:String x:Key="defaultFileManagerToolTip">Select the file manager to use when opening the folder.</system:String>
3639
<system:String x:Key="pythonDirectory">Python Directory</system:String>
3740
<system:String x:Key="autoUpdates">Auto Update</system:String>
3841
<system:String x:Key="selectPythonDirectory">Select</system:String>
@@ -44,7 +47,7 @@
4447
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese</system:String>
4548
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
4649

47-
<!--Setting Plugin-->
50+
<!-- Setting Plugin -->
4851
<system:String x:Key="plugin">Plugins</system:String>
4952
<system:String x:Key="browserMorePlugins">Find more plugins</system:String>
5053
<system:String x:Key="enable">On</system:String>
@@ -62,12 +65,12 @@
6265
<system:String x:Key="plugin_query_time">Query time:</system:String>
6366

6467

65-
<!--Setting Plugin Store-->
68+
<!-- Setting Plugin Store -->
6669
<system:String x:Key="pluginStore">Plugin Store</system:String>
6770
<system:String x:Key="refresh">Refresh</system:String>
6871
<system:String x:Key="install">Install</system:String>
6972

70-
<!--Setting Theme-->
73+
<!-- Setting Theme -->
7174
<system:String x:Key="theme">Theme</system:String>
7275
<system:String x:Key="browserMoreThemes">Theme Gallery</system:String>
7376
<system:String x:Key="howToCreateTheme">How to create a theme</system:String>
@@ -81,7 +84,7 @@
8184
<system:String x:Key="ThemeFolder">Theme Folder</system:String>
8285
<system:String x:Key="OpenThemeFolder">Open Theme Folder</system:String>
8386

84-
<!--Setting Hotkey-->
87+
<!-- Setting Hotkey -->
8588
<system:String x:Key="hotkey">Hotkey</system:String>
8689
<system:String x:Key="flowlauncherHotkey">Flow Launcher Hotkey</system:String>
8790
<system:String x:Key="flowlauncherHotkeyToolTip">Enter shortcut to show/hide Flow Launcher.</system:String>
@@ -102,7 +105,7 @@
102105
<system:String x:Key="useGlyphUI">Use Segoe Fluent Icons</system:String>
103106
<system:String x:Key="useGlyphUIEffect">Use Segoe Fluent Icons for query results where supported</system:String>
104107

105-
<!--Setting Proxy-->
108+
<!-- Setting Proxy -->
106109
<system:String x:Key="proxy">HTTP Proxy</system:String>
107110
<system:String x:Key="enableProxy">Enable HTTP Proxy</system:String>
108111
<system:String x:Key="server">HTTP Server</system:String>
@@ -118,7 +121,7 @@
118121
<system:String x:Key="proxyIsCorrect">Proxy configured correctly</system:String>
119122
<system:String x:Key="proxyConnectFailed">Proxy connection failed</system:String>
120123

121-
<!--Setting About-->
124+
<!-- Setting About -->
122125
<system:String x:Key="about">About</system:String>
123126
<system:String x:Key="website">Website</system:String>
124127
<system:String x:Key="version">Version</system:String>
@@ -127,18 +130,28 @@
127130
<system:String x:Key="newVersionTips">New version {0} is available, would you like to restart Flow Launcher to use the update?</system:String>
128131
<system:String x:Key="checkUpdatesFailed">Check updates failed, please check your connection and proxy settings to api.github.com.</system:String>
129132
<system:String x:Key="downloadUpdatesFailed">
130-
Download updates failed, please check your connection and proxy settings to github-cloud.s3.amazonaws.com,
133+
Download updates failed, please check your connection and proxy settings to github-cloud.s3.amazonaws.com,
131134
or go to https://github.com/Flow-Launcher/Flow.Launcher/releases to download updates manually.
132135
</system:String>
133136
<system:String x:Key="releaseNotes">Release Notes</system:String>
134137
<system:String x:Key="documentation">Usage Tips:</system:String>
135138

136-
<!--Priority Setting Dialog-->
139+
<!-- FileManager Setting Dialog -->
140+
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>
141+
<system:String x:Key="fileManager_tips">Please specify the file location of the file manager you using and add arguments if necessary. The default arguments is &quot;%d&quot;, and a path is entered at that location. For example, If a command is required such as &quot;totalcmd.exe /A c:\windows&quot;, argument is /A &quot;%d&quot;.</system:String>
142+
<system:String x:Key="fileManager_tips2">&quot;%f&quot; is an argument that represent the file path. It is used to emphasize the file/folder name when opening a specific file location in 3rd party file manager. This argument is only available in the &quot;Arg for File&quot; item. If the file manager does not have that function, you can use &quot;%d&quot;.</system:String>
143+
<system:String x:Key="fileManager_name">File Manager</system:String>
144+
<system:String x:Key="fileManager_profile_name">Profile Name</system:String>
145+
<system:String x:Key="fileManager_path">File Manager Path</system:String>
146+
<system:String x:Key="fileManager_directory_arg">Arg For Folder</system:String>
147+
<system:String x:Key="fileManager_file_arg">Arg For File</system:String>
148+
149+
<!-- Priority Setting Dialog -->
137150
<system:String x:Key="changePriorityWindow">Change Priority</system:String>
138151
<system:String x:Key="priority_tips">Greater the number, the higher the result will be ranked. Try setting it as 5. If you want the results to be lower than any other plugin's, provide a negative number</system:String>
139152
<system:String x:Key="invalidPriority">Please provide an valid integer for Priority!</system:String>
140153

141-
<!--Action Keyword Setting Dialog-->
154+
<!-- Action Keyword Setting Dialog -->
142155
<system:String x:Key="oldActionKeywords">Old Action Keyword</system:String>
143156
<system:String x:Key="newActionKeywords">New Action Keyword</system:String>
144157
<system:String x:Key="cancel">Cancel</system:String>
@@ -148,20 +161,20 @@
148161
<system:String x:Key="newActionKeywordsHasBeenAssigned">This new Action Keyword is already assigned to another plugin, please choose a different one</system:String>
149162
<system:String x:Key="success">Success</system:String>
150163
<system:String x:Key="completedSuccessfully">Completed successfully</system:String>
151-
<system:String x:Key="actionkeyword_tips">Enter the action keyword you need to start the plug-in. Use * if you don't want to specify an action keyword. In the case, The plug-in works without keywords. </system:String>
164+
<system:String x:Key="actionkeyword_tips">Enter the action keyword you need to start the plug-in. Use * if you don't want to specify an action keyword. In the case, The plug-in works without keywords.</system:String>
152165

153-
<!--Custom Query Hotkey Dialog-->
166+
<!-- Custom Query Hotkey Dialog -->
154167
<system:String x:Key="customeQueryHotkeyTitle">Custom Query Hotkey</system:String>
155168
<system:String x:Key="customeQueryHotkeyTips">Press the custom hotkey to automatically insert the specified query.</system:String>
156169
<system:String x:Key="preview">Preview</system:String>
157170
<system:String x:Key="hotkeyIsNotUnavailable">Hotkey is unavailable, please select a new hotkey</system:String>
158171
<system:String x:Key="invalidPluginHotkey">Invalid plugin hotkey</system:String>
159172
<system:String x:Key="update">Update</system:String>
160173

161-
<!--Hotkey Control-->
174+
<!-- Hotkey Control -->
162175
<system:String x:Key="hotkeyUnavailable">Hotkey Unavailable</system:String>
163176

164-
<!--Crash Reporter-->
177+
<!-- Crash Reporter -->
165178
<system:String x:Key="reportWindow_version">Version</system:String>
166179
<system:String x:Key="reportWindow_time">Time</system:String>
167180
<system:String x:Key="reportWindow_reproduce">Please tell us how application crashed so we can fix it</system:String>
@@ -177,16 +190,18 @@
177190
<system:String x:Key="reportWindow_report_failed">Failed to send report</system:String>
178191
<system:String x:Key="reportWindow_flowlauncher_got_an_error">Flow Launcher got an error</system:String>
179192

180-
<!--General Notice-->
193+
<!-- General Notice -->
181194
<system:String x:Key="pleaseWait">Please wait...</system:String>
182195

183-
<!--update-->
196+
<!-- update -->
184197
<system:String x:Key="update_flowlauncher_update_check">Checking for new update</system:String>
185198
<system:String x:Key="update_flowlauncher_already_on_latest">You already have the latest Flow Launcher version</system:String>
186199
<system:String x:Key="update_flowlauncher_update_found">Update found</system:String>
187200
<system:String x:Key="update_flowlauncher_updating">Updating...</system:String>
188-
<system:String x:Key="update_flowlauncher_fail_moving_portable_user_profile_data">Flow Launcher was not able to move your user profile data to the new update version.
189-
Please manually move your profile data folder from {0} to {1}</system:String>
201+
<system:String x:Key="update_flowlauncher_fail_moving_portable_user_profile_data">
202+
Flow Launcher was not able to move your user profile data to the new update version.
203+
Please manually move your profile data folder from {0} to {1}
204+
</system:String>
190205
<system:String x:Key="update_flowlauncher_new_update">New Update</system:String>
191206
<system:String x:Key="update_flowlauncher_update_new_version_available">New Flow Launcher release {0} is now available</system:String>
192207
<system:String x:Key="update_flowlauncher_update_error">An error occurred while trying to install software updates</system:String>

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
using Flow.Launcher.Infrastructure.Logger;
2323
using Flow.Launcher.Infrastructure.Storage;
2424
using System.Collections.Concurrent;
25+
using Flow.Launcher.Plugin.SharedCommands;
26+
using System.Diagnostics;
2527

2628
namespace Flow.Launcher
2729
{
@@ -158,7 +160,7 @@ public void SavePluginSettings()
158160
if (!_pluginJsonStorages.ContainsKey(type))
159161
_pluginJsonStorages[type] = new PluginJsonStorage<T>();
160162

161-
return ((PluginJsonStorage<T>) _pluginJsonStorages[type]).Load();
163+
return ((PluginJsonStorage<T>)_pluginJsonStorages[type]).Load();
162164
}
163165

164166
public void SaveSettingJsonStorage<T>() where T : new()
@@ -167,15 +169,30 @@ public void SavePluginSettings()
167169
if (!_pluginJsonStorages.ContainsKey(type))
168170
_pluginJsonStorages[type] = new PluginJsonStorage<T>();
169171

170-
((PluginJsonStorage<T>) _pluginJsonStorages[type]).Save();
172+
((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save();
171173
}
172174

173175
public void SaveJsonStorage<T>(T settings) where T : new()
174176
{
175177
var type = typeof(T);
176178
_pluginJsonStorages[type] = new PluginJsonStorage<T>(settings);
177179

178-
((PluginJsonStorage<T>) _pluginJsonStorages[type]).Save();
180+
((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save();
181+
}
182+
183+
public void OpenDirectory(string DirectoryPath, string FileName = null)
184+
{
185+
using Process explorer = new Process();
186+
var explorerInfo = _settingsVM.Settings.CustomExplorer;
187+
explorer.StartInfo = new ProcessStartInfo
188+
{
189+
FileName = explorerInfo.Path,
190+
Arguments = FileName is null ?
191+
explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) :
192+
explorerInfo.FileArgument.Replace("%d", DirectoryPath).Replace("%f",
193+
Path.IsPathRooted(FileName) ? FileName : Path.Combine(DirectoryPath, FileName))
194+
};
195+
explorer.Start();
179196
}
180197

181198
public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;
@@ -188,7 +205,7 @@ private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, Spe
188205
{
189206
if (GlobalKeyboardEvent != null)
190207
{
191-
return GlobalKeyboardEvent((int) keyevent, vkcode, state);
208+
return GlobalKeyboardEvent((int)keyevent, vkcode, state);
192209
}
193210

194211
return true;

0 commit comments

Comments
 (0)