Shortcut settings dialog preview & text & bugfix

This commit is contained in:
Vic 2022-10-08 17:52:27 +08:00
parent e78994874a
commit f3c4120395
5 changed files with 42 additions and 23 deletions

View file

@ -110,14 +110,25 @@
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource customShortcutExpansion}" />
<TextBox
<DockPanel
Grid.Row="1"
Grid.Column="1"
Margin="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{Binding Value}"/>
</Grid>
LastChildFill="True">
<Button
x:Name="btnTestShortcut"
Padding="10,5,10,5"
Click="BtnTestShortcut_OnClick"
Content="{DynamicResource preview}"
DockPanel.Dock="Right" />
<TextBox
x:Name="tbExpand"
Margin="10"
HorizontalAlignment="Stretch"
Text="{Binding Value}"
VerticalAlignment="Center" />
</DockPanel>
</Grid>
</StackPanel>
</StackPanel>
</StackPanel>

View file

@ -1,29 +1,30 @@
using System;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure.UserSettings;
using System;
using System.Windows;
using System.Windows.Input;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher
{
public partial class CustomShortcutSetting : Window
{
private SettingWindow _settingWidow;
private bool update;
private Settings _settings;
private bool update = false;
public string Key { get; set; }
public string Value { get; set; }
public CustomShortcutModel ShortCut => (Key, Value);
public CustomShortcutSetting()
public CustomShortcutSetting(Settings settings)
{
_settings = settings;
InitializeComponent();
}
public CustomShortcutSetting((string, string) shortcut)
public CustomShortcutSetting((string, string) shortcut, Settings settings)
{
(Key, Value) = shortcut;
_settings = settings;
update = true;
InitializeComponent();
}
@ -35,17 +36,17 @@ namespace Flow.Launcher
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
DialogResult = true;
if (_settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)))
if (!update && _settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("dulplicateShortcut"));
DialogResult = false;
return;
}
else if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidShortcut"));
DialogResult = false;
return;
}
DialogResult = true;
Close();
}
@ -54,5 +55,13 @@ namespace Flow.Launcher
DialogResult = false;
Close();
}
private void BtnTestShortcut_OnClick(object sender, RoutedEventArgs e)
{
App.API.ChangeQuery(tbExpand.Text);
Application.Current.MainWindow.Show();
Application.Current.MainWindow.Opacity = 1;
Application.Current.MainWindow.Focus();
}
}
}

View file

@ -215,7 +215,6 @@
<!-- Custom Query Shortcut Dialog -->
<system:String x:Key="customeQueryShortcutTitle">Custom Query Shortcut</system:String>
<system:String x:Key="customeQueryShortcutTips">Enter a shortcut to automatically expand to the specified query.</system:String>
<system:String x:Key="preview">Preview</system:String>
<system:String x:Key="dulplicateShortcut">Shortcut is dulplicate, please enter a new Shortcut or edit the existing one.</system:String>
<system:String x:Key="invalidShortcut">Invalid Shortcut</system:String>

View file

@ -2175,7 +2175,7 @@
VerticalAlignment="Center"
FontSize="14"
Foreground="{DynamicResource Color05B}"
Text="Shortcut" />
Text="{DynamicResource customQueryShortcut}" />
<ListView
MinHeight="185"
Margin="0,6,0,0"

View file

@ -398,7 +398,7 @@ namespace Flow.Launcher
var item = viewModel.SelectedCustomShortcut;
if (item != null)
{
var shortcutSettingWindow = new CustomShortcutSetting(item);
var shortcutSettingWindow = new CustomShortcutSetting(item, settings);
if (shortcutSettingWindow.ShowDialog() == true)
{
settings.CustomShortcuts[viewModel.SelectCustomShortcutIndex.Value] = shortcutSettingWindow.ShortCut;
@ -412,7 +412,7 @@ namespace Flow.Launcher
private void OnAddCustomeShortCutClick(object sender, RoutedEventArgs e)
{
var shortcutSettingWindow = new CustomShortcutSetting();
var shortcutSettingWindow = new CustomShortcutSetting(settings);
if (shortcutSettingWindow.ShowDialog() == true)
{
settings.CustomShortcuts.Add(shortcutSettingWindow.ShortCut);