Skip to content

Commit 2202fce

Browse files
committed
Merge dev into fork/040427SplitSettingWindow with merge conflicts resolved
2 parents c350c5d + a68b180 commit 2202fce

File tree

15 files changed

+312
-78
lines changed

15 files changed

+312
-78
lines changed

Flow.Launcher.Core/ExternalPlugins/UserPlugin.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22

33
namespace Flow.Launcher.Core.ExternalPlugins
44
{
@@ -13,9 +13,11 @@ public record UserPlugin
1313
public string Website { get; set; }
1414
public string UrlDownload { get; set; }
1515
public string UrlSourceCode { get; set; }
16+
public string LocalInstallPath { get; set; }
1617
public string IcoPath { get; set; }
1718
public DateTime? LatestReleaseDate { get; set; }
1819
public DateTime? DateAdded { get; set; }
1920

21+
public bool IsFromLocalInstallPath => !string.IsNullOrEmpty(LocalInstallPath);
2022
}
2123
}

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ public static bool PluginModified(string uuid)
380380

381381

382382
/// <summary>
383-
/// Update a plugin to new version, from a zip file. Will Delete zip after updating.
383+
/// Update a plugin to new version, from a zip file. By default will remove the zip file if update is via url,
384+
/// unless it's a local path installation
384385
/// </summary>
385386
public static void UpdatePlugin(PluginMetadata existingVersion, UserPlugin newVersion, string zipFilePath)
386387
{
@@ -390,11 +391,11 @@ public static void UpdatePlugin(PluginMetadata existingVersion, UserPlugin newVe
390391
}
391392

392393
/// <summary>
393-
/// Install a plugin. Will Delete zip after updating.
394+
/// Install a plugin. By default will remove the zip file if installation is from url, unless it's a local path installation
394395
/// </summary>
395396
public static void InstallPlugin(UserPlugin plugin, string zipFilePath)
396397
{
397-
InstallPlugin(plugin, zipFilePath, true);
398+
InstallPlugin(plugin, zipFilePath, checkModified: true);
398399
}
399400

400401
/// <summary>
@@ -420,7 +421,9 @@ internal static void InstallPlugin(UserPlugin plugin, string zipFilePath, bool c
420421
// Unzip plugin files to temp folder
421422
var tempFolderPluginPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
422423
System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, tempFolderPluginPath);
423-
File.Delete(zipFilePath);
424+
425+
if(!plugin.IsFromLocalInstallPath)
426+
File.Delete(zipFilePath);
424427

425428
var pluginFolderPath = GetContainingFolderPathAfterUnzip(tempFolderPluginPath);
426429

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class Settings : BaseModel, IHotkeySettings
3131
public string SelectPrevPageHotkey { get; set; } = $"PageDown";
3232
public string OpenContextMenuHotkey { get; set; } = $"Ctrl+O";
3333
public string SettingWindowHotkey { get; set; } = $"Ctrl+I";
34+
public string CycleHistoryUpHotkey { get; set; } = $"{KeyConstant.Alt} + Up";
35+
public string CycleHistoryDownHotkey { get; set; } = $"{KeyConstant.Alt} + Down";
3436

3537
public string Language
3638
{
@@ -280,42 +282,9 @@ public List<RegisteredHotkeyData> RegisteredHotkeys
280282
{
281283
get
282284
{
283-
var list = new List<RegisteredHotkeyData>
284-
{
285-
new("Up", "HotkeyLeftRightDesc"),
286-
new("Down", "HotkeyLeftRightDesc"),
287-
new("Left", "HotkeyUpDownDesc"),
288-
new("Right", "HotkeyUpDownDesc"),
289-
new("Escape", "HotkeyESCDesc"),
290-
new("F5", "ReloadPluginHotkey"),
291-
new("Alt+Home", "HotkeySelectFirstResult"),
292-
new("Alt+End", "HotkeySelectLastResult"),
293-
new("Ctrl+R", "HotkeyRequery"),
294-
new("Ctrl+H", "ToggleHistoryHotkey"),
295-
new("Ctrl+OemCloseBrackets", "QuickWidthHotkey"),
296-
new("Ctrl+OemOpenBrackets", "QuickWidthHotkey"),
297-
new("Ctrl+OemPlus", "QuickHeightHotkey"),
298-
new("Ctrl+OemMinus", "QuickHeightHotkey"),
299-
new("Ctrl+Shift+Enter", "HotkeyCtrlShiftEnterDesc"),
300-
new("Shift+Enter", "OpenContextMenuHotkey"),
301-
new("Enter", "HotkeyRunDesc"),
302-
new("Ctrl+Enter", "OpenContainFolderHotkey"),
303-
new("Alt+Enter", "HotkeyOpenResult"),
304-
new("Ctrl+F12", "ToggleGameModeHotkey"),
305-
new("Ctrl+Shift+C", "CopyFilePathHotkey"),
306-
307-
new($"{OpenResultModifiers}+D1", "HotkeyOpenResultN", 1),
308-
new($"{OpenResultModifiers}+D2", "HotkeyOpenResultN", 2),
309-
new($"{OpenResultModifiers}+D3", "HotkeyOpenResultN", 3),
310-
new($"{OpenResultModifiers}+D4", "HotkeyOpenResultN", 4),
311-
new($"{OpenResultModifiers}+D5", "HotkeyOpenResultN", 5),
312-
new($"{OpenResultModifiers}+D6", "HotkeyOpenResultN", 6),
313-
new($"{OpenResultModifiers}+D7", "HotkeyOpenResultN", 7),
314-
new($"{OpenResultModifiers}+D8", "HotkeyOpenResultN", 8),
315-
new($"{OpenResultModifiers}+D9", "HotkeyOpenResultN", 9),
316-
new($"{OpenResultModifiers}+D0", "HotkeyOpenResultN", 10)
317-
};
285+
var list = FixedHotkeys();
318286

287+
// Customizeable hotkeys
319288
if(!string.IsNullOrEmpty(Hotkey))
320289
list.Add(new(Hotkey, "flowlauncherHotkey", () => Hotkey = ""));
321290
if(!string.IsNullOrEmpty(PreviewHotkey))
@@ -340,7 +309,12 @@ public List<RegisteredHotkeyData> RegisteredHotkeys
340309
list.Add(new(SelectNextPageHotkey, "SelectNextPageHotkey", () => SelectNextPageHotkey = ""));
341310
if(!string.IsNullOrEmpty(SelectPrevPageHotkey))
342311
list.Add(new(SelectPrevPageHotkey, "SelectPrevPageHotkey", () => SelectPrevPageHotkey = ""));
312+
if (!string.IsNullOrEmpty(CycleHistoryUpHotkey))
313+
list.Add(new(CycleHistoryUpHotkey, "CycleHistoryUpHotkey", () => CycleHistoryUpHotkey = ""));
314+
if (!string.IsNullOrEmpty(CycleHistoryDownHotkey))
315+
list.Add(new(CycleHistoryDownHotkey, "CycleHistoryDownHotkey", () => CycleHistoryDownHotkey = ""));
343316

317+
// Custom Query Hotkeys
344318
foreach (var customPluginHotkey in CustomPluginHotkeys)
345319
{
346320
if (!string.IsNullOrEmpty(customPluginHotkey.Hotkey))
@@ -350,6 +324,45 @@ public List<RegisteredHotkeyData> RegisteredHotkeys
350324
return list;
351325
}
352326
}
327+
328+
private List<RegisteredHotkeyData> FixedHotkeys()
329+
{
330+
return new List<RegisteredHotkeyData>
331+
{
332+
new("Up", "HotkeyLeftRightDesc"),
333+
new("Down", "HotkeyLeftRightDesc"),
334+
new("Left", "HotkeyUpDownDesc"),
335+
new("Right", "HotkeyUpDownDesc"),
336+
new("Escape", "HotkeyESCDesc"),
337+
new("F5", "ReloadPluginHotkey"),
338+
new("Alt+Home", "HotkeySelectFirstResult"),
339+
new("Alt+End", "HotkeySelectLastResult"),
340+
new("Ctrl+R", "HotkeyRequery"),
341+
new("Ctrl+H", "ToggleHistoryHotkey"),
342+
new("Ctrl+OemCloseBrackets", "QuickWidthHotkey"),
343+
new("Ctrl+OemOpenBrackets", "QuickWidthHotkey"),
344+
new("Ctrl+OemPlus", "QuickHeightHotkey"),
345+
new("Ctrl+OemMinus", "QuickHeightHotkey"),
346+
new("Ctrl+Shift+Enter", "HotkeyCtrlShiftEnterDesc"),
347+
new("Shift+Enter", "OpenContextMenuHotkey"),
348+
new("Enter", "HotkeyRunDesc"),
349+
new("Ctrl+Enter", "OpenContainFolderHotkey"),
350+
new("Alt+Enter", "HotkeyOpenResult"),
351+
new("Ctrl+F12", "ToggleGameModeHotkey"),
352+
new("Ctrl+Shift+C", "CopyFilePathHotkey"),
353+
354+
new($"{OpenResultModifiers}+D1", "HotkeyOpenResultN", 1),
355+
new($"{OpenResultModifiers}+D2", "HotkeyOpenResultN", 2),
356+
new($"{OpenResultModifiers}+D3", "HotkeyOpenResultN", 3),
357+
new($"{OpenResultModifiers}+D4", "HotkeyOpenResultN", 4),
358+
new($"{OpenResultModifiers}+D5", "HotkeyOpenResultN", 5),
359+
new($"{OpenResultModifiers}+D6", "HotkeyOpenResultN", 6),
360+
new($"{OpenResultModifiers}+D7", "HotkeyOpenResultN", 7),
361+
new($"{OpenResultModifiers}+D8", "HotkeyOpenResultN", 8),
362+
new($"{OpenResultModifiers}+D9", "HotkeyOpenResultN", 9),
363+
new($"{OpenResultModifiers}+D0", "HotkeyOpenResultN", 10)
364+
};
365+
}
353366
}
354367

355368
public enum LastQueryMode

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Diagnostics;
33
using System.IO;
4+
using System.Linq;
45
#pragma warning disable IDE0005
56
using System.Windows;
67
#pragma warning restore IDE0005
@@ -200,6 +201,24 @@ public static void OpenFile(string filePath, string workingDir = "", bool asAdmi
200201
}
201202
}
202203

204+
///<summary>
205+
/// This checks whether a given string is a zip file path.
206+
/// By default does not check if the zip file actually exist on disk, can do so by
207+
/// setting checkFileExists = true.
208+
///</summary>
209+
public static bool IsZipFilePath(string querySearchString, bool checkFileExists = false)
210+
{
211+
if (IsLocationPathString(querySearchString) && querySearchString.Split('.').Last() == "zip")
212+
{
213+
if (checkFileExists)
214+
return FileExists(querySearchString);
215+
216+
return true;
217+
}
218+
219+
return false;
220+
}
221+
203222
///<summary>
204223
/// This checks whether a given string is a directory path or network location string.
205224
/// It does not check if location actually exists.

Flow.Launcher.Test/Plugins/ExplorerTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,15 @@ public void GivenQuery_WhenActionKeywordForFileContentSearchExists_ThenFileConte
191191
[TestCase(@"\c:\", false)]
192192
[TestCase(@"cc:\", false)]
193193
[TestCase(@"\\\SomeNetworkLocation\", false)]
194+
[TestCase(@"\\SomeNetworkLocation\", true)]
194195
[TestCase("RandomFile", false)]
195196
[TestCase(@"c:\>*", true)]
196197
[TestCase(@"c:\>", true)]
197198
[TestCase(@"c:\SomeLocation\SomeOtherLocation\>", true)]
198199
[TestCase(@"c:\SomeLocation\SomeOtherLocation", true)]
200+
[TestCase(@"c:\SomeLocation\SomeOtherLocation\SomeFile.exe", true)]
201+
[TestCase(@"\\SomeNetworkLocation\SomeFile.exe", true)]
202+
199203
public void WhenGivenQuerySearchString_ThenShouldIndicateIfIsLocationPathString(string querySearchString, bool expectedResult)
200204
{
201205
// When, Given

Flow.Launcher/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@
188188
<system:String x:Key="SelectPrevItemHotkey">Select Previous Item</system:String>
189189
<system:String x:Key="SelectNextPageHotkey">Next Page</system:String>
190190
<system:String x:Key="SelectPrevPageHotkey">Previous Page</system:String>
191+
<system:String x:Key="CycleHistoryUpHotkey">Cycle Previous Query</system:String>
192+
<system:String x:Key="CycleHistoryDownHotkey">Cycle Next Query</system:String>
191193
<system:String x:Key="OpenContextMenuHotkey">Open Context Menu</system:String>
192194
<system:String x:Key="SettingWindowHotkey">Open Setting Window</system:String>
193195
<system:String x:Key="CopyFilePathHotkey">Copy File Path</system:String>

Flow.Launcher/MainWindow.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
LocationChanged="OnLocationChanged"
2626
Opacity="{Binding MainWindowOpacity, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
2727
PreviewKeyDown="OnKeyDown"
28+
PreviewKeyUp="OnKeyUp"
2829
ResizeMode="NoResize"
2930
ShowInTaskbar="False"
3031
SizeToContent="Height"
@@ -197,6 +198,14 @@
197198
Key="{Binding SelectPrevPageHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
198199
Command="{Binding SelectPrevPageCommand}"
199200
Modifiers="{Binding SelectPrevPageHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
201+
<KeyBinding
202+
Key="{Binding CycleHistoryUpHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
203+
Command="{Binding ReverseHistoryCommand}"
204+
Modifiers="{Binding CycleHistoryUpHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
205+
<KeyBinding
206+
Key="{Binding CycleHistoryDownHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
207+
Command="{Binding ForwardHistoryCommand}"
208+
Modifiers="{Binding CycleHistoryDownHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
200209
</Window.InputBindings>
201210
<Grid>
202211
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public partial class MainWindow
4747
private MainViewModel _viewModel;
4848
private bool _animating;
4949
MediaPlayer animationSound = new MediaPlayer();
50+
private bool isArrowKeyPressed = false;
5051

5152
#endregion
5253

@@ -109,9 +110,11 @@ private async void OnClosing(object sender, CancelEventArgs e)
109110
private void OnInitialized(object sender, EventArgs e)
110111
{
111112
}
112-
113113
private void OnLoaded(object sender, RoutedEventArgs _)
114114
{
115+
// MouseEventHandler
116+
PreviewMouseMove += MainPreviewMouseMove;
117+
115118
CheckFirstLaunch();
116119
HideStartup();
117120
// show notify icon when flowlauncher is hidden
@@ -406,6 +409,7 @@ public void WindowAnimator()
406409
if (_animating)
407410
return;
408411

412+
isArrowKeyPressed = true;
409413
_animating = true;
410414
UpdatePosition();
411415

@@ -494,6 +498,7 @@ public void WindowAnimator()
494498
windowsb.Completed += (_, _) => _animating = false;
495499
_settings.WindowLeft = Left;
496500
_settings.WindowTop = Top;
501+
isArrowKeyPressed = false;
497502

498503
if (QueryTextBox.Text.Length == 0)
499504
{
@@ -644,10 +649,12 @@ private void OnKeyDown(object sender, KeyEventArgs e)
644649
switch (e.Key)
645650
{
646651
case Key.Down:
652+
isArrowKeyPressed = true;
647653
_viewModel.SelectNextItemCommand.Execute(null);
648654
e.Handled = true;
649655
break;
650656
case Key.Up:
657+
isArrowKeyPressed = true;
651658
_viewModel.SelectPrevItemCommand.Execute(null);
652659
e.Handled = true;
653660
break;
@@ -698,7 +705,21 @@ private void OnKeyDown(object sender, KeyEventArgs e)
698705

699706
}
700707
}
708+
private void OnKeyUp(object sender, KeyEventArgs e)
709+
{
710+
if (e.Key == Key.Up || e.Key == Key.Down)
711+
{
712+
isArrowKeyPressed = false;
713+
}
714+
}
701715

716+
private void MainPreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
717+
{
718+
if (isArrowKeyPressed)
719+
{
720+
e.Handled = true; // Ignore Mouse Hover when press Arrowkeys
721+
}
722+
}
702723
public void PreviewReset()
703724
{
704725
_viewModel.ResetPreview();

Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@
139139
Type="Inside">
140140
<cc:HotkeyDisplay Keys="Ctrl+R" />
141141
</cc:Card>
142+
<cc:Card
143+
Title="{DynamicResource CycleHistoryUpHotkey}"
144+
Icon="&#xe70e;"
145+
Type="Inside">
146+
<flowlauncher:HotkeyControl
147+
DefaultHotkey="Alt+Up"
148+
Hotkey="{Binding Settings.CycleHistoryUpHotkey}"
149+
HotkeySettings="{Binding Settings}"
150+
ValidateKeyGesture="False" />
151+
</cc:Card>
152+
<cc:Card
153+
Title="{DynamicResource CycleHistoryDownHotkey}"
154+
Icon="&#xe70d;"
155+
Type="Inside">
156+
<flowlauncher:HotkeyControl
157+
DefaultHotkey="Alt+Down"
158+
Hotkey="{Binding Settings.CycleHistoryDownHotkey}"
159+
HotkeySettings="{Binding Settings}"
160+
ValidateKeyGesture="False" />
161+
</cc:Card>
142162
<cc:Card
143163
Title="{DynamicResource ReloadPluginHotkey}"
144164
Icon="&#xe72c;"

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ private void Window_StateChanged(object sender, EventArgs e)
108108
RefreshMaximizeRestoreButton();
109109
}
110110

111-
private void InitializePosition()
111+
public void InitializePosition()
112112
{
113-
if (_settings.SettingWindowTop >= 0 && _settings.SettingWindowLeft >= 0)
113+
if (_settings.SettingWindowTop == null)
114114
{
115-
Top = _settings.SettingWindowTop;
116-
Left = _settings.SettingWindowLeft;
115+
Top = WindowTop();
116+
Left = WindowLeft();
117117
}
118118
else
119119
{
120-
Top = WindowTop();
121-
Left = WindowLeft();
120+
Top = _settings.SettingWindowTop;
121+
Left = _settings.SettingWindowLeft;
122122
}
123123
WindowState = _settings.SettingWindowState;
124124
}

0 commit comments

Comments
 (0)