Skip to content

Commit 6f7c3eb

Browse files
committed
add option to suppress notification when calling copy
1 parent 2b862f7 commit 6f7c3eb

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public interface IPublicAPI
4646
/// </summary>
4747
/// <param name="text">Text to save on clipboard</param>
4848
/// <param name="directCopy">When true it will directly copy the file/folder from the path specified in text</param>
49-
public void CopyToClipboard(string text, bool directCopy = false);
49+
/// <param name="showDefaultNotification">Whether to show the default notification from this method after copy is done.
50+
/// It will show file/folder/text is copied successfully.
51+
/// Turn this off to show your own notification after copy is done.</param>>
52+
public void CopyToClipboard(string text, bool directCopy = false, bool showDefaultNotification = true);
5053

5154
/// <summary>
5255
/// Save everything, all of Flow Launcher and plugins' data and settings

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private void OnCopy(object sender, ExecutedRoutedEventArgs e)
6767
}
6868
else if (!string.IsNullOrEmpty(QueryTextBox.Text))
6969
{
70-
System.Windows.Clipboard.SetDataObject(QueryTextBox.SelectedText);
70+
App.API.CopyToClipboard(QueryTextBox.SelectedText, showDefaultNotification: false);
7171
}
7272
}
7373

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void ShellRun(string cmd, string filename = "cmd.exe")
117117
ShellCommand.Execute(startInfo);
118118
}
119119

120-
public void CopyToClipboard(string stringToCopy, bool directCopy = false)
120+
public void CopyToClipboard(string stringToCopy, bool directCopy = false, bool showDefaultNotification = true)
121121
{
122122
if (string.IsNullOrEmpty(stringToCopy))
123123
return;
@@ -132,20 +132,21 @@ public void CopyToClipboard(string stringToCopy, bool directCopy = false)
132132

133133
Clipboard.SetFileDropList(paths);
134134

135-
ShowMsg(
136-
$"{GetTranslation("copy")} {(isFile ? GetTranslation("fileTitle") : GetTranslation("folderTitle"))}",
137-
GetTranslation("completedSuccessfully"));
135+
if (showDefaultNotification)
136+
ShowMsg(
137+
$"{GetTranslation("copy")} {(isFile ? GetTranslation("fileTitle") : GetTranslation("folderTitle"))}",
138+
GetTranslation("completedSuccessfully"));
138139
}
139140
else
140141
{
141142
Clipboard.SetDataObject(stringToCopy);
142143

143-
ShowMsg(
144-
$"{GetTranslation("copy")} {GetTranslation("textTitle")}",
145-
GetTranslation("completedSuccessfully"));
144+
if (showDefaultNotification)
145+
ShowMsg(
146+
$"{GetTranslation("copy")} {GetTranslation("textTitle")}",
147+
GetTranslation("completedSuccessfully"));
146148
}
147149
}
148-
149150

150151
public void StartLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Visible;
151152

0 commit comments

Comments
 (0)