Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
efd34c9
Draft Query Shortcut
taooceros Dec 23, 2021
4340c08
Draft Query Shortcut
taooceros Dec 23, 2021
2fa0b52
Merge remote-tracking branch 'origin/Shortcut' into Shortcut
taooceros Dec 23, 2021
0a8405f
Resolve issue and add partial replacement trick
taooceros Mar 1, 2022
0d355bd
Draft Query Shortcut
taooceros Dec 23, 2021
2bb8812
Resolve issue and add partial replacement trick
taooceros Mar 1, 2022
9ccebd9
Merge remote-tracking branch 'origin/Shortcut' into Shortcut
taooceros Mar 1, 2022
b837d45
Merge remote-tracking branch 'origin/dev' into Shortcut
taooceros Mar 1, 2022
4d42e52
- Move the 'Shorcut' to Hotkey tab from General
onesounds Mar 1, 2022
c0a61c0
slightly code adjustment
taooceros Mar 26, 2022
d60ba01
Implement {clipboard} feature and the setting panel
taooceros Jun 4, 2022
8ebdff0
Merge branch 'dev' into Shortcut
taooceros Jun 4, 2022
0c75dfe
Update delete message
taooceros Jun 4, 2022
806720d
Remove ignore executable check
taooceros Jun 7, 2022
609e8e8
Remove testing code
taooceros Sep 1, 2022
3d20a60
Rename ShortcutModel to CustomShortcutModel
VictoriousRaptor Oct 5, 2022
099b1d6
Rename Settings.ShortCuts to CustomShortcuts
VictoriousRaptor Oct 5, 2022
99d1807
Move CustomShortcutModel definition to a new file
VictoriousRaptor Oct 5, 2022
a0c70a3
Inherit
VictoriousRaptor Oct 8, 2022
c2b1481
Warn if trying to add existing shortcut
VictoriousRaptor Oct 8, 2022
e789948
Text update
VictoriousRaptor Oct 8, 2022
f3c4120
Shortcut settings dialog preview & text & bugfix
VictoriousRaptor Oct 8, 2022
5879c84
Show builtin vars in shortcut list
VictoriousRaptor Oct 13, 2022
334d58d
Fix json load
VictoriousRaptor Oct 13, 2022
d394d86
Bugfix
VictoriousRaptor Oct 13, 2022
cde272a
Fix hard-coded text
VictoriousRaptor Oct 13, 2022
23ecd39
Separate custom & built-in shortcuts
VictoriousRaptor Oct 15, 2022
ce60f41
bugfix
VictoriousRaptor Oct 15, 2022
951ba4c
Add Listview for builtin shortcuts
VictoriousRaptor Oct 16, 2022
2489bfa
Merge pull request #1474 from VictoriousRaptor/Shortcut
taooceros Oct 17, 2022
3372a40
Fix mixed usage of \t and space
VictoriousRaptor Oct 17, 2022
40dda13
Merge branch 'Flow-Launcher:Shortcut' into Shortcut
VictoriousRaptor Oct 17, 2022
fe5859a
Merge pull request #1478 from VictoriousRaptor/Shortcut
jjw24 Oct 17, 2022
cbbb3b8
Merge branch 'dev' into Shortcut
VictoriousRaptor Nov 2, 2022
532f7ce
Fix merging
VictoriousRaptor Nov 2, 2022
3d36513
Add MinHeight for ListViews
VictoriousRaptor Nov 2, 2022
12721bc
Revert accidental change in Log.cs
VictoriousRaptor Nov 2, 2022
0eedb7b
renaming
VictoriousRaptor Nov 3, 2022
1296b0e
minor changes
VictoriousRaptor Nov 3, 2022
fc7ed31
Use reference when editing
VictoriousRaptor Nov 3, 2022
473626f
Fix duplicates when editing
VictoriousRaptor Nov 4, 2022
7fe81b4
Add text
VictoriousRaptor Nov 6, 2022
977ec33
Move logic to viewmodel
VictoriousRaptor Nov 6, 2022
5d3e6e0
Move dialog logic to vm
VictoriousRaptor Nov 6, 2022
019019e
Fix
VictoriousRaptor Nov 6, 2022
224b1df
Translate BuiltinShortcut desc
VictoriousRaptor Nov 7, 2022
9ccdf59
change text textbox when expanding builtin shortcuts
VictoriousRaptor Nov 7, 2022
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
2 changes: 1 addition & 1 deletion Flow.Launcher.Infrastructure/Logger/Log.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using NLog;
Expand Down
65 changes: 65 additions & 0 deletions Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Text.Json.Serialization;

namespace Flow.Launcher.Infrastructure.UserSettings
{
public abstract class ShortcutBaseModel
{
public string Key { get; set; }

[JsonIgnore]
public Func<string> Expand { get; set; } = () => { return ""; };

public override bool Equals(object obj)
{
return obj is ShortcutBaseModel other &&
Key == other.Key;
}

public override int GetHashCode()
{
return Key.GetHashCode();
}
}

public class CustomShortcutModel : ShortcutBaseModel
{
public string Value { get; set; }

[JsonConstructorAttribute]
public CustomShortcutModel(string key, string value)
{
Key = key;
Value = value;
Expand = () => { return Value; };
}

public void Deconstruct(out string key, out string value)
{
key = Key;
value = Value;
}

public static implicit operator (string Key, string Value)(CustomShortcutModel shortcut)
{
return (shortcut.Key, shortcut.Value);
}

public static implicit operator CustomShortcutModel((string Key, string Value) shortcut)
{
return new CustomShortcutModel(shortcut.Key, shortcut.Value);
}
}

public class BuiltinShortcutModel : ShortcutBaseModel
{
public string Description { get; set; }

public BuiltinShortcutModel(string key, string description, Func<string> expand)
{
Key = key;
Description = description;
Expand = expand ?? (() => { return ""; });
}
}
}
11 changes: 9 additions & 2 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.ObjectModel;
using System.Drawing;
using System.Text.Json.Serialization;
using System.Windows;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedModels;
using Flow.Launcher;
Expand Down Expand Up @@ -129,8 +130,7 @@ public CustomBrowserViewModel CustomBrowser
PrivateArg = "-private",
EnablePrivate = false,
Editable = false
}
,
},
new()
{
Name = "MS Edge",
Expand Down Expand Up @@ -186,6 +186,13 @@ public string QuerySearchPrecisionString

public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>();

public ObservableCollection<CustomShortcutModel> CustomShortcuts { get; set; } = new ObservableCollection<CustomShortcutModel>();

[JsonIgnore]
public ObservableCollection<BuiltinShortcutModel> BuiltinShortcuts { get; set; } = new ObservableCollection<BuiltinShortcutModel>() {
new BuiltinShortcutModel("{clipboard}", "shortcut_clipboard_description", Clipboard.GetText)
};

public bool DontPromptUpdateMsg { get; set; }
public bool EnableUpdateLog { get; set; }

Expand Down
20 changes: 20 additions & 0 deletions Flow.Launcher/Converters/TranslationConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Flow.Launcher.Core.Resource;

namespace Flow.Launcher.Converters
{
public class TranlationConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var key = value.ToString();
if (String.IsNullOrEmpty(key))
return key;
return InternationalizationManager.Instance.GetTranslation(key);
}

public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture) => throw new System.InvalidOperationException();
}
}
160 changes: 160 additions & 0 deletions Flow.Launcher/CustomShortcutSetting.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<Window
x:Class="Flow.Launcher.CustomShortcutSetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:flowlauncher="clr-namespace:Flow.Launcher"
Title="{DynamicResource customeQueryShortcutTitle}"
Width="530"
Background="{DynamicResource PopuBGColor}"
Foreground="{DynamicResource PopupTextColor}"
Icon="Images\app.png"
ResizeMode="NoResize"
SizeToContent="Height"
WindowStartupLocation="CenterScreen"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
<Window.InputBindings>
<KeyBinding Key="Escape" Command="Close" />
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="Close" Executed="cmdEsc_OnPress" />
</Window.CommandBindings>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="80" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="4"
Click="BtnCancel_OnClick"
Style="{StaticResource TitleBarCloseButtonStyle}">
<Path
Width="46"
Height="32"
Data="M 18,11 27,20 M 18,20 27,11"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1">
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
<Setter Property="Opacity" Value="0.5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Button>
</Grid>
</StackPanel>
<StackPanel Margin="26,0,26,0">
<StackPanel Grid.Row="0" Margin="0,0,0,12">
<TextBlock
Grid.Column="0"
Margin="0,0,0,0"
FontFamily="Segoe UI"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource customQueryShortcut}"
TextAlignment="Left" />
</StackPanel>
<StackPanel>
<TextBlock
FontSize="14"
Text="{DynamicResource customeQueryShortcutTips}"
TextAlignment="Left"
TextWrapping="WrapWithOverflow" />
</StackPanel>

<StackPanel Margin="0,20,0,0" Orientation="Horizontal">
<Grid Width="470">
<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 customShortcut}" />
<TextBox
Grid.Row="0"
Grid.Column="1"
Margin="10"
Text="{Binding Key}"
/>
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource customShortcutExpansion}" />

<DockPanel
Grid.Row="1"
Grid.Column="1"
LastChildFill="True">
<Button
x:Name="btnTestShortcut"
Margin="0,0,10,0"
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>
<Border
Grid.Row="1"
Margin="0,14,0,0"
Background="{DynamicResource PopupButtonAreaBGColor}"
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
BorderThickness="0,1,0,0">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button
x:Name="btnCancel"
MinWidth="140"
Margin="10,0,5,0"
Click="BtnCancel_OnClick"
Content="{DynamicResource cancel}" />
<Button
x:Name="btnAdd"
MinWidth="140"
Margin="5,0,10,0"
Click="BtnAdd_OnClick"
Style="{StaticResource AccentButtonStyle}">
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
</Button>
</StackPanel>
</Border>
</Grid>
</Window>
73 changes: 73 additions & 0 deletions Flow.Launcher/CustomShortcutSetting.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Flow.Launcher.Core.Resource;
using Flow.Launcher.ViewModel;
using System;
using System.Windows;
using System.Windows.Input;

namespace Flow.Launcher
{
public partial class CustomShortcutSetting : Window
{
private SettingWindowViewModel viewModel;
public string Key { get; set; } = String.Empty;
public string Value { get; set; } = String.Empty;
private string originalKey { get; init; } = null;
private string originalValue { get; init; } = null;
private bool update { get; init; } = false;

public CustomShortcutSetting(SettingWindowViewModel vm)
{
viewModel = vm;
InitializeComponent();
}

public CustomShortcutSetting(string key, string value, SettingWindowViewModel vm)
{
viewModel = vm;
Key = key;
Value = value;
originalKey = key;
originalValue = value;
update = true;
InitializeComponent();
}

private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}

private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
{
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
return;
}
// Check if key is modified or adding a new one
if (((update && originalKey != Key) || !update)
&& viewModel.ShortcutExists(Key))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
return;
}
DialogResult = !update || originalKey != Key || originalValue != Value;
Close();
}

private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
{
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();
}
}
}
12 changes: 12 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,18 @@
<system:String x:Key="showOpenResultHotkey">Show Hotkey</system:String>
<system:String x:Key="showOpenResultHotkeyToolTip">Show result selection hotkey with results.</system:String>
<system:String x:Key="customQueryHotkey">Custom Query Hotkey</system:String>
<system:String x:Key="customQueryShortcut">Custom Query Shortcut</system:String>
<system:String x:Key="customQuery">Query</system:String>
<system:String x:Key="customShortcut">Shortcut</system:String>
<system:String x:Key="customShortcutExpansion">Expanded</system:String>
<system:String x:Key="builtinShortcutDescription">Description</system:String>
<system:String x:Key="delete">Delete</system:String>
<system:String x:Key="edit">Edit</system:String>
<system:String x:Key="add">Add</system:String>
<system:String x:Key="pleaseSelectAnItem">Please select an item</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String>
<system:String x:Key="deleteCustomShortcutWarning">Are you sure you want to delete shortcut: {0} with expansion {1}?</system:String>
<system:String x:Key="shortcut_clipboard_description">Get text from clipboard.</system:String>
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU. Not recommended if your computer performance is limited.</system:String>
<system:String x:Key="windowWidthSize">Window Width Size</system:String>
Expand Down Expand Up @@ -241,6 +247,12 @@
<system:String x:Key="invalidPluginHotkey">Invalid plugin hotkey</system:String>
<system:String x:Key="update">Update</system:String>

<!-- Custom Query Shortcut Dialog -->
<system:String x:Key="customeQueryShortcutTitle">Custom Query Shortcut</system:String>
<system:String x:Key="customeQueryShortcutTips">Enter a shortcut that automatically expands to the specified query.</system:String>
<system:String x:Key="duplicateShortcut">Shortcut already exists, please enter a new Shortcut or edit the existing one.</system:String>
<system:String x:Key="emptyShortcut">Shortcut and/or its expansion is empty.</system:String>

<!-- Hotkey Control -->
<system:String x:Key="hotkeyUnavailable">Hotkey Unavailable</system:String>

Expand Down
Loading