mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Implement the API call to custom explorer via ipublicapi, and migrate the exist call to explorer to the api call.
This commit is contained in:
parent
b3a04a9d25
commit
8a312d4874
5 changed files with 35 additions and 11 deletions
|
|
@ -190,5 +190,12 @@ namespace Flow.Launcher.Plugin
|
|||
/// <typeparam name="T">Type for Serialization</typeparam>
|
||||
/// <returns></returns>
|
||||
void SaveSettingJsonStorage<T>() where T : new();
|
||||
|
||||
/// <summary>
|
||||
/// Open Directory in explorer configured by user
|
||||
/// </summary>
|
||||
/// <param name="DirectoryPath">Directory Path to open</param>
|
||||
/// <param name="FileName">Extra FileName Info</param>
|
||||
public void OpenDirectory(string DirectoryPath, string FileName = null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ using System.Runtime.CompilerServices;
|
|||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.Storage;
|
||||
using System.Collections.Concurrent;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
|
|
@ -158,7 +160,7 @@ namespace Flow.Launcher
|
|||
if (!_pluginJsonStorages.ContainsKey(type))
|
||||
_pluginJsonStorages[type] = new PluginJsonStorage<T>();
|
||||
|
||||
return ((PluginJsonStorage<T>) _pluginJsonStorages[type]).Load();
|
||||
return ((PluginJsonStorage<T>)_pluginJsonStorages[type]).Load();
|
||||
}
|
||||
|
||||
public void SaveSettingJsonStorage<T>() where T : new()
|
||||
|
|
@ -167,7 +169,7 @@ namespace Flow.Launcher
|
|||
if (!_pluginJsonStorages.ContainsKey(type))
|
||||
_pluginJsonStorages[type] = new PluginJsonStorage<T>();
|
||||
|
||||
((PluginJsonStorage<T>) _pluginJsonStorages[type]).Save();
|
||||
((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save();
|
||||
}
|
||||
|
||||
public void SaveJsonStorage<T>(T settings) where T : new()
|
||||
|
|
@ -175,7 +177,22 @@ namespace Flow.Launcher
|
|||
var type = typeof(T);
|
||||
_pluginJsonStorages[type] = new PluginJsonStorage<T>(settings);
|
||||
|
||||
((PluginJsonStorage<T>) _pluginJsonStorages[type]).Save();
|
||||
((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save();
|
||||
}
|
||||
|
||||
public void OpenDirectory(string DirectoryPath, string FileName = null)
|
||||
{
|
||||
using Process explorer = new Process();
|
||||
var explorerInfo = _settingsVM.Settings.CustomExplorer;
|
||||
explorer.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = explorerInfo.Path,
|
||||
Arguments = FileName is null ?
|
||||
explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) :
|
||||
explorerInfo.FileArgument.Replace("%d", DirectoryPath).Replace("%f",
|
||||
Path.IsPathRooted(FileName) ? FileName : Path.Combine(DirectoryPath, FileName))
|
||||
};
|
||||
explorer.Start();
|
||||
}
|
||||
|
||||
public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;
|
||||
|
|
@ -188,7 +205,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
if (GlobalKeyboardEvent != null)
|
||||
{
|
||||
return GlobalKeyboardEvent((int) keyevent, vkcode, state);
|
||||
return GlobalKeyboardEvent((int)keyevent, vkcode, state);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
var directory = viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory;
|
||||
if (!string.IsNullOrEmpty(directory))
|
||||
FilesFolders.OpenPath(directory);
|
||||
PluginManager.API.OpenDirectory(directory);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -269,7 +269,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void OpenPluginFolder(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FilesFolders.OpenPath(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
|
||||
PluginManager.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
|
||||
}
|
||||
|
||||
private void OnPluginStoreRefreshClick(object sender, RoutedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
{
|
||||
try
|
||||
{
|
||||
FilesFolders.OpenPath(path);
|
||||
Context.API.OpenDirectory(path);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -101,7 +101,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
Score = 500,
|
||||
Action = c =>
|
||||
{
|
||||
FilesFolders.OpenPath(retrievedDirectoryPath);
|
||||
Context.API.OpenDirectory(retrievedDirectoryPath);
|
||||
return true;
|
||||
},
|
||||
TitleToolTip = retrievedDirectoryPath,
|
||||
|
|
@ -150,7 +150,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
}
|
||||
else if (c.SpecialKeyState.CtrlPressed)
|
||||
{
|
||||
FilesFolders.OpenContainingFolder(filePath);
|
||||
Context.API.OpenDirectory(Path.GetDirectoryName(filePath), filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Action = c =>
|
||||
{
|
||||
var logPath = Path.Combine(DataLocation.DataDirectory(), "Logs", Constant.Version);
|
||||
FilesFolders.OpenPath(logPath);
|
||||
context.API.OpenDirectory(logPath);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -326,7 +326,7 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
IcoPath = "Images\\app.png",
|
||||
Action = c =>
|
||||
{
|
||||
FilesFolders.OpenPath(DataLocation.DataDirectory());
|
||||
context.API.OpenDirectory(DataLocation.DataDirectory());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue