Skip to content

Commit f3c4120

Browse files
Shortcut settings dialog preview & text & bugfix
1 parent e789948 commit f3c4120

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

Flow.Launcher/CustomShortcutSetting.xaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,25 @@
110110
VerticalAlignment="Center"
111111
FontSize="14"
112112
Text="{DynamicResource customShortcutExpansion}" />
113-
<TextBox
113+
114+
<DockPanel
114115
Grid.Row="1"
115116
Grid.Column="1"
116-
Margin="10"
117-
HorizontalAlignment="Stretch"
118-
VerticalAlignment="Center"
119-
Text="{Binding Value}"/>
120-
</Grid>
117+
LastChildFill="True">
118+
<Button
119+
x:Name="btnTestShortcut"
120+
Padding="10,5,10,5"
121+
Click="BtnTestShortcut_OnClick"
122+
Content="{DynamicResource preview}"
123+
DockPanel.Dock="Right" />
124+
<TextBox
125+
x:Name="tbExpand"
126+
Margin="10"
127+
HorizontalAlignment="Stretch"
128+
Text="{Binding Value}"
129+
VerticalAlignment="Center" />
130+
</DockPanel>
131+
</Grid>
121132
</StackPanel>
122133
</StackPanel>
123134
</StackPanel>
Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
using System;
1+
using Flow.Launcher.Core.Resource;
2+
using Flow.Launcher.Infrastructure.UserSettings;
3+
using System;
24
using System.Windows;
35
using System.Windows.Input;
4-
using Flow.Launcher.Core.Resource;
5-
using Flow.Launcher.Infrastructure.UserSettings;
66

77
namespace Flow.Launcher
88
{
99
public partial class CustomShortcutSetting : Window
1010
{
11-
private SettingWindow _settingWidow;
12-
private bool update;
1311
private Settings _settings;
14-
12+
private bool update = false;
1513
public string Key { get; set; }
1614
public string Value { get; set; }
1715
public CustomShortcutModel ShortCut => (Key, Value);
1816

19-
public CustomShortcutSetting()
17+
public CustomShortcutSetting(Settings settings)
2018
{
19+
_settings = settings;
2120
InitializeComponent();
2221
}
2322

24-
public CustomShortcutSetting((string, string) shortcut)
23+
public CustomShortcutSetting((string, string) shortcut, Settings settings)
2524
{
2625
(Key, Value) = shortcut;
26+
_settings = settings;
27+
update = true;
2728
InitializeComponent();
2829
}
2930

@@ -35,17 +36,17 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
3536

3637
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
3738
{
38-
DialogResult = true;
39-
if (_settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)))
39+
if (!update && _settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)))
4040
{
4141
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("dulplicateShortcut"));
42-
DialogResult = false;
42+
return;
4343
}
44-
else if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
44+
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
4545
{
4646
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidShortcut"));
47-
DialogResult = false;
47+
return;
4848
}
49+
DialogResult = true;
4950
Close();
5051
}
5152

@@ -54,5 +55,13 @@ private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
5455
DialogResult = false;
5556
Close();
5657
}
58+
59+
private void BtnTestShortcut_OnClick(object sender, RoutedEventArgs e)
60+
{
61+
App.API.ChangeQuery(tbExpand.Text);
62+
Application.Current.MainWindow.Show();
63+
Application.Current.MainWindow.Opacity = 1;
64+
Application.Current.MainWindow.Focus();
65+
}
5766
}
5867
}

Flow.Launcher/Languages/en.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@
215215
<!-- Custom Query Shortcut Dialog -->
216216
<system:String x:Key="customeQueryShortcutTitle">Custom Query Shortcut</system:String>
217217
<system:String x:Key="customeQueryShortcutTips">Enter a shortcut to automatically expand to the specified query.</system:String>
218-
<system:String x:Key="preview">Preview</system:String>
219218
<system:String x:Key="dulplicateShortcut">Shortcut is dulplicate, please enter a new Shortcut or edit the existing one.</system:String>
220219
<system:String x:Key="invalidShortcut">Invalid Shortcut</system:String>
221220

Flow.Launcher/SettingWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@
21752175
VerticalAlignment="Center"
21762176
FontSize="14"
21772177
Foreground="{DynamicResource Color05B}"
2178-
Text="Shortcut" />
2178+
Text="{DynamicResource customQueryShortcut}" />
21792179
<ListView
21802180
MinHeight="185"
21812181
Margin="0,6,0,0"

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ private void OnEditCustomShortCutClick(object sender, RoutedEventArgs e)
398398
var item = viewModel.SelectedCustomShortcut;
399399
if (item != null)
400400
{
401-
var shortcutSettingWindow = new CustomShortcutSetting(item);
401+
var shortcutSettingWindow = new CustomShortcutSetting(item, settings);
402402
if (shortcutSettingWindow.ShowDialog() == true)
403403
{
404404
settings.CustomShortcuts[viewModel.SelectCustomShortcutIndex.Value] = shortcutSettingWindow.ShortCut;
@@ -412,7 +412,7 @@ private void OnEditCustomShortCutClick(object sender, RoutedEventArgs e)
412412

413413
private void OnAddCustomeShortCutClick(object sender, RoutedEventArgs e)
414414
{
415-
var shortcutSettingWindow = new CustomShortcutSetting();
415+
var shortcutSettingWindow = new CustomShortcutSetting(settings);
416416
if (shortcutSettingWindow.ShowDialog() == true)
417417
{
418418
settings.CustomShortcuts.Add(shortcutSettingWindow.ShortCut);

0 commit comments

Comments
 (0)