Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preserve last action keyword options #3118

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public string Theme
public double ItemHeightSize { get; set; } = 58;
public double QueryBoxFontSize { get; set; } = 20;
public double ResultItemFontSize { get; set; } = 16;
public double ResultSubItemFontSize { get; set; } = 13;
public double ResultSubItemFontSize { get; set; } = 13;
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string QueryBoxFontStyle { get; set; }
public string QueryBoxFontWeight { get; set; }
Expand Down Expand Up @@ -187,7 +187,7 @@ public CustomBrowserViewModel CustomBrowser
public bool ShouldUsePinyin { get; set; } = false;

public bool AlwaysPreview { get; set; } = false;

public bool AlwaysStartEn { get; set; } = false;

private SearchPrecisionScore _querySearchPrecision = SearchPrecisionScore.Regular;
Expand Down Expand Up @@ -370,7 +370,9 @@ public enum LastQueryMode
{
Selected,
Empty,
Preserved
Preserved,
ActionKeywordPreserved,
ActionKeywordSelected
}

public enum ColorSchemes
Expand Down
2 changes: 2 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<system:String x:Key="LastQueryPreserved">Preserve Last Query</system:String>
<system:String x:Key="LastQuerySelected">Select last Query</system:String>
<system:String x:Key="LastQueryEmpty">Empty last Query</system:String>
<system:String x:Key="LastQueryActionKeywordPreserved">Preserve Last Action Keyword</system:String>
<system:String x:Key="LastQueryActionKeywordSelected">Select Last Action Keyword</system:String>
<system:String x:Key="KeepMaxResults">Fixed Window Height</system:String>
<system:String x:Key="KeepMaxResultsToolTip">The window height is not adjustable by dragging.</system:String>
<system:String x:Key="maxShowResults">Maximum results shown</system:String>
Expand Down
16 changes: 13 additions & 3 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public string VerifyOrSetDefaultHotkey(string hotkey, string defaultHotkey)
public string Image => Constant.QueryTextBoxIconImagePath;

public bool StartWithEnglishMode => Settings.AlwaysStartEn;

#endregion

#region Preview
Expand Down Expand Up @@ -833,7 +833,7 @@ when CanExternalPreviewSelectedResult(out var path):
}

private void HidePreview()
{
{
if (PluginManager.UseExternalPreview())
CloseExternalPreview();

Expand Down Expand Up @@ -912,7 +912,7 @@ when PluginManager.AllowAlwaysPreview() && CanExternalPreviewSelectedResult(out
break;
}
}

private void UpdatePreview()
{
switch (PluginManager.UseExternalPreview())
Expand Down Expand Up @@ -1401,6 +1401,16 @@ public async void Hide()
await Task.Delay(100);
LastQuerySelected = false;
break;
case LastQueryMode.ActionKeywordPreserved or LastQueryMode.ActionKeywordSelected:
var newQuery = _lastQuery.ActionKeyword;
if (!string.IsNullOrEmpty(newQuery))
newQuery += " ";
ChangeQueryText(newQuery);
if (Settings.UseAnimation)
await Task.Delay(100);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we wait here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok because using animation, think previously other options had some issues when animation is in process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually not sure. It's mentioned here

case LastQueryMode.Empty:
ChangeQueryText(string.Empty);
await Task.Delay(100); //Time for change to opacity
break;
case LastQueryMode.Preserved:
if (Settings.UseAnimation)
await Task.Delay(100);
LastQuerySelected = true;
break;
case LastQueryMode.Selected:
if (Settings.UseAnimation)
await Task.Delay(100);
LastQuerySelected = false;
break;
and I added it in my code because this was present in all three other case branches, so it probably solves some old issue I don't know about.

if (Settings.LastQueryMode == LastQueryMode.ActionKeywordSelected)
LastQuerySelected = false;
break;
Yusyuriv marked this conversation as resolved.
Show resolved Hide resolved
default:
throw new ArgumentException($"wrong LastQueryMode: <{Settings.LastQueryMode}>");
}
Expand Down
Loading