Skip to content

Commit e0ff7d2

Browse files
committed
Merge branch 'dev' into 240430PreviewSetting
2 parents 5ffe091 + 5afce95 commit e0ff7d2

File tree

64 files changed

+6549
-5019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+6549
-5019
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: 51 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
{
@@ -271,6 +273,9 @@ public bool HideNotifyIcon
271273
public AnimationSpeeds AnimationSpeed { get; set; } = AnimationSpeeds.Medium;
272274
public int CustomAnimationLength { get; set; } = 360;
273275

276+
[JsonIgnore]
277+
public bool WMPInstalled { get; set; } = true;
278+
274279

275280
// This needs to be loaded last by staying at the bottom
276281
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
@@ -280,42 +285,9 @@ public List<RegisteredHotkeyData> RegisteredHotkeys
280285
{
281286
get
282287
{
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-
};
288+
var list = FixedHotkeys();
318289

290+
// Customizeable hotkeys
319291
if(!string.IsNullOrEmpty(Hotkey))
320292
list.Add(new(Hotkey, "flowlauncherHotkey", () => Hotkey = ""));
321293
if(!string.IsNullOrEmpty(PreviewHotkey))
@@ -340,7 +312,12 @@ public List<RegisteredHotkeyData> RegisteredHotkeys
340312
list.Add(new(SelectNextPageHotkey, "SelectNextPageHotkey", () => SelectNextPageHotkey = ""));
341313
if(!string.IsNullOrEmpty(SelectPrevPageHotkey))
342314
list.Add(new(SelectPrevPageHotkey, "SelectPrevPageHotkey", () => SelectPrevPageHotkey = ""));
315+
if (!string.IsNullOrEmpty(CycleHistoryUpHotkey))
316+
list.Add(new(CycleHistoryUpHotkey, "CycleHistoryUpHotkey", () => CycleHistoryUpHotkey = ""));
317+
if (!string.IsNullOrEmpty(CycleHistoryDownHotkey))
318+
list.Add(new(CycleHistoryDownHotkey, "CycleHistoryDownHotkey", () => CycleHistoryDownHotkey = ""));
343319

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

355371
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/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</ui:ThemeResources>
2525
<ui:XamlControlsResources />
2626
<ResourceDictionary Source="pack://application:,,,/Resources/CustomControlTemplate.xaml" />
27+
<ResourceDictionary Source="pack://application:,,,/Resources/SettingWindowStyle.xaml" />
2728
<ResourceDictionary Source="pack://application:,,,/Themes/Win11System.xaml" />
2829
<ResourceDictionary Source="pack://application:,,,/Languages/en.xaml" />
2930
</ResourceDictionary.MergedDictionaries>

Flow.Launcher/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
6262

6363
_settingsVM = new SettingWindowViewModel(_updater, _portable);
6464
_settings = _settingsVM.Settings;
65+
_settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled();
6566

6667
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings);
6768

Flow.Launcher/CustomShortcutSetting.xaml.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace Flow.Launcher
88
{
99
public partial class CustomShortcutSetting : Window
1010
{
11-
private SettingWindowViewModel viewModel;
1211
public string Key { get; set; } = String.Empty;
1312
public string Value { get; set; } = String.Empty;
1413
private string originalKey { get; init; } = null;
@@ -17,13 +16,11 @@ public partial class CustomShortcutSetting : Window
1716

1817
public CustomShortcutSetting(SettingWindowViewModel vm)
1918
{
20-
viewModel = vm;
2119
InitializeComponent();
2220
}
2321

24-
public CustomShortcutSetting(string key, string value, SettingWindowViewModel vm)
22+
public CustomShortcutSetting(string key, string value)
2523
{
26-
viewModel = vm;
2724
Key = key;
2825
Value = value;
2926
originalKey = key;
@@ -46,8 +43,7 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
4643
return;
4744
}
4845
// Check if key is modified or adding a new one
49-
if (((update && originalKey != Key) || !update)
50-
&& viewModel.ShortcutExists(Key))
46+
if ((update && originalKey != Key) || !update)
5147
{
5248
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
5349
return;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Microsoft.Win32;
2+
3+
namespace Flow.Launcher.Helper;
4+
internal static class WindowsMediaPlayerHelper
5+
{
6+
internal static bool IsWindowsMediaPlayerInstalled()
7+
{
8+
using var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MediaPlayer");
9+
return key.GetValue("Installation Directory") != null;
10+
}
11+
}

Flow.Launcher/Images/info.png

1.33 KB
Loading

0 commit comments

Comments
 (0)