Remove back to query result and call this function in ChangeQuery & ReQuery

This commit is contained in:
Jack251970 2025-02-22 19:32:08 +08:00
parent 2843236214
commit aee585620a
11 changed files with 8 additions and 39 deletions

View file

@ -170,10 +170,5 @@ namespace Flow.Launcher.Core.Plugin.JsonRPCV2Models
{
_api.OpenAppUri(appUri);
}
public void BackToQueryResults()
{
_api.BackToQueryResults();
}
}
}

View file

@ -17,7 +17,8 @@ namespace Flow.Launcher.Plugin
public interface IPublicAPI
{
/// <summary>
/// Change Flow.Launcher query
/// Change Flow.Launcher query.
/// When current results is from context menu or history, we will back to query results before changing query.
/// </summary>
/// <param name="query">query text</param>
/// <param name="requery">
@ -299,17 +300,11 @@ namespace Flow.Launcher.Plugin
/// <summary>
/// Reloads the query.
/// This method should run when selected item is from query results.
/// When current results is from context menu or history, we will back to query results before changing query.
/// </summary>
/// <param name="reselect">Choose the first result after reload if true; keep the last selected result if false. Default is true.</param>
public void ReQuery(bool reselect = true);
/// <summary>
/// Back to the query results.
/// This method should run when selected item is from context menu or history.
/// </summary>
public void BackToQueryResults();
/// <summary>
/// Displays a standardised Flow message box.
/// </summary>

View file

@ -76,8 +76,6 @@ namespace Flow.Launcher
private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e)
{
// if user happens to open context menu, we need to return back to query results before changing query
App.API.BackToQueryResults();
App.API.ChangeQuery(tbAction.Text);
Application.Current.MainWindow.Show();
Application.Current.MainWindow.Opacity = 1;

View file

@ -64,8 +64,6 @@ namespace Flow.Launcher
private void BtnTestShortcut_OnClick(object sender, RoutedEventArgs e)
{
// if user happens to open context menu, we need to return back to query results before changing query
App.API.BackToQueryResults();
App.API.ChangeQuery(tbExpand.Text);
Application.Current.MainWindow.Show();
Application.Current.MainWindow.Opacity = 1;

View file

@ -319,8 +319,6 @@ namespace Flow.Launcher
public void ReQuery(bool reselect = true) => _mainVM.ReQuery(reselect);
public void BackToQueryResults() => _mainVM.BackToQueryResults();
public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK) =>
MessageBoxEx.Show(messageBoxText, caption, button, icon, defaultResult);

View file

@ -149,11 +149,7 @@ namespace Flow.Launcher
var rawQuery = query;
var effect = DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy);
if (effect == DragDropEffects.Move)
{
// if user happens to open context menu, we need to return back to query results before changing query
App.API.BackToQueryResults();
App.API.ChangeQuery(rawQuery, true);
}
}
private void ResultListBox_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{

View file

@ -279,10 +279,8 @@ namespace Flow.Launcher.ViewModel
public void ReQuery(bool reselect)
{
if (SelectedIsFromQueryResults())
{
QueryResults(isReQuery: true, reSelect: reselect);
}
BackToQueryResults();
QueryResults(isReQuery: true, reSelect: reselect);
}
[RelayCommand]
@ -491,7 +489,7 @@ namespace Flow.Launcher.ViewModel
}
}
public void BackToQueryResults()
private void BackToQueryResults()
{
if (!SelectedIsFromQueryResults())
{
@ -610,6 +608,8 @@ namespace Flow.Launcher.ViewModel
{
Application.Current.Dispatcher.Invoke(() =>
{
BackToQueryResults();
if (QueryText != queryText)
{
// re-query is done in QueryText's setter method
@ -1266,8 +1266,6 @@ namespace Flow.Launcher.ViewModel
{
_topMostRecord.Remove(result);
App.API.ShowMsg(InternationalizationManager.Instance.GetTranslation("success"));
// if user happens to open context menu, we need to return back to query results before changing query
App.API.BackToQueryResults();
App.API.ReQuery();
return false;
}
@ -1285,8 +1283,6 @@ namespace Flow.Launcher.ViewModel
{
_topMostRecord.AddOrUpdate(result);
App.API.ShowMsg(InternationalizationManager.Instance.GetTranslation("success"));
// if user happens to open context menu, we need to return back to query results before changing query
App.API.BackToQueryResults();
App.API.ReQuery();
return false;
}

View file

@ -64,8 +64,6 @@ namespace Flow.Launcher.ViewModel
private void ShowCommandQuery(string action)
{
var actionKeyword = PluginManagerData.Metadata.ActionKeywords.Any() ? PluginManagerData.Metadata.ActionKeywords[0] + " " : String.Empty;
// if user happens to open context menu, we need to return back to query results before changing query
App.API.BackToQueryResults();
App.API.ChangeQuery($"{actionKeyword}{action} {_plugin.Name}");
App.API.ShowMainWindow();
}

View file

@ -146,8 +146,6 @@ namespace Flow.Launcher.ViewModel
[RelayCommand]
private void OpenDeletePluginWindow()
{
// if user happens to open context menu, we need to return back to query results before changing query
PluginManager.API.BackToQueryResults();
PluginManager.API.ChangeQuery($"{PluginManagerActionKeyword} uninstall {PluginPair.Metadata.Name}".Trim(), true);
PluginManager.API.ShowMainWindow();
}
@ -161,5 +159,4 @@ namespace Flow.Launcher.ViewModel
changeKeywordsWindow.ShowDialog();
}
}
}

View file

@ -264,7 +264,6 @@ namespace Flow.Launcher.Plugin.Program
Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"),
Context.API.GetTranslation(
"flowlauncher_plugin_program_disable_dlgtitle_success_message"));
Context.API.BackToQueryResults();
Context.API.ReQuery();
return false;
},

View file

@ -382,7 +382,6 @@ namespace Flow.Launcher.Plugin.Shell
{
context.API.ShowMainWindow();
// if user happens to open context menu, we need to return back to query results before changing query
context.API.BackToQueryResults();
context.API.ChangeQuery($"{context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeparator}");
});