mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
[PTRun] Drag and drop files (#22409)
* [PTRun] Support drag&drop to other application for files in result list * [PTRun] use file/folder thumbnail as drag image * (fix spellcheck) * [PTRun] use _mouseDownResultViewModel.Image to generate the drag image * fix spelling + refactoring
This commit is contained in:
@@ -47,7 +47,7 @@ namespace Microsoft.Plugin.Folder
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(record.FullPath);
|
||||
Clipboard.SetText(record.Path);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -75,18 +75,18 @@ namespace Microsoft.Plugin.Folder
|
||||
{
|
||||
if (record.Type == ResultType.File)
|
||||
{
|
||||
Helper.OpenInConsole(_fileSystem.Path.GetDirectoryName(record.FullPath));
|
||||
Helper.OpenInConsole(_fileSystem.Path.GetDirectoryName(record.Path));
|
||||
}
|
||||
else
|
||||
{
|
||||
Helper.OpenInConsole(record.FullPath);
|
||||
Helper.OpenInConsole(record.Path);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception($"Failed to open {record.FullPath} in console, {e.Message}", e, GetType());
|
||||
Log.Exception($"Failed to open {record.Path} in console, {e.Message}", e, GetType());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -109,9 +109,9 @@ namespace Microsoft.Plugin.Folder
|
||||
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
|
||||
Action = _ =>
|
||||
{
|
||||
if (!Helper.OpenInShell("explorer.exe", $"/select,\"{record.FullPath}\""))
|
||||
if (!Helper.OpenInShell("explorer.exe", $"/select,\"{record.Path}\""))
|
||||
{
|
||||
var message = $"{Properties.Resources.Microsoft_plugin_folder_file_open_failed} {record.FullPath}";
|
||||
var message = $"{Properties.Resources.Microsoft_plugin_folder_file_open_failed} {record.Path}";
|
||||
_context.API.ShowMsg(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
namespace Microsoft.Plugin.Folder
|
||||
{
|
||||
public class SearchResult
|
||||
using Wox.Plugin.Interfaces;
|
||||
|
||||
public class SearchResult : IFileDropResult
|
||||
{
|
||||
public string FullPath { get; set; }
|
||||
public string Path { get; set; }
|
||||
|
||||
public ResultType Type { get; set; }
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
||||
IcoPath = Search,
|
||||
Score = 500,
|
||||
Action = c => _shellAction.ExecuteSanitized(Search, contextApi),
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = Search },
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, Path = Search },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Path),
|
||||
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Path)),
|
||||
QueryTextDisplay = Path,
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = Path },
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
||||
Action = c => _shellAction.Execute(Path, contextApi),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
||||
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_file_result_subtitle, FilePath)),
|
||||
IcoPath = FilePath,
|
||||
Action = c => ShellAction.Execute(FilePath, contextApi),
|
||||
ContextData = new SearchResult { Type = ResultType.File, FullPath = FilePath },
|
||||
ContextData = new SearchResult { Type = ResultType.File, Path = FilePath },
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle),
|
||||
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle)),
|
||||
QueryTextDisplay = Path,
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = Path },
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
||||
Action = c => ShellAction.Execute(Path, contextApi),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Microsoft.Plugin.Folder
|
||||
// Using CurrentCulture since this is user facing
|
||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle),
|
||||
QueryTextDisplay = Path,
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = Path },
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
||||
Action = c => _shellAction.Execute(Path, contextApi),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user