add copy notification

This commit is contained in:
Jeremy 2022-01-27 17:13:06 +11:00
parent c5be5b89cb
commit 8839f1bf6e
2 changed files with 16 additions and 3 deletions

View file

@ -18,6 +18,9 @@
<system:String x:Key="copy">Copy</system:String>
<system:String x:Key="cut">Cut</system:String>
<system:String x:Key="paste">Paste</system:String>
<system:String x:Key="fileTitle">File</system:String>
<system:String x:Key="folderTitle">Folder</system:String>
<system:String x:Key="textTitle">Text</system:String>
<system:String x:Key="GameMode">Game Mode</system:String>
<system:String x:Key="GameModeToolTip">Suspend the use of Hotkeys.</system:String>

View file

@ -890,18 +890,28 @@ namespace Flow.Launcher.ViewModel
if (result != null)
{
string copyText = string.IsNullOrEmpty(result.CopyText) ? result.SubTitle : result.CopyText;
if (File.Exists(copyText) || Directory.Exists(copyText))
var isFile = File.Exists(copyText);
var isFolder = Directory.Exists(copyText);
if (isFile || isFolder)
{
var paths = new StringCollection();
paths.Add(copyText);
Clipboard.SetFileDropList(paths);
App.API.ShowMsg(
App.API.GetTranslation("copy")
+" "
+ (isFile? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle")),
App.API.GetTranslation("completedSuccessfully"));
}
else
{
Clipboard.SetDataObject(copyText.ToString());
App.API.ShowMsg(
App.API.GetTranslation("copy")
+ " "
+ App.API.GetTranslation("textTitle"),
App.API.GetTranslation("completedSuccessfully"));
}
}