mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
update copy calls to use API CopyToClipboard method
This commit is contained in:
parent
936d2b7e34
commit
1ff328be03
7 changed files with 11 additions and 29 deletions
|
|
@ -40,7 +40,8 @@ namespace Flow.Launcher.Plugin
|
|||
void ShellRun(string cmd, string filename = "cmd.exe");
|
||||
|
||||
/// <summary>
|
||||
/// Copy Text to clipboard
|
||||
/// If the passed in text is the path to a file or directory, the actual file/directory will
|
||||
/// be copied to clipboard. Otherwise the text itself will be copied to clipboard.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to save on clipboard</param>
|
||||
public void CopyToClipboard(string text);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace Flow.Launcher
|
|||
}
|
||||
else if (!string.IsNullOrEmpty(QueryTextBox.Text))
|
||||
{
|
||||
System.Windows.Clipboard.SetText(QueryTextBox.SelectedText);
|
||||
System.Windows.Clipboard.SetDataObject(QueryTextBox.SelectedText);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1112,11 +1112,10 @@ namespace Flow.Launcher.ViewModel
|
|||
public void ResultCopy(string stringToCopy)
|
||||
{
|
||||
if (string.IsNullOrEmpty(stringToCopy))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var isFile = File.Exists(stringToCopy);
|
||||
var isFolder = Directory.Exists(stringToCopy);
|
||||
var isFolder = isFile ? false : Directory.Exists(stringToCopy); // No need to eval directory exists if determined that file exists
|
||||
if (isFile || isFolder)
|
||||
{
|
||||
var paths = new StringCollection
|
||||
|
|
@ -1125,6 +1124,7 @@ namespace Flow.Launcher.ViewModel
|
|||
};
|
||||
|
||||
Clipboard.SetFileDropList(paths);
|
||||
|
||||
App.API.ShowMsg(
|
||||
$"{App.API.GetTranslation("copy")} {(isFile ? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle"))}",
|
||||
App.API.GetTranslation("completedSuccessfully"));
|
||||
|
|
@ -1132,6 +1132,7 @@ namespace Flow.Launcher.ViewModel
|
|||
else
|
||||
{
|
||||
Clipboard.SetDataObject(stringToCopy);
|
||||
|
||||
App.API.ShowMsg(
|
||||
$"{App.API.GetTranslation("copy")} {App.API.GetTranslation("textTitle")}",
|
||||
App.API.GetTranslation("completedSuccessfully"));
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ namespace Flow.Launcher.Plugin.BrowserBookmark
|
|||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetDataObject(((BookmarkAttributes)selectedResult.ContextData).Url);
|
||||
context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ namespace Flow.Launcher.Plugin.Caculator
|
|||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetDataObject(newResult);
|
||||
Context.API.CopyToClipboard(newResult);
|
||||
return true;
|
||||
}
|
||||
catch (ExternalException)
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(record.FullPath);
|
||||
Clipboard.SetDataObject(record.FullPath);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
|||
|
|
@ -22,26 +22,6 @@ namespace Flow.Launcher.Plugin.WindowsSettings.Helper
|
|||
internal static List<Result> GetContextMenu(in Result result, in string assemblyName)
|
||||
{
|
||||
return new List<Result>(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy the given text to the clipboard
|
||||
/// </summary>
|
||||
/// <param name="text">The text to copy to the clipboard</param>
|
||||
/// <returns><see langword="true"/>The text successful copy to the clipboard, otherwise <see langword="false"/></returns>
|
||||
private static bool TryToCopyToClipBoard(in string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.Clear();
|
||||
Clipboard.SetText(text);
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Exception("Can't copy to clipboard", exception, typeof(Main));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue