mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Change search delay time to int & Improve code quality & Improve strings
This commit is contained in:
parent
44f136cca5
commit
dc7b812077
17 changed files with 52 additions and 457 deletions
|
|
@ -120,10 +120,9 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
public int Priority { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public SearchDelayTime? DefaultSearchDelayTime { get; set; }
|
||||
public int? DefaultSearchDelayTime { get; set; }
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public SearchDelayTime? SearchDelayTime { get; set; }
|
||||
public int? SearchDelayTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used only to save the state of the plugin in settings
|
||||
|
|
|
|||
|
|
@ -322,8 +322,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
|
||||
public bool SearchQueryResultsWithDelay { get; set; }
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public SearchDelayTime SearchDelayTime { get; set; } = SearchDelayTime.Normal;
|
||||
[JsonIgnore]
|
||||
public IEnumerable<int> SearchDelayTimeRange = new List<int> { 50, 100, 150, 200, 250, 300, 350, 400, 450, 500 };
|
||||
|
||||
public int SearchDelayTime { get; set; } = 150;
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public SearchWindowScreens SearchWindowScreen { get; set; } = SearchWindowScreens.Cursor;
|
||||
|
|
|
|||
|
|
@ -99,10 +99,9 @@ namespace Flow.Launcher.Plugin
|
|||
public bool HideActionKeywordPanel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Plugin search delay time. Null means use default search delay time.
|
||||
/// Plugin search delay time in ms. Null means use default search delay time.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public SearchDelayTime? SearchDelayTime { get; set; } = null;
|
||||
public int? SearchDelayTime { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Plugin icon path.
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
namespace Flow.Launcher.Plugin;
|
||||
|
||||
/// <summary>
|
||||
/// Enum for search delay time
|
||||
/// </summary>
|
||||
public enum SearchDelayTime
|
||||
{
|
||||
/// <summary>
|
||||
/// Very long search delay time. 250ms.
|
||||
/// </summary>
|
||||
VeryLong,
|
||||
|
||||
/// <summary>
|
||||
/// Long search delay time. 200ms.
|
||||
/// </summary>
|
||||
Long,
|
||||
|
||||
/// <summary>
|
||||
/// Normal search delay time. 150ms. Default value.
|
||||
/// </summary>
|
||||
Normal,
|
||||
|
||||
/// <summary>
|
||||
/// Short search delay time. 100ms.
|
||||
/// </summary>
|
||||
Short,
|
||||
|
||||
/// <summary>
|
||||
/// Very short search delay time. 50ms.
|
||||
/// </summary>
|
||||
VeryShort
|
||||
}
|
||||
|
|
@ -380,9 +380,7 @@
|
|||
|
||||
<!-- Search Delay Settings Dialog -->
|
||||
<system:String x:Key="searchDelayTimeTitle">Search Delay Time Setting</system:String>
|
||||
<system:String x:Key="searchDelayTime_tips">Select the search delay time you like to use for the plugin. Select "{0}" if you don't want to specify any, and the plugin will use default search delay time.</system:String>
|
||||
<system:String x:Key="currentSearchDelayTime">Current search delay time</system:String>
|
||||
<system:String x:Key="newSearchDelayTime">New search delay time</system:String>
|
||||
<system:String x:Key="searchDelayTimeTips">Input the search delay time in ms you like to use for the plugin. Input empty if you don't want to specify any, and the plugin will use default search delay time.</system:String>
|
||||
|
||||
<!-- Custom Query Hotkey Dialog -->
|
||||
<system:String x:Key="customeQueryHotkeyTitle">Custom Query Hotkey</system:String>
|
||||
|
|
|
|||
|
|
@ -85,7 +85,12 @@
|
|||
Foreground="{DynamicResource Color08B}"
|
||||
Text="{DynamicResource searchDelay}"
|
||||
ToolTip="{DynamicResource searchDelayToolTip}" />
|
||||
<cc:InstalledPluginSearchDelayCombobox Margin="0 0 8 0" />
|
||||
<ui:NumberBox
|
||||
Margin="0 0 8 0"
|
||||
Maximum="1000"
|
||||
Minimum="0"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
ToolTip="{DynamicResource searchDelayToolTip}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Put OnOffControl after PriorityControl & SearchDelayControl so that it can display correctly -->
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
<UserControl
|
||||
x:Class="Flow.Launcher.Resources.Controls.InstalledPluginSearchDelay"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModel="clr-namespace:Flow.Launcher.ViewModel"
|
||||
d:DataContext="{d:DesignInstance viewModel:PluginViewModel}"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300"
|
||||
mc:Ignorable="d">
|
||||
<Border
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
Margin="0"
|
||||
Padding="0"
|
||||
BorderThickness="0 1 0 0"
|
||||
CornerRadius="0"
|
||||
Style="{DynamicResource SettingGroupBox}">
|
||||
<DockPanel Margin="{StaticResource SettingPanelMargin}">
|
||||
<TextBlock
|
||||
Margin="{StaticResource SettingPanelItemRightMargin}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{StaticResource Glyph}">
|
||||

|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="{StaticResource SettingPanelItemRightMargin}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource SettingTitleLabel}"
|
||||
Text="{DynamicResource pluginSearchDelayTime}" />
|
||||
<!-- Here Margin="0 -4.5 0 -4.5" is to remove redundant top bottom margin from Margin="{StaticResource SettingPanelMargin}" -->
|
||||
<Button
|
||||
Width="100"
|
||||
Margin="0 -4.5 0 -4.5"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{Binding SetSearchDelayTimeCommand}"
|
||||
Content="{Binding SearchDelayTimeText}"
|
||||
Cursor="Hand"
|
||||
DockPanel.Dock="Right"
|
||||
FontWeight="Bold"
|
||||
ToolTip="{DynamicResource pluginSearchDelayTimeTooltip}" />
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System.Windows.Controls;
|
||||
|
||||
namespace Flow.Launcher.Resources.Controls;
|
||||
|
||||
public partial class InstalledPluginSearchDelay : UserControl
|
||||
{
|
||||
public InstalledPluginSearchDelay()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
<UserControl
|
||||
x:Class="Flow.Launcher.Resources.Controls.InstalledPluginSearchDelayCombobox"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModel="clr-namespace:Flow.Launcher.ViewModel"
|
||||
d:DataContext="{d:DesignInstance viewModel:PluginViewModel}"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300"
|
||||
mc:Ignorable="d">
|
||||
<Border
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
Margin="0"
|
||||
Padding="0"
|
||||
BorderThickness="0"
|
||||
CornerRadius="0">
|
||||
<DockPanel>
|
||||
<TextBlock Visibility="Collapsed"
|
||||
Margin="0 0 8 0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Left"
|
||||
Text="{DynamicResource pluginSearchDelayTime}"
|
||||
FontSize="13"
|
||||
Foreground="{DynamicResource Color08B}" />
|
||||
<ComboBox
|
||||
x:Name="cbDelay"
|
||||
Width="100"
|
||||
HorizontalAlignment="Right"
|
||||
DisplayMemberPath="Display"
|
||||
SelectedValuePath="Value"
|
||||
SelectionChanged="CbDelay_SelectionChanged"
|
||||
DockPanel.Dock="Right"
|
||||
ToolTip="{DynamicResource pluginSearchDelayTimeTooltip}" />
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
||||
namespace Flow.Launcher.Resources.Controls
|
||||
{
|
||||
public partial class InstalledPluginSearchDelayCombobox
|
||||
{
|
||||
public InstalledPluginSearchDelayCombobox()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadDelayOptions();
|
||||
Loaded += InstalledPluginSearchDelayCombobox_Loaded;
|
||||
}
|
||||
|
||||
private void InstalledPluginSearchDelayCombobox_Loaded(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModel.PluginViewModel viewModel)
|
||||
{
|
||||
// 초기 값 설정
|
||||
int currentDelayMs = GetCurrentDelayMs(viewModel);
|
||||
foreach (DelayOption option in cbDelay.Items)
|
||||
{
|
||||
if (option.Value == currentDelayMs)
|
||||
{
|
||||
cbDelay.SelectedItem = option;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int GetCurrentDelayMs(ViewModel.PluginViewModel viewModel)
|
||||
{
|
||||
// SearchDelayTime enum 값을 int로 변환
|
||||
SearchDelayTime? delayTime = viewModel.PluginPair.Metadata.SearchDelayTime;
|
||||
if (delayTime.HasValue)
|
||||
{
|
||||
return (int)delayTime.Value;
|
||||
}
|
||||
return 0; // 기본값
|
||||
}
|
||||
|
||||
private void LoadDelayOptions()
|
||||
{
|
||||
// 검색 지연 시간 옵션들 (SearchDelayTime enum 값에 맞춰야 함)
|
||||
var delayOptions = new List<DelayOption>
|
||||
{
|
||||
new DelayOption { Display = "0 ms", Value = 0 },
|
||||
new DelayOption { Display = "50 ms", Value = 50 },
|
||||
new DelayOption { Display = "100 ms", Value = 100 },
|
||||
new DelayOption { Display = "150 ms", Value = 150 },
|
||||
new DelayOption { Display = "200 ms", Value = 200 },
|
||||
new DelayOption { Display = "250 ms", Value = 250 },
|
||||
new DelayOption { Display = "300 ms", Value = 300 },
|
||||
new DelayOption { Display = "350 ms", Value = 350 },
|
||||
new DelayOption { Display = "400 ms", Value = 400 },
|
||||
new DelayOption { Display = "450 ms", Value = 450 },
|
||||
new DelayOption { Display = "500 ms", Value = 500 },
|
||||
};
|
||||
|
||||
cbDelay.ItemsSource = delayOptions;
|
||||
}
|
||||
|
||||
private void CbDelay_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModel.PluginViewModel viewModel && cbDelay.SelectedItem is DelayOption selectedOption)
|
||||
{
|
||||
// int 값을 SearchDelayTime enum으로 변환
|
||||
int delayValue = selectedOption.Value;
|
||||
viewModel.PluginPair.Metadata.SearchDelayTime = (SearchDelayTime)delayValue;
|
||||
|
||||
// 설정 저장
|
||||
//How to save?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DelayOption
|
||||
{
|
||||
public string Display { get; set; }
|
||||
public int Value { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
<Window
|
||||
x:Class="Flow.Launcher.SearchDelayTimeWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="{DynamicResource searchDelayTimeTitle}"
|
||||
Width="450"
|
||||
Background="{DynamicResource PopuBGColor}"
|
||||
Foreground="{DynamicResource PopupTextColor}"
|
||||
Icon="Images\app.png"
|
||||
Loaded="SearchDelayTimeWindow_OnLoaded"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Height"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
|
||||
</WindowChrome.WindowChrome>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="80" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<StackPanel Grid.Row="0">
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
Grid.Column="4"
|
||||
Click="BtnCancel_OnClick"
|
||||
Style="{StaticResource TitleBarCloseButtonStyle}">
|
||||
<Path
|
||||
Width="46"
|
||||
Height="32"
|
||||
Data="M 18,11 27,20 M 18,20 27,11"
|
||||
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
|
||||
StrokeThickness="1">
|
||||
<Path.Style>
|
||||
<Style TargetType="Path">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
|
||||
<Setter Property="Opacity" Value="0.5" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Path.Style>
|
||||
</Path>
|
||||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="26 12 26 0">
|
||||
<StackPanel Grid.Row="0" Margin="0 0 0 12">
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Margin="0 0 0 0"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
Text="{DynamicResource searchDelayTimeTitle}"
|
||||
TextAlignment="Left" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
x:Name="tbSearchDelayTimeTips"
|
||||
FontSize="14"
|
||||
TextAlignment="Left"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="0 18 0 0" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{DynamicResource currentSearchDelayTime}" />
|
||||
<TextBlock
|
||||
x:Name="tbOldSearchDelayTime"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="14 10 10 10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource Color05B}" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0 0 0 10" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{DynamicResource newSearchDelayTime}" />
|
||||
<ComboBox
|
||||
x:Name="cbDelay"
|
||||
MaxWidth="200"
|
||||
Margin="10 10 15 10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
DisplayMemberPath="Display"
|
||||
SelectedValuePath="Value" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Background="{DynamicResource PopupButtonAreaBGColor}"
|
||||
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
|
||||
BorderThickness="0 1 0 0">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
Width="145"
|
||||
Height="30"
|
||||
Margin="10 0 5 0"
|
||||
Click="BtnCancel_OnClick"
|
||||
Content="{DynamicResource cancel}" />
|
||||
<Button
|
||||
x:Name="btnDone"
|
||||
Width="145"
|
||||
Height="30"
|
||||
Margin="5 0 10 0"
|
||||
Click="btnDone_OnClick"
|
||||
Style="{StaticResource AccentButtonStyle}">
|
||||
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.SettingPages.ViewModels;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using static Flow.Launcher.SettingPages.ViewModels.SettingsPaneGeneralViewModel;
|
||||
|
||||
namespace Flow.Launcher;
|
||||
|
||||
public partial class SearchDelayTimeWindow : Window
|
||||
{
|
||||
private readonly PluginViewModel _pluginViewModel;
|
||||
|
||||
public SearchDelayTimeWindow(PluginViewModel pluginViewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
_pluginViewModel = pluginViewModel;
|
||||
}
|
||||
|
||||
private void SearchDelayTimeWindow_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tbSearchDelayTimeTips.Text = string.Format(App.API.GetTranslation("searchDelayTime_tips"),
|
||||
App.API.GetTranslation("default"));
|
||||
tbOldSearchDelayTime.Text = _pluginViewModel.SearchDelayTimeText;
|
||||
var searchDelayTimes = DropdownDataGeneric<SearchDelayTime>.GetValues<SearchDelayTimeData>("SearchDelayTime");
|
||||
SearchDelayTimeData selected = null;
|
||||
// Because default value is SearchDelayTime.VeryShort, we need to get selected value before adding default value
|
||||
if (_pluginViewModel.PluginSearchDelayTime != null)
|
||||
{
|
||||
selected = searchDelayTimes.FirstOrDefault(x => x.Value == _pluginViewModel.PluginSearchDelayTime);
|
||||
}
|
||||
// Add default value to the beginning of the list
|
||||
// When _pluginViewModel.PluginSearchDelayTime equals null, we will select this
|
||||
searchDelayTimes.Insert(0, new SearchDelayTimeData { Display = App.API.GetTranslation("default"), LocalizationKey = "default" });
|
||||
selected ??= searchDelayTimes.FirstOrDefault();
|
||||
cbDelay.ItemsSource = searchDelayTimes;
|
||||
cbDelay.SelectedItem = selected;
|
||||
cbDelay.Focus();
|
||||
}
|
||||
|
||||
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnDone_OnClick(object sender, RoutedEventArgs _)
|
||||
{
|
||||
// Update search delay time
|
||||
var selected = cbDelay.SelectedItem as SearchDelayTimeData;
|
||||
SearchDelayTime? changedValue = selected?.LocalizationKey != "default" ? selected.Value : null;
|
||||
_pluginViewModel.PluginSearchDelayTime = changedValue;
|
||||
|
||||
// Update search delay time text and close window
|
||||
_pluginViewModel.OnSearchDelayTimeChanged();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Flow.Launcher.Core;
|
||||
using Flow.Launcher.Core.Configuration;
|
||||
|
|
@ -31,7 +32,25 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
|
||||
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
|
||||
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
|
||||
public class SearchDelayTimeData : DropdownDataGeneric<SearchDelayTime> { }
|
||||
public class SearchDelayTimeData
|
||||
{
|
||||
public string Display { get; set; }
|
||||
public int Value { get; set; }
|
||||
|
||||
public static List<SearchDelayTimeData> GetValues()
|
||||
{
|
||||
var settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
var data = new List<SearchDelayTimeData>();
|
||||
|
||||
foreach (var value in settings.SearchDelayTimeRange)
|
||||
{
|
||||
var display = $"{value}ms";
|
||||
data.Add(new SearchDelayTimeData { Display = display, Value = value });
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public bool StartFlowLauncherOnSystemStartup
|
||||
{
|
||||
|
|
@ -144,19 +163,15 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
public List<LastQueryModeData> LastQueryModes { get; } =
|
||||
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");
|
||||
|
||||
public List<SearchDelayTimeData> SearchDelayTimes { get; } =
|
||||
DropdownDataGeneric<SearchDelayTime>.GetValues<SearchDelayTimeData>("SearchDelayTime");
|
||||
public List<SearchDelayTimeData> SearchDelayTimes { get; } = SearchDelayTimeData.GetValues();
|
||||
|
||||
public SearchDelayTimeData SearchDelayTime
|
||||
{
|
||||
get => SearchDelayTimes.FirstOrDefault(x => x.Value == Settings.SearchDelayTime) ??
|
||||
SearchDelayTimes.FirstOrDefault(x => x.Value == Plugin.SearchDelayTime.Normal) ??
|
||||
SearchDelayTimes.FirstOrDefault();
|
||||
get => SearchDelayTimes.FirstOrDefault(x => x.Value == Settings.SearchDelayTime);
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
if (value == null) return;
|
||||
|
||||
if (Settings.SearchDelayTime != value.Value)
|
||||
{
|
||||
Settings.SearchDelayTime = value.Value;
|
||||
|
|
@ -170,7 +185,6 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
|
||||
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
|
||||
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
|
||||
DropdownDataGeneric<SearchDelayTime>.UpdateLabels(SearchDelayTimes);
|
||||
}
|
||||
|
||||
public string Language
|
||||
|
|
|
|||
|
|
@ -196,18 +196,21 @@
|
|||
</cc:Card>
|
||||
</cc:CardGroup>
|
||||
|
||||
<cc:ExCard Margin="0 14 0 0" Title="{DynamicResource searchDelay}"
|
||||
Icon=""
|
||||
Sub="{DynamicResource searchDelayToolTip}">
|
||||
<cc:ExCard
|
||||
Title="{DynamicResource searchDelay}"
|
||||
Margin="0 14 0 0"
|
||||
Icon=""
|
||||
Sub="{DynamicResource searchDelayToolTip}">
|
||||
<cc:ExCard.SideContent>
|
||||
<ui:ToggleSwitch
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding Settings.SearchQueryResultsWithDelay}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}" />
|
||||
</cc:ExCard.SideContent>
|
||||
<cc:Card Type="InsideFit"
|
||||
<cc:Card
|
||||
Title="{DynamicResource searchDelayTime}"
|
||||
Sub="{DynamicResource searchDelayTimeToolTip}">
|
||||
Sub="{DynamicResource searchDelayTimeToolTip}"
|
||||
Type="InsideFit">
|
||||
<ComboBox
|
||||
MaxWidth="200"
|
||||
DisplayMemberPath="Display"
|
||||
|
|
@ -216,7 +219,7 @@
|
|||
SelectedValuePath="Value" />
|
||||
</cc:Card>
|
||||
</cc:ExCard>
|
||||
|
||||
|
||||
<cc:Card
|
||||
Title="{DynamicResource defaultFileManager}"
|
||||
Margin="0 14 0 0"
|
||||
|
|
|
|||
|
|
@ -1257,15 +1257,7 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
if (searchDelay)
|
||||
{
|
||||
var searchDelayTime = (plugin.Metadata.SearchDelayTime ?? Settings.SearchDelayTime) switch
|
||||
{
|
||||
SearchDelayTime.VeryLong => 250,
|
||||
SearchDelayTime.Long => 200,
|
||||
SearchDelayTime.Normal => 150,
|
||||
SearchDelayTime.Short => 100,
|
||||
SearchDelayTime.VeryShort => 50,
|
||||
_ => 150
|
||||
};
|
||||
var searchDelayTime = plugin.Metadata.SearchDelayTime ?? Settings.SearchDelayTime;
|
||||
|
||||
await Task.Delay(searchDelayTime, token);
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
public SearchDelayTime? PluginSearchDelayTime
|
||||
public int? PluginSearchDelayTime
|
||||
{
|
||||
get => PluginPair.Metadata.SearchDelayTime;
|
||||
set
|
||||
|
|
@ -192,12 +192,5 @@ namespace Flow.Launcher.ViewModel
|
|||
var changeKeywordsWindow = new ActionKeywords(this);
|
||||
changeKeywordsWindow.ShowDialog();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void SetSearchDelayTime()
|
||||
{
|
||||
var searchDelayTimeWindow = new SearchDelayTimeWindow(this);
|
||||
searchDelayTimeWindow.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,5 +32,5 @@
|
|||
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
||||
"ExecuteFileName": "Flow.Launcher.Plugin.WebSearch.dll",
|
||||
"IcoPath": "Images\\web_search.png",
|
||||
"SearchDelayTime": "VeryLong"
|
||||
"SearchDelayTime": 450
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue