mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
https://github.com/Wox-launcher/Wox/issues/1050 https://github.com/Wox-launcher/Wox/issues/1141
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
namespace Wox.Infrastructure.UserSettings
|
namespace Wox.Infrastructure.UserSettings
|
||||||
@@ -49,6 +50,17 @@ namespace Wox.Infrastructure.UserSettings
|
|||||||
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
||||||
|
|
||||||
public HttpProxy Proxy { get; set; } = new HttpProxy();
|
public HttpProxy Proxy { get; set; } = new HttpProxy();
|
||||||
|
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LastQueryMode
|
||||||
|
{
|
||||||
|
Selected,
|
||||||
|
Empty,
|
||||||
|
Preserved
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
[Obsolete]
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
<system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String>
|
<system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String>
|
||||||
<system:String x:Key="rememberLastLocation">Remember last launch location</system:String>
|
<system:String x:Key="rememberLastLocation">Remember last launch location</system:String>
|
||||||
<system:String x:Key="language">Language</system:String>
|
<system:String x:Key="language">Language</system:String>
|
||||||
|
<system:String x:Key="lastQueryMode">Last Query Style</system:String>
|
||||||
|
<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="maxShowResults">Maximum results shown</system:String>
|
<system:String x:Key="maxShowResults">Maximum results shown</system:String>
|
||||||
<system:String x:Key="ignoreHotkeysOnFullscreen">Ignore hotkeys in fullscreen mode</system:String>
|
<system:String x:Key="ignoreHotkeysOnFullscreen">Ignore hotkeys in fullscreen mode</system:String>
|
||||||
<system:String x:Key="pythonDirectory">Python Directory</system:String>
|
<system:String x:Key="pythonDirectory">Python Directory</system:String>
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
<system:String x:Key="dontPromptUpdateMsg">不显示新版本提示</system:String>
|
<system:String x:Key="dontPromptUpdateMsg">不显示新版本提示</system:String>
|
||||||
<system:String x:Key="rememberLastLocation">记住上次启动位置</system:String>
|
<system:String x:Key="rememberLastLocation">记住上次启动位置</system:String>
|
||||||
<system:String x:Key="language">语言</system:String>
|
<system:String x:Key="language">语言</system:String>
|
||||||
|
<system:String x:Key="lastQueryMode">上次搜索关键字模式</system:String>
|
||||||
|
<system:String x:Key="LastQueryPreserved">保留上次搜索关键字</system:String>
|
||||||
|
<system:String x:Key="LastQuerySelected">全选上次搜索关键字</system:String>
|
||||||
|
<system:String x:Key="LastQueryEmpty">清空上次搜索关键字</system:String>
|
||||||
<system:String x:Key="maxShowResults">最大结果显示个数</system:String>
|
<system:String x:Key="maxShowResults">最大结果显示个数</system:String>
|
||||||
<system:String x:Key="ignoreHotkeysOnFullscreen">全屏模式下忽略热键</system:String>
|
<system:String x:Key="ignoreHotkeysOnFullscreen">全屏模式下忽略热键</system:String>
|
||||||
<system:String x:Key="pythonDirectory">Python 路径</system:String>
|
<system:String x:Key="pythonDirectory">Python 路径</system:String>
|
||||||
|
|||||||
@@ -68,10 +68,10 @@ namespace Wox
|
|||||||
QueryTextBox.Focus();
|
QueryTextBox.Focus();
|
||||||
SetWindowPosition();
|
SetWindowPosition();
|
||||||
_settings.ActivateTimes++;
|
_settings.ActivateTimes++;
|
||||||
if (_viewModel.QueryTextSelected)
|
if (!_viewModel.LastQuerySelected)
|
||||||
{
|
{
|
||||||
QueryTextBox.SelectAll();
|
QueryTextBox.SelectAll();
|
||||||
_viewModel.QueryTextSelected = false;
|
_viewModel.LastQuerySelected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,12 @@
|
|||||||
Checked="OnAutoStartupChecked" Unchecked="OnAutoStartupUncheck">
|
Checked="OnAutoStartupChecked" Unchecked="OnAutoStartupUncheck">
|
||||||
<TextBlock Text="{DynamicResource autoUpdates}" />
|
<TextBlock Text="{DynamicResource autoUpdates}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<StackPanel Margin="10" Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{DynamicResource lastQueryMode}" />
|
||||||
|
<ComboBox Margin="10 0 0 0" Width="120"
|
||||||
|
ItemsSource="{Binding LastQueryModes}" SelectedValue="{Binding Settings.LastQueryMode}"
|
||||||
|
DisplayMemberPath="Display" SelectedValuePath="Value" />
|
||||||
|
</StackPanel>
|
||||||
<StackPanel Margin="10" Orientation="Horizontal">
|
<StackPanel Margin="10" Orientation="Horizontal">
|
||||||
<TextBlock Text="{DynamicResource language}" />
|
<TextBlock Text="{DynamicResource language}" />
|
||||||
<ComboBox Margin="10 0 0 0" Width="120" SelectionChanged="OnLanguageChanged"
|
<ComboBox Margin="10 0 0 0" Width="120" SelectionChanged="OnLanguageChanged"
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ namespace Wox.ViewModel
|
|||||||
QueryTextCursorMovedToEnd = true;
|
QueryTextCursorMovedToEnd = true;
|
||||||
QueryText = queryText;
|
QueryText = queryText;
|
||||||
}
|
}
|
||||||
public bool QueryTextSelected { get; set; }
|
public bool LastQuerySelected { get; set; }
|
||||||
public bool QueryTextCursorMovedToEnd { get; set; }
|
public bool QueryTextCursorMovedToEnd { get; set; }
|
||||||
|
|
||||||
private ResultsViewModel _selectedResults;
|
private ResultsViewModel _selectedResults;
|
||||||
@@ -566,10 +566,29 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
private void OnHotkey(object sender, HotkeyEventArgs e)
|
private void OnHotkey(object sender, HotkeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (ShouldIgnoreHotkeys()) return;
|
if (!ShouldIgnoreHotkeys())
|
||||||
QueryTextSelected = true;
|
{
|
||||||
ToggleWox();
|
|
||||||
e.Handled = true;
|
if (_settings.LastQueryMode == LastQueryMode.Empty)
|
||||||
|
{
|
||||||
|
ChangeQueryText(string.Empty);
|
||||||
|
}
|
||||||
|
else if (_settings.LastQueryMode == LastQueryMode.Preserved)
|
||||||
|
{
|
||||||
|
LastQuerySelected = true;
|
||||||
|
}
|
||||||
|
else if (_settings.LastQueryMode == LastQueryMode.Selected)
|
||||||
|
{
|
||||||
|
LastQuerySelected = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");
|
||||||
|
}
|
||||||
|
|
||||||
|
ToggleWox();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleWox()
|
private void ToggleWox()
|
||||||
|
|||||||
@@ -50,8 +50,30 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
#region general
|
#region general
|
||||||
|
|
||||||
public List<Language> Languages => _translater.LoadAvailableLanguages();
|
public class LastQueryMode
|
||||||
|
{
|
||||||
|
public string Display { get; set; }
|
||||||
|
public Infrastructure.UserSettings.LastQueryMode Value { get; set; }
|
||||||
|
}
|
||||||
|
public List<LastQueryMode> LastQueryModes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<LastQueryMode> modes = new List<LastQueryMode>();
|
||||||
|
var enums = (Infrastructure.UserSettings.LastQueryMode[])Enum.GetValues(typeof(Infrastructure.UserSettings.LastQueryMode));
|
||||||
|
foreach (var e in enums)
|
||||||
|
{
|
||||||
|
var key = $"LastQuery{e}";
|
||||||
|
var display = _translater.GetTranslation(key);
|
||||||
|
var m = new LastQueryMode { Display = display, Value = e, };
|
||||||
|
modes.Add(m);
|
||||||
|
}
|
||||||
|
return modes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Internationalization _translater => InternationalizationManager.Instance;
|
private Internationalization _translater => InternationalizationManager.Instance;
|
||||||
|
public List<Language> Languages => _translater.LoadAvailableLanguages();
|
||||||
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
|
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user