Skip to content

Commit e04944f

Browse files
committed
Merge Dev
2 parents 838d6c5 + b7d5f4f commit e04944f

File tree

20 files changed

+635
-112
lines changed

20 files changed

+635
-112
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
public bool UseAnimation { get; set; } = true;
4186
public bool UseSound { get; set; } = false;
4287

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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
<system:String x:Key="maxShowResults">Maximum results shown</system:String>
3535
<system:String x:Key="ignoreHotkeysOnFullscreen">Ignore hotkeys in fullscreen mode</system:String>
3636
<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>
3739
<system:String x:Key="pythonDirectory">Python Directory</system:String>
3840
<system:String x:Key="autoUpdates">Auto Update</system:String>
3941
<system:String x:Key="selectPythonDirectory">Select</system:String>
@@ -138,6 +140,16 @@
138140
<system:String x:Key="releaseNotes">Release Notes</system:String>
139141
<system:String x:Key="documentation">Usage Tips:</system:String>
140142

143+
<!-- FileManager Setting Dialog -->
144+
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>
145+
<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>
146+
<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>
147+
<system:String x:Key="fileManager_name">File Manager</system:String>
148+
<system:String x:Key="fileManager_profile_name">Profile Name</system:String>
149+
<system:String x:Key="fileManager_path">File Manager Path</system:String>
150+
<system:String x:Key="fileManager_directory_arg">Arg For Folder</system:String>
151+
<system:String x:Key="fileManager_file_arg">Arg For File</system:String>
152+
141153
<!-- Priority Setting Dialog -->
142154
<system:String x:Key="changePriorityWindow">Change Priority</system:String>
143155
<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>

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)