Skip to content

Commit 35617e9

Browse files
authored
Merge branch 'dev' into search_delay
2 parents e98b144 + 9d1e305 commit 35617e9

23 files changed

+671
-228
lines changed

Flow.Launcher/CustomQueryHotkeySetting.xaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
</Button>
5959
</Grid>
6060
</StackPanel>
61-
<StackPanel Margin="26,0,26,0">
61+
<StackPanel Margin="26 0 26 0">
6262
<TextBlock
63-
Margin="0,0,0,12"
63+
Margin="0 0 0 12"
6464
FontSize="20"
6565
FontWeight="SemiBold"
6666
Text="{DynamicResource customeQueryHotkeyTitle}"
@@ -72,10 +72,10 @@
7272
TextWrapping="WrapWithOverflow" />
7373
<Image
7474
Width="478"
75-
Margin="0,20,0,0"
75+
Margin="0 20 0 0"
7676
Source="/Images/illustration_01.png" />
7777

78-
<Grid Width="478" Margin="0,20,0,0">
78+
<Grid Width="478" Margin="0 20 0 0">
7979
<Grid.RowDefinitions>
8080
<RowDefinition />
8181
<RowDefinition />
@@ -99,11 +99,12 @@
9999
Grid.Row="0"
100100
Grid.Column="1"
101101
Grid.ColumnSpan="2"
102-
Margin="10,0,10,0"
102+
Margin="10 0 10 0"
103103
HorizontalAlignment="Left"
104104
VerticalAlignment="Center"
105105
HorizontalContentAlignment="Left"
106-
DefaultHotkey="" />
106+
DefaultHotkey=""
107+
Type="CustomQueryHotkey" />
107108
<TextBlock
108109
Grid.Row="1"
109110
Grid.Column="0"
@@ -123,30 +124,30 @@
123124
x:Name="btnTestActionKeyword"
124125
Grid.Row="1"
125126
Grid.Column="2"
126-
Margin="0,0,10,0"
127-
Padding="10,5,10,5"
127+
Margin="0 0 10 0"
128+
Padding="10 5 10 5"
128129
Click="BtnTestActionKeyword_OnClick"
129130
Content="{DynamicResource preview}" />
130131
</Grid>
131132
</StackPanel>
132133
</StackPanel>
133134
<Border
134135
Grid.Row="1"
135-
Margin="0,14,0,0"
136+
Margin="0 14 0 0"
136137
Background="{DynamicResource PopupButtonAreaBGColor}"
137138
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
138-
BorderThickness="0,1,0,0">
139+
BorderThickness="0 1 0 0">
139140
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
140141
<Button
141142
x:Name="btnCancel"
142143
MinWidth="140"
143-
Margin="10,0,5,0"
144+
Margin="10 0 5 0"
144145
Click="BtnCancel_OnClick"
145146
Content="{DynamicResource cancel}" />
146147
<Button
147148
x:Name="btnAdd"
148149
MinWidth="140"
149-
Margin="5,0,10,0"
150+
Margin="5 0 10 0"
150151
Click="btnAdd_OnClick"
151152
Style="{StaticResource AccentButtonStyle}">
152153
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public ICommand? ChangeHotkey
8484
nameof(Type),
8585
typeof(HotkeyType),
8686
typeof(HotkeyControl),
87-
new FrameworkPropertyMetadata(HotkeyType.Hotkey, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged)
87+
new FrameworkPropertyMetadata(HotkeyType.None, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged)
8888
);
8989

9090
public HotkeyType Type
@@ -95,6 +95,10 @@ public HotkeyType Type
9595

9696
public enum HotkeyType
9797
{
98+
None,
99+
// Custom query hotkeys
100+
CustomQueryHotkey,
101+
// Settings hotkeys
98102
Hotkey,
99103
PreviewHotkey,
100104
OpenContextMenuHotkey,
@@ -115,12 +119,16 @@ public enum HotkeyType
115119
// and it will not construct settings instances twice
116120
private static readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();
117121

122+
private string hotkey = string.Empty;
118123
public string Hotkey
119124
{
120125
get
121126
{
122127
return Type switch
123128
{
129+
// Custom query hotkeys
130+
HotkeyType.CustomQueryHotkey => hotkey,
131+
// Settings hotkeys
124132
HotkeyType.Hotkey => _settings.Hotkey,
125133
HotkeyType.PreviewHotkey => _settings.PreviewHotkey,
126134
HotkeyType.OpenContextMenuHotkey => _settings.OpenContextMenuHotkey,
@@ -135,13 +143,20 @@ public string Hotkey
135143
HotkeyType.SelectPrevItemHotkey2 => _settings.SelectPrevItemHotkey2,
136144
HotkeyType.SelectNextItemHotkey => _settings.SelectNextItemHotkey,
137145
HotkeyType.SelectNextItemHotkey2 => _settings.SelectNextItemHotkey2,
138-
_ => string.Empty
146+
_ => throw new System.NotImplementedException("Hotkey type not set")
139147
};
140148
}
141149
set
142150
{
143151
switch (Type)
144152
{
153+
// Custom query hotkeys
154+
case HotkeyType.CustomQueryHotkey:
155+
// We just need to store it in a local field
156+
// because we will save to settings in other place
157+
hotkey = value;
158+
break;
159+
// Settings hotkeys
145160
case HotkeyType.Hotkey:
146161
_settings.Hotkey = value;
147162
break;
@@ -185,7 +200,7 @@ public string Hotkey
185200
_settings.SelectNextItemHotkey2 = value;
186201
break;
187202
default:
188-
return;
203+
throw new System.NotImplementedException("Hotkey type not set");
189204
}
190205

191206
// After setting the hotkey, we need to refresh the interface

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@
331331
HorizontalAlignment="Center"
332332
VerticalAlignment="Bottom"
333333
StrokeThickness="2"
334-
Style="{DynamicResource PendingLineStyle}"
335334
Visibility="{Binding ProgressBarVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
336335
X1="-100"
337336
X2="0"
@@ -377,8 +376,8 @@
377376
HorizontalAlignment="Stretch"
378377
Style="{DynamicResource SeparatorStyle}" />
379378
</ContentControl>
380-
381379
</Grid>
380+
382381
<Border Style="{DynamicResource WindowRadius}">
383382
<Border.Clip>
384383
<MultiBinding Converter="{StaticResource BorderClipConverter}">

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@
2727
using System.Windows.Interop;
2828
using Windows.Win32;
2929
using System.Reactive.Linq;
30+
using System.Windows.Shapes;
3031

3132
namespace Flow.Launcher
3233
{
3334
public partial class MainWindow
3435
{
3536
#region Private Fields
3637

37-
private readonly Storyboard _progressBarStoryboard = new Storyboard();
38-
private bool isProgressBarStoryboardPaused;
3938
private Settings _settings;
4039
private NotifyIcon _notifyIcon;
4140
private ContextMenu contextMenu = new ContextMenu();
@@ -63,21 +62,14 @@ public MainWindow(Settings settings, MainViewModel mainVM)
6362

6463
DataObject.AddPastingHandler(QueryTextBox, OnPaste);
6564

66-
this.Loaded += (_, _) =>
65+
Loaded += (_, _) =>
6766
{
6867
var handle = new WindowInteropHelper(this).Handle;
6968
var win = HwndSource.FromHwnd(handle);
7069
win.AddHook(WndProc);
7170
};
7271
}
7372

74-
DispatcherTimer timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 500), IsEnabled = false };
75-
76-
public MainWindow()
77-
{
78-
InitializeComponent();
79-
}
80-
8173
private int _initialWidth;
8274
private int _initialHeight;
8375

@@ -242,27 +234,13 @@ private void OnLoaded(object sender, RoutedEventArgs _)
242234
_progressBarStoryboard.Stop(ProgressBar);
243235
isProgressBarStoryboardPaused = true;
244236
}
245-
});
246-
break;
247-
}
248-
case nameof(MainViewModel.ProgressBarVisibility):
249-
{
250-
Dispatcher.Invoke(() =>
251-
{
252-
if (_viewModel.ProgressBarVisibility == Visibility.Hidden && !isProgressBarStoryboardPaused)
253-
{
254-
_progressBarStoryboard.Stop(ProgressBar);
255-
isProgressBarStoryboardPaused = true;
256-
}
257-
else if (_viewModel.MainWindowVisibilityStatus &&
258-
isProgressBarStoryboardPaused)
259-
{
260-
_progressBarStoryboard.Begin(ProgressBar, true);
261-
isProgressBarStoryboardPaused = false;
262-
}
263-
});
264-
break;
265-
}
237+
238+
if (_settings.UseAnimation)
239+
WindowAnimator();
240+
}
241+
});
242+
break;
243+
}
266244
case nameof(MainViewModel.QueryTextCursorMovedToEnd):
267245
if (_viewModel.QueryTextCursorMovedToEnd)
268246
{
@@ -370,7 +348,6 @@ private void InitializeNotifyIcon()
370348
Icon = Constant.Version == "1.0.0" ? Properties.Resources.dev : Properties.Resources.app,
371349
Visible = !_settings.HideNotifyIcon
372350
};
373-
374351
var openIcon = new FontIcon { Glyph = "\ue71e" };
375352
var open = new MenuItem
376353
{
@@ -381,7 +358,8 @@ private void InitializeNotifyIcon()
381358
var gamemodeIcon = new FontIcon { Glyph = "\ue7fc" };
382359
var gamemode = new MenuItem
383360
{
384-
Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon
361+
Header = InternationalizationManager.Instance.GetTranslation("GameMode"),
362+
Icon = gamemodeIcon
385363
};
386364
var positionresetIcon = new FontIcon { Glyph = "\ue73f" };
387365
var positionreset = new MenuItem
@@ -398,7 +376,8 @@ private void InitializeNotifyIcon()
398376
var exitIcon = new FontIcon { Glyph = "\ue7e8" };
399377
var exit = new MenuItem
400378
{
401-
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon
379+
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"),
380+
Icon = exitIcon
402381
};
403382

404383
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
@@ -465,17 +444,49 @@ private async void PositionReset()
465444

466445
private void InitProgressbarAnimation()
467446
{
447+
var progressBarStoryBoard = new Storyboard();
448+
468449
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100,
469450
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
470451
var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 0,
471452
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
472453
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
473454
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
474-
_progressBarStoryboard.Children.Add(da);
475-
_progressBarStoryboard.Children.Add(da1);
476-
_progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever;
455+
progressBarStoryBoard.Children.Add(da);
456+
progressBarStoryBoard.Children.Add(da1);
457+
progressBarStoryBoard.RepeatBehavior = RepeatBehavior.Forever;
458+
459+
da.Freeze();
460+
da1.Freeze();
461+
462+
const string progressBarAnimationName = "ProgressBarAnimation";
463+
var beginStoryboard = new BeginStoryboard
464+
{
465+
Name = progressBarAnimationName, Storyboard = progressBarStoryBoard
466+
};
467+
468+
var stopStoryboard = new StopStoryboard()
469+
{
470+
BeginStoryboardName = progressBarAnimationName
471+
};
472+
473+
var trigger = new Trigger
474+
{
475+
Property = VisibilityProperty, Value = Visibility.Visible
476+
};
477+
trigger.EnterActions.Add(beginStoryboard);
478+
trigger.ExitActions.Add(stopStoryboard);
479+
480+
var progressStyle = new Style(typeof(Line))
481+
{
482+
BasedOn = FindResource("PendingLineStyle") as Style
483+
};
484+
progressStyle.RegisterName(progressBarAnimationName, beginStoryboard);
485+
progressStyle.Triggers.Add(trigger);
486+
487+
ProgressBar.Style = progressStyle;
488+
477489
_viewModel.ProgressBarVisibility = Visibility.Hidden;
478-
isProgressBarStoryboardPaused = true;
479490
}
480491

481492
public void WindowAnimator()

Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using System;
2-
using System.Windows.Navigation;
1+
using System.Windows.Navigation;
2+
using Flow.Launcher.Core;
33
using Flow.Launcher.SettingPages.ViewModels;
4+
using Flow.Launcher.Infrastructure.UserSettings;
5+
using CommunityToolkit.Mvvm.DependencyInjection;
46

57
namespace Flow.Launcher.SettingPages.Views;
68

@@ -12,8 +14,8 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
1214
{
1315
if (!IsInitialized)
1416
{
15-
if (e.ExtraData is not SettingWindow.PaneData { Settings: { } settings, Updater: { } updater })
16-
throw new ArgumentException("Settings are required for SettingsPaneAbout.");
17+
var settings = Ioc.Default.GetRequiredService<Settings>();
18+
var updater = Ioc.Default.GetRequiredService<Updater>();
1719
_viewModel = new SettingsPaneAboutViewModel(settings, updater);
1820
DataContext = _viewModel;
1921
InitializeComponent();

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using System;
2-
using System.Windows.Navigation;
1+
using System.Windows.Navigation;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
3+
using Flow.Launcher.Core;
4+
using Flow.Launcher.Core.Configuration;
35
using Flow.Launcher.Infrastructure.UserSettings;
46
using Flow.Launcher.SettingPages.ViewModels;
57

@@ -13,8 +15,9 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
1315
{
1416
if (!IsInitialized)
1517
{
16-
if (e.ExtraData is not SettingWindow.PaneData { Settings: { } settings, Updater: {} updater, Portable: {} portable })
17-
throw new ArgumentException("Settings, Updater and Portable are required for SettingsPaneGeneral.");
18+
var settings = Ioc.Default.GetRequiredService<Settings>();
19+
var updater = Ioc.Default.GetRequiredService<Updater>();
20+
var portable = Ioc.Default.GetRequiredService<Portable>();
1821
_viewModel = new SettingsPaneGeneralViewModel(settings, updater, portable);
1922
DataContext = _viewModel;
2023
InitializeComponent();

Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using System;
2-
using System.Windows.Navigation;
1+
using System.Windows.Navigation;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
33
using Flow.Launcher.SettingPages.ViewModels;
4+
using Flow.Launcher.Infrastructure.UserSettings;
45

56
namespace Flow.Launcher.SettingPages.Views;
67

@@ -12,8 +13,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
1213
{
1314
if (!IsInitialized)
1415
{
15-
if (e.ExtraData is not SettingWindow.PaneData { Settings: { } settings })
16-
throw new ArgumentException("Settings are required for SettingsPaneHotkey.");
16+
var settings = Ioc.Default.GetRequiredService<Settings>();
1717
_viewModel = new SettingsPaneHotkeyViewModel(settings);
1818
DataContext = _viewModel;
1919
InitializeComponent();

0 commit comments

Comments
 (0)