mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add file path to clipboard as file if valid
This commit is contained in:
parent
0f78d5176e
commit
48dbfc240b
1 changed files with 21 additions and 7 deletions
|
|
@ -20,6 +20,7 @@ using Flow.Launcher.Infrastructure;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Flow.Launcher.Infrastructure.Hotkey;
|
using Flow.Launcher.Infrastructure.Hotkey;
|
||||||
using Flow.Launcher.Plugin.SharedCommands;
|
using Flow.Launcher.Plugin.SharedCommands;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Flow.Launcher
|
namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
|
|
@ -59,18 +60,31 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
var results = _viewModel.Results;
|
var results = _viewModel.Results;
|
||||||
var result = results.SelectedItem?.Result;
|
var result = results.SelectedItem?.Result;
|
||||||
if (result != null) // SelectedItem returns null if selection is empty.
|
if (result != null)
|
||||||
{
|
{
|
||||||
string _copyText = String.IsNullOrEmpty(result.CopyText) ? result.Title : result.CopyText;
|
string copyText = String.IsNullOrEmpty(result.CopyText) ? result.SubTitle : result.CopyText;
|
||||||
System.Windows.Clipboard.SetDataObject(_copyText.ToString());
|
if (File.Exists(copyText) || Directory.Exists(copyText))
|
||||||
|
{
|
||||||
|
|
||||||
|
System.Collections.Specialized.StringCollection paths = new System.Collections.Specialized.StringCollection();
|
||||||
|
paths.Add(copyText);
|
||||||
|
|
||||||
|
System.Windows.Clipboard.SetFileDropList(paths);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.Windows.Clipboard.SetDataObject(copyText.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//else if (!String.IsNullOrEmpty(QueryTextBox.Text))
|
else if (!String.IsNullOrEmpty(QueryTextBox.Text))
|
||||||
//{
|
{
|
||||||
// System.Windows.Clipboard.SetDataObject(QueryTextBox.SelectedText);
|
System.Windows.Clipboard.SetDataObject(QueryTextBox.SelectedText);
|
||||||
//}
|
}
|
||||||
e.Handled = false;
|
e.Handled = false;
|
||||||
}
|
}
|
||||||
private async void OnClosing(object sender, CancelEventArgs e)
|
private async void OnClosing(object sender, CancelEventArgs e)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue