Skip to content

Commit 0e5d5ec

Browse files
committed
- Add CustomQuery Hotkey Tips String
- Adjust CustomQueryHotkey Setting Popup Layout - Change HotkeyControl to using popup - Add some code to closing popup when click out area
1 parent 43a62d0 commit 0e5d5ec

File tree

7 files changed

+84
-7
lines changed

7 files changed

+84
-7
lines changed

Flow.Launcher/CustomQueryHotkeySetting.xaml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,57 @@
55
Icon="Images\app.png"
66
ResizeMode="NoResize"
77
WindowStartupLocation="CenterScreen"
8-
Title="{DynamicResource customeQueryHotkeyTitle}" Height="200" Width="674.766">
8+
MouseDown="window_MouseDown"
9+
Title="{DynamicResource customeQueryHotkeyTitle}" Height="345" Width="500" Background="#F3F3F3" BorderBrush="#cecece">
910
<Window.InputBindings>
1011
<KeyBinding Key="Escape" Command="Close"/>
1112
</Window.InputBindings>
1213
<Window.CommandBindings>
1314
<CommandBinding Command="Close" Executed="cmdEsc_OnPress"/>
1415
</Window.CommandBindings>
1516
<Grid>
17+
<Grid.RowDefinitions>
18+
<RowDefinition />
19+
<RowDefinition Height="80"/>
20+
</Grid.RowDefinitions>
21+
<Border BorderThickness="0 0 0 1" BorderBrush="#e5e5e5" Background="#ffffff" Padding="26 26 26 0">
22+
<Grid>
23+
<StackPanel>
24+
<StackPanel Grid.Row="0" Margin="0 0 0 12">
25+
<TextBlock Grid.Column="0" Text="{DynamicResource customeQueryHotkeyTitle}" FontSize="20" FontWeight="SemiBold" FontFamily="Segoe UI" TextAlignment="Left"
26+
Margin="0 0 0 0" />
27+
</StackPanel>
28+
<StackPanel>
29+
<TextBlock
30+
Text="{DynamicResource customeQueryHotkeyTips}" Foreground="#1b1b1b" FontSize="14" TextWrapping="WrapWithOverflow" TextAlignment="Left"/>
31+
</StackPanel>
32+
33+
<StackPanel Orientation="Horizontal" Margin="0 20 0 0">
34+
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
35+
HorizontalAlignment="Left" Text="{DynamicResource hotkey}" Width="60"/>
36+
<flowlauncher:HotkeyControl x:Name="ctlHotkey" Margin="10,0,10,0" Grid.Column="1" VerticalAlignment="Center" Height="32" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Width="200"/>
37+
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"
38+
HorizontalAlignment="Left" Text="{DynamicResource actionKeyword}" />
39+
</StackPanel>
40+
41+
<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
42+
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Width="60"
43+
HorizontalAlignment="Left" Text="{DynamicResource customQuery}" />
44+
<TextBox x:Name="tbAction" Margin="10" Width="250" VerticalAlignment="Center" HorizontalAlignment="Left" />
45+
<Button x:Name="btnTestActionKeyword" Padding="10 5 10 5" Height="30" Click="BtnTestActionKeyword_OnClick"
46+
Content="{DynamicResource preview}" />
47+
</StackPanel>
48+
</StackPanel>
49+
</Grid>
50+
</Border>
51+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1">
52+
<Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 5 0" Width="100" Height="32"
53+
Content="{DynamicResource cancel}" />
54+
<Button x:Name="btnAdd" Margin="5 0 10 0" Width="100" Height="32" Click="btnAdd_OnClick">
55+
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
56+
</Button>
57+
</StackPanel>
58+
<!--
1659
<Grid.RowDefinitions>
1760
<RowDefinition />
1861
<RowDefinition />
@@ -41,5 +84,6 @@
4184
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
4285
</Button>
4386
</StackPanel>
87+
-->
4488
</Grid>
4589
</Window>

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Linq;
88
using System.Windows;
99
using System.Windows.Input;
10+
using System.Windows.Controls;
11+
1012

1113
namespace Flow.Launcher
1214
{
@@ -99,5 +101,15 @@ private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
99101
{
100102
Close();
101103
}
104+
105+
private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */
106+
{
107+
TextBox textBox = Keyboard.FocusedElement as TextBox;
108+
if (textBox != null)
109+
{
110+
TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
111+
textBox.MoveFocus(tRequest);
112+
}
113+
}
102114
}
103115
}

Flow.Launcher/HotkeyControl.xaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@
99
d:DesignHeight="300" d:DesignWidth="300">
1010
<Grid>
1111
<Grid.ColumnDefinitions>
12-
<ColumnDefinition Width="125" />
13-
<ColumnDefinition Width="160" />
12+
<ColumnDefinition Width="200"/>
1413
</Grid.ColumnDefinitions>
15-
<TextBlock x:Name="tbMsg" Visibility="Hidden" Margin="8 0 0 0" VerticalAlignment="Center" Grid.Column="0" HorizontalAlignment="Right"/>
16-
<TextBox x:Name="tbHotkey" TabIndex="100" VerticalContentAlignment="Center" Grid.Column="1"
17-
PreviewKeyDown="TbHotkey_OnPreviewKeyDown" input:InputMethod.IsInputMethodEnabled="False" Margin="5 0 18 0"/>
14+
<Popup x:Name="popup" AllowDrop="True" PopupAnimation="Fade" PlacementTarget="{Binding ElementName=tbHotkey}" IsOpen="{Binding IsKeyboardFocused, ElementName=tbHotkey, Mode=OneWay}" StaysOpen="True" AllowsTransparency="True" Placement="Top" VerticalOffset="-5">
15+
<Border Background="#f6f6f6" BorderBrush="#cecece" BorderThickness="1" CornerRadius="6" Width="120" Height="30">
16+
<TextBlock x:Name="tbMsg" FontSize="13" FontWeight="SemiBold" Visibility="Visible" Margin="0 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Center">
17+
press key
18+
</TextBlock>
19+
</Border>
20+
</Popup>
21+
22+
<TextBox x:Name="tbHotkey" TabIndex="100" VerticalContentAlignment="Center"
23+
PreviewKeyDown="TbHotkey_OnPreviewKeyDown" input:InputMethod.IsInputMethodEnabled="False" Margin="0 0 18 0">
24+
</TextBox>
1825
</Grid>
1926
</UserControl>

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
8181
}
8282
}
8383

84+
85+
8486
public void SetHotkey(string keyStr, bool triggerValidate = true)
8587
{
8688
SetHotkey(new HotkeyModel(keyStr), triggerValidate);

Flow.Launcher/Languages/en.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@
149149
<system:String x:Key="actionkeyword_tips">Use * if you don't want to specify an action keyword</system:String>
150150

151151
<!--Custom Query Hotkey Dialog-->
152-
<system:String x:Key="customeQueryHotkeyTitle">Custom Plugin Hotkey</system:String>
152+
<system:String x:Key="customeQueryHotkeyTitle">Custom Query Hotkey</system:String>
153+
<system:String x:Key="customeQueryHotkeyTips">Press the custom hotkey to automatically insert the specified query.</system:String>
153154
<system:String x:Key="preview">Preview</system:String>
154155
<system:String x:Key="hotkeyIsNotUnavailable">Hotkey is unavailable, please select a new hotkey</system:String>
155156
<system:String x:Key="invalidPluginHotkey">Invalid plugin hotkey</system:String>

Flow.Launcher/SettingWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Height="700" Width="1000"
2020
MinWidth="900"
2121
MinHeight="600"
22+
MouseDown="window_MouseDown"
2223
Loaded="OnLoaded"
2324
Closed="OnClosed"
2425
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,15 @@ private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e)
281281
API.ShowMainWindow();
282282
}
283283
}
284+
private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */
285+
{
286+
TextBox textBox = Keyboard.FocusedElement as TextBox;
287+
if (textBox != null)
288+
{
289+
TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
290+
textBox.MoveFocus(tRequest);
291+
}
292+
}
293+
284294
}
285295
}

0 commit comments

Comments
 (0)