add option to suppress notification when calling copy

This commit is contained in:
Jeremy Wu 2023-06-11 21:59:08 +10:00
parent 2b862f702a
commit 6f7c3eba4d
3 changed files with 14 additions and 10 deletions

View file

@ -46,7 +46,10 @@ namespace Flow.Launcher.Plugin
/// </summary>
/// <param name="text">Text to save on clipboard</param>
/// <param name="directCopy">When true it will directly copy the file/folder from the path specified in text</param>
public void CopyToClipboard(string text, bool directCopy = false);
/// <param name="showDefaultNotification">Whether to show the default notification from this method after copy is done.
/// It will show file/folder/text is copied successfully.
/// Turn this off to show your own notification after copy is done.</param>>
public void CopyToClipboard(string text, bool directCopy = false, bool showDefaultNotification = true);
/// <summary>
/// Save everything, all of Flow Launcher and plugins' data and settings

View file

@ -67,7 +67,7 @@ namespace Flow.Launcher
}
else if (!string.IsNullOrEmpty(QueryTextBox.Text))
{
System.Windows.Clipboard.SetDataObject(QueryTextBox.SelectedText);
App.API.CopyToClipboard(QueryTextBox.SelectedText, showDefaultNotification: false);
}
}

View file

@ -117,7 +117,7 @@ namespace Flow.Launcher
ShellCommand.Execute(startInfo);
}
public void CopyToClipboard(string stringToCopy, bool directCopy = false)
public void CopyToClipboard(string stringToCopy, bool directCopy = false, bool showDefaultNotification = true)
{
if (string.IsNullOrEmpty(stringToCopy))
return;
@ -132,20 +132,21 @@ namespace Flow.Launcher
Clipboard.SetFileDropList(paths);
ShowMsg(
$"{GetTranslation("copy")} {(isFile ? GetTranslation("fileTitle") : GetTranslation("folderTitle"))}",
GetTranslation("completedSuccessfully"));
if (showDefaultNotification)
ShowMsg(
$"{GetTranslation("copy")} {(isFile ? GetTranslation("fileTitle") : GetTranslation("folderTitle"))}",
GetTranslation("completedSuccessfully"));
}
else
{
Clipboard.SetDataObject(stringToCopy);
ShowMsg(
$"{GetTranslation("copy")} {GetTranslation("textTitle")}",
GetTranslation("completedSuccessfully"));
if (showDefaultNotification)
ShowMsg(
$"{GetTranslation("copy")} {GetTranslation("textTitle")}",
GetTranslation("completedSuccessfully"));
}
}
public void StartLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Visible;