Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
914f400
WIP: new HotkeyControl
Yusyuriv Apr 12, 2024
a0b9d71
Sizes and Margins Adjust
onesounds Apr 12, 2024
a30d515
Change the button to togglebutton
onesounds Apr 12, 2024
7458e10
Add Show/Hide Style
onesounds Apr 12, 2024
efe081b
Added Show/Hide Trigger by style
onesounds Apr 12, 2024
78a6b27
HotkeyControl: add click handlers, add default hotkey
Yusyuriv Apr 12, 2024
172764d
Merge remote-tracking branch 'origin/new-hotkey-control' into new-hot…
Yusyuriv Apr 12, 2024
5e87e18
Fix the code merge mistake
Yusyuriv Apr 12, 2024
6e34218
WIP: handling hotkeys in HotkeyControl
Yusyuriv Apr 12, 2024
2f63079
Change the Button Label Text to Icon
onesounds Apr 12, 2024
453f767
Revise Hotkey Structure
taooceros Apr 12, 2024
58550c1
Merge remote-tracking branch 'Yusyuriv/new-hotkey-control' into fork/…
taooceros Apr 12, 2024
fe80141
Change the togglebutton to radio for multiple openning hotkey reg sit…
onesounds Apr 12, 2024
1a67287
feat(i18n): make empty hotkey translatable
taooceros Apr 13, 2024
690def1
fix(i18n): fix previous commit by using lazy to delay fetching transl…
taooceros Apr 13, 2024
9fd1774
Adjust String
onesounds Apr 13, 2024
e79fee7
Adjust Style
onesounds Apr 13, 2024
2339941
Fix Rec Button
onesounds Apr 13, 2024
22021c1
Add AutoComplete Hotkey Item
onesounds Apr 13, 2024
c9b5159
fix some issues and change structure and verification place
taooceros Apr 13, 2024
b7ccab6
handle lostfocus
taooceros Apr 13, 2024
c39da2f
fix: lost focus change current hotkey before stop recording store that
taooceros Apr 13, 2024
e53e1a0
Add Next/Prev Hotkey Item
onesounds Apr 15, 2024
d15cc1e
Change Default Autocomplete hotkey
onesounds Apr 15, 2024
fc64d9c
Fix Default AutoComplete hotkey
onesounds Apr 15, 2024
c0d41a3
- Remove Duplicated History Hotkey
onesounds Apr 15, 2024
82c6c41
Add Custom Control For Setting
onesounds Apr 15, 2024
dbbc42b
Adjust Card Style
onesounds Apr 16, 2024
56f27cb
Adjust Card
onesounds Apr 16, 2024
b1b22b2
Add Expander Control
onesounds Apr 16, 2024
dc724d4
Fix Border
onesounds Apr 17, 2024
8260f75
Adjust Item Sort
onesounds Apr 17, 2024
95ebac2
Add Hotkey Display
onesounds Apr 17, 2024
a62b67e
Added Hotkey Display Control
onesounds Apr 17, 2024
66125fc
Split Key to display
taooceros Apr 17, 2024
c6b62f9
Fix HotkeyDisplay xaml
onesounds Apr 17, 2024
5c3d3c7
Custom Hotkeys to Expander
onesounds Apr 17, 2024
c544a7e
Change all the logic back to control rather than viewmodel
taooceros Apr 17, 2024
5b20cce
Merge remote-tracking branch 'Yusyuriv/new-hotkey-control' into fork/…
taooceros Apr 17, 2024
fb3eb06
Fix Xaml
onesounds Apr 17, 2024
fa0f498
fix some issue
taooceros Apr 17, 2024
fd620f4
fix Hotkey control size CustomQueryHotkeyWindow
onesounds Apr 17, 2024
1d858d3
Fix duplicate modifier and clean up code
taooceros Apr 18, 2024
a64b4d3
Fix CustomQueryHotkeySetting window not working, remove some redundan…
Yusyuriv Apr 18, 2024
e4485c7
Add Setting Window Hotkey
onesounds Apr 18, 2024
dc6598b
Add Open Context Menu Hotkkey / Adjust Hotkey Strings
onesounds Apr 18, 2024
6761182
Organize Item Position
onesounds Apr 18, 2024
e3e3bf2
Add Static Hotkeys
onesounds Apr 18, 2024
9ce6425
Add Static Hotkey Items
onesounds Apr 18, 2024
56a8376
Make HotkeyControl hotkey binding two-way by default
Yusyuriv Apr 18, 2024
b2b8dc8
Fix NextItemHotkey
onesounds Apr 18, 2024
d7b6d82
Add static hotkeys
onesounds Apr 18, 2024
05bd2dd
- Add Additional(2nd) Customizable Hotkeys
onesounds Apr 18, 2024
146e499
Temporary move CustomHotkeyArea
onesounds Apr 18, 2024
bd778c2
Add 2nd AutoComplete Custom key
onesounds Apr 18, 2024
603d0f4
Add FitType for card control
onesounds Apr 18, 2024
15fe1cd
Fix Styles
onesounds Apr 18, 2024
aaf770a
Try implementing HotkeyControl, but with a modal window
Yusyuriv Apr 19, 2024
51eb8b9
Replace Window with ContentDialog when editing a hotkey in HotkeyCont…
Yusyuriv Apr 19, 2024
1ededb9
Fix Overlay Color
onesounds Apr 19, 2024
b5bd370
Adjust HotkeyPopup Style
onesounds Apr 19, 2024
8e6c06d
add message
taooceros Apr 19, 2024
e1defb5
Add warning Style
onesounds Apr 19, 2024
9e24c59
Change MiniControl To Popup Control
onesounds Apr 19, 2024
f2399da
Add Window Title for empty property
onesounds Apr 21, 2024
b93aa8e
- Change CustomQueryHotkey's HotkeyControl to popup
onesounds Apr 21, 2024
5cd8fa9
- Adjust Welcome Window's Hotkey Layout
onesounds Apr 21, 2024
2741485
Some cleanup in Card and ExCard controls
Yusyuriv Apr 21, 2024
9762afd
Some cleanup in HotkeyControl2Dialog
Yusyuriv Apr 21, 2024
20fa61d
Don't close HotkeyControl2Dialog after pressing Reset or Delete in it
Yusyuriv Apr 21, 2024
8c90980
Fix a bug with HotkeyControl2 not re-registering the global hotkey af…
Yusyuriv Apr 21, 2024
ebb4916
Fix HotkeyControl2 not working in WelcomePage2 for setting the global…
Yusyuriv Apr 21, 2024
fc32a88
Some cleanup in HotkeyDisplay control
Yusyuriv Apr 21, 2024
5a0f1f8
Fix Rider not recognizing DependencyProperty as such due to naming co…
Yusyuriv Apr 21, 2024
a3b13ef
Specify the default display type in Card and HotkeyDisplay controls
Yusyuriv Apr 23, 2024
03c7459
Remove old HotkeyControl, rename HotkeyControl2 to HotkeyControl
Yusyuriv Apr 23, 2024
806e124
- Fix Static Hotkey's Uppercases
onesounds Apr 23, 2024
2f471b6
update wording
jjw24 Apr 24, 2024
7a5f9dd
update wording
jjw24 Apr 24, 2024
db2765a
update wording
jjw24 Apr 24, 2024
30463b1
update wording
jjw24 Apr 24, 2024
3e2e5c3
update translation key
jjw24 Apr 24, 2024
1b8d310
update translation key
jjw24 Apr 24, 2024
c27f58f
update translation key
jjw24 Apr 24, 2024
55f2b6a
update translation key
jjw24 Apr 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 36 additions & 32 deletions Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Flow.Launcher.Infrastructure.Hotkey
{
public class HotkeyModel
public record struct HotkeyModel
{
public bool Alt { get; set; }
public bool Shift { get; set; }
Expand All @@ -17,8 +17,7 @@ public class HotkeyModel

private static readonly Dictionary<Key, string> specialSymbolDictionary = new Dictionary<Key, string>
{
{Key.Space, "Space"},
{Key.Oem3, "~"}
{ Key.Space, "Space" }, { Key.Oem3, "~" }
};

public ModifierKeys ModifierKeys
Expand All @@ -30,18 +29,22 @@ public ModifierKeys ModifierKeys
{
modifierKeys |= ModifierKeys.Alt;
}

if (Shift)
{
modifierKeys |= ModifierKeys.Shift;
}

if (Win)
{
modifierKeys |= ModifierKeys.Windows;
}

if (Ctrl)
{
modifierKeys |= ModifierKeys.Control;
}

return modifierKeys;
}
}
Expand All @@ -66,31 +69,37 @@ private void Parse(string hotkeyString)
{
return;
}

List<string> keys = hotkeyString.Replace(" ", "").Split('+').ToList();
if (keys.Contains("Alt"))
{
Alt = true;
keys.Remove("Alt");
}

if (keys.Contains("Shift"))
{
Shift = true;
keys.Remove("Shift");
}

if (keys.Contains("Win"))
{
Win = true;
keys.Remove("Win");
}

if (keys.Contains("Ctrl"))
{
Ctrl = true;
keys.Remove("Ctrl");
}

if (keys.Count == 1)
{
string charKey = keys[0];
KeyValuePair<Key, string>? specialSymbolPair = specialSymbolDictionary.FirstOrDefault(pair => pair.Value == charKey);
KeyValuePair<Key, string>? specialSymbolPair =
specialSymbolDictionary.FirstOrDefault(pair => pair.Value == charKey);
if (specialSymbolPair.Value.Value != null)
{
CharKey = specialSymbolPair.Value.Key;
Expand All @@ -103,41 +112,46 @@ private void Parse(string hotkeyString)
}
catch (ArgumentException)
{

}
}
}
}

public override string ToString()
{
List<string> keys = new List<string>();
if (Ctrl)
return string.Join(" + ", EnumerateDisplayKeys());
}

public IEnumerable<string> EnumerateDisplayKeys()
{
if (Ctrl && CharKey is not (Key.LeftCtrl or Key.RightCtrl))
{
keys.Add("Ctrl");
yield return "Ctrl";
}
if (Alt)

if (Alt && CharKey is not (Key.LeftAlt or Key.RightAlt))
{
keys.Add("Alt");
yield return "Alt";
}
if (Shift)

if (Shift && CharKey is not (Key.LeftShift or Key.RightShift))
{
keys.Add("Shift");
yield return "Shift";
}
if (Win)

if (Win && CharKey is not (Key.LWin or Key.RWin))
{
keys.Add("Win");
yield return "Win";
}

if (CharKey != Key.None)
{
keys.Add(specialSymbolDictionary.ContainsKey(CharKey)
? specialSymbolDictionary[CharKey]
: CharKey.ToString());
yield return specialSymbolDictionary.TryGetValue(CharKey, out var value)
? value
: CharKey.ToString();
}
return string.Join(" + ", keys);
}

/// <summary>
/// Validate hotkey
/// </summary>
Expand All @@ -164,11 +178,13 @@ public bool Validate(bool validateKeyGestrue = false)
{
KeyGesture keyGesture = new KeyGesture(CharKey, ModifierKeys);
}
catch (System.Exception e) when (e is NotSupportedException || e is InvalidEnumArgumentException)
catch (System.Exception e) when
(e is NotSupportedException || e is InvalidEnumArgumentException)
{
return false;
}
}

if (ModifierKeys == ModifierKeys.None)
{
return !IsPrintableCharacter(CharKey);
Expand Down Expand Up @@ -206,18 +222,6 @@ private static bool IsPrintableCharacter(Key key)
key == Key.Decimal;
}

public override bool Equals(object obj)
{
if (obj is HotkeyModel other)
{
return ModifierKeys == other.ModifierKeys && CharKey == other.CharKey;
}
else
{
return false;
}
}

public override int GetHashCode()
{
return HashCode.Combine(ModifierKeys, CharKey);
Expand Down
10 changes: 10 additions & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ public class Settings : BaseModel
public bool ShowOpenResultHotkey { get; set; } = true;
public double WindowSize { get; set; } = 580;
public string PreviewHotkey { get; set; } = $"F1";
public string AutoCompleteHotkey { get; set; } = $"{KeyConstant.Ctrl} + Tab";
public string AutoCompleteHotkey2 { get; set; } = $"";
public string SelectNextItemHotkey { get; set; } = $"Tab";
public string SelectNextItemHotkey2 { get; set; } = $"";
public string SelectPrevItemHotkey { get; set; } = $"Shift + Tab";
public string SelectPrevItemHotkey2 { get; set; } = $"";
public string SelectNextPageHotkey { get; set; } = $"";
public string SelectPrevPageHotkey { get; set; } = $"";
public string OpenContextMenuHotkey { get; set; } = $"Ctrl+O";
public string SettingWindowHotkey { get; set; } = $"Ctrl+I";

public string Language
{
Expand Down
153 changes: 68 additions & 85 deletions Flow.Launcher/CustomQueryHotkeySetting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
x:Class="Flow.Launcher.CustomQueryHotkeySetting"
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:flowlauncher="clr-namespace:Flow.Launcher"
Title="{DynamicResource customeQueryHotkeyTitle}"
Width="530"
Background="{DynamicResource PopuBGColor}"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Foreground="{DynamicResource PopupTextColor}"
Icon="Images\app.png"
MouseDown="window_MouseDown"
Expand Down Expand Up @@ -60,94 +62,75 @@
</Grid>
</StackPanel>
<StackPanel Margin="26,0,26,0">
<StackPanel Grid.Row="0" Margin="0,0,0,12">
<TextBlock
Margin="0,0,0,12"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource customeQueryHotkeyTitle}"
TextAlignment="Left" />
<TextBlock
FontSize="14"
Text="{DynamicResource customeQueryHotkeyTips}"
TextAlignment="Left"
TextWrapping="WrapWithOverflow" />
<Image
Width="478"
Margin="0,20,0,0"
Source="/Images/illustration_01.png" />

<Grid Width="478" Margin="0,20,0,0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="0,0,0,0"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource customeQueryHotkeyTitle}"
TextAlignment="Left" />
</StackPanel>
<StackPanel>
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource hotkey}" />
<flowlauncher:HotkeyControl
x:Name="HotkeyControl"
Grid.Row="0"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="10,0,10,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Left"
DefaultHotkey="" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource customeQueryHotkeyTips}"
TextAlignment="Left"
TextWrapping="WrapWithOverflow" />
<Image
Width="478"
Margin="0,20,0,0"
Source="/Images/illustration_01.png" />
</StackPanel>

<StackPanel Margin="0,20,0,0" Orientation="Horizontal">
<Grid Width="478">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource hotkey}" />
<StackPanel
Grid.Row="0"
Grid.Column="1"
Orientation="Horizontal">
<flowlauncher:HotkeyControl
x:Name="ctlHotkey"
Grid.Column="1"
Width="200"
Height="36"
Margin="10,0,10,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Left" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource actionKeyword}" />
</StackPanel>
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource customQuery}" />
<DockPanel
Grid.Row="1"
Grid.Column="1"
LastChildFill="True">
<Button
x:Name="btnTestActionKeyword"
Margin="0,0,10,0"
Padding="10,5,10,5"
Click="BtnTestActionKeyword_OnClick"
Content="{DynamicResource preview}"
DockPanel.Dock="Right" />
<TextBox
x:Name="tbAction"
Margin="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" />
</DockPanel>
</Grid>
</StackPanel>
Text="{DynamicResource customQuery}" />
<TextBox
x:Name="tbAction"
Grid.Row="1"
Grid.Column="1"
Margin="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" />
<Button
x:Name="btnTestActionKeyword"
Grid.Row="1"
Grid.Column="2"
Margin="0,0,10,0"
Padding="10,5,10,5"
Click="BtnTestActionKeyword_OnClick"
Content="{DynamicResource preview}" />
</Grid>
</StackPanel>
</StackPanel>
<Border
Expand All @@ -174,4 +157,4 @@
</StackPanel>
</Border>
</Grid>
</Window>
</Window>
Loading