Merge branch 'dev' into RemoveUnusedNuget

This commit is contained in:
VictoriousRaptor 2023-06-11 18:36:04 +08:00 committed by GitHub
commit dcc7dbb918
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 113 additions and 101 deletions

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
@ -54,8 +54,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Droplex" Version="1.6.0" /> <PackageReference Include="Droplex" Version="1.6.0" />
<PackageReference Include="FSharp.Core" Version="7.0.0" /> <PackageReference Include="FSharp.Core" Version="7.0.300" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.1" /> <PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" /> <PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
</ItemGroup> </ItemGroup>

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
@ -53,7 +53,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.4.27" /> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.5.22" />
<PackageReference Include="NLog" Version="4.7.10" /> <PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NLog.Schema" Version="4.7.10" /> <PackageReference Include="NLog.Schema" Version="4.7.10" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" /> <PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" />

View file

@ -80,6 +80,17 @@ namespace Flow.Launcher.Plugin
/// </summary> /// </summary>
void ShowMainWindow(); void ShowMainWindow();
/// <summary>
/// Hide MainWindow
/// </summary>
void HideMainWindow();
/// <summary>
/// Representing whether the main window is visible
/// </summary>
/// <returns></returns>
bool IsMainWindowVisible();
/// <summary> /// <summary>
/// Show message box /// Show message box
/// </summary> /// </summary>

View file

@ -54,7 +54,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -94,10 +94,6 @@
<!-- https://github.com/Flow-Launcher/Flow.Launcher/issues/1772#issuecomment-1502440801 --> <!-- https://github.com/Flow-Launcher/Flow.Launcher/issues/1772#issuecomment-1502440801 -->
<PackageReference Include="ModernWpfUI" Version="0.9.4" /> <PackageReference Include="ModernWpfUI" Version="0.9.4" />
<PackageReference Include="NHotkey.Wpf" Version="2.1.0" /> <PackageReference Include="NHotkey.Wpf" Version="2.1.0" />
<PackageReference Include="NuGet.CommandLine" Version="6.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" /> <PackageReference Include="PropertyChanged.Fody" Version="3.4.0" />
<PackageReference Include="SharpVectors" Version="1.8.1" /> <PackageReference Include="SharpVectors" Version="1.8.1" />
<PackageReference Include="VirtualizingWrapPanel" Version="1.5.7" /> <PackageReference Include="VirtualizingWrapPanel" Version="1.5.7" />

View file

@ -59,14 +59,16 @@ namespace Flow.Launcher
private void OnCopy(object sender, ExecutedRoutedEventArgs e) private void OnCopy(object sender, ExecutedRoutedEventArgs e)
{ {
if (QueryTextBox.SelectionLength == 0) var result = _viewModel.Results.SelectedItem?.Result;
if (QueryTextBox.SelectionLength == 0 && result != null)
{ {
_viewModel.ResultCopy(string.Empty); string copyText = result.CopyText;
_viewModel.ResultCopy(copyText);
} }
else if (!string.IsNullOrEmpty(QueryTextBox.Text)) else if (!string.IsNullOrEmpty(QueryTextBox.Text))
{ {
_viewModel.ResultCopy(QueryTextBox.SelectedText); System.Windows.Clipboard.SetText(QueryTextBox.SelectedText);
} }
} }

View file

@ -73,6 +73,10 @@ namespace Flow.Launcher
public void ShowMainWindow() => _mainVM.Show(); public void ShowMainWindow() => _mainVM.Show();
public void HideMainWindow() => _mainVM.Hide();
public bool IsMainWindowVisible() => _mainVM.MainWindowVisibilityStatus;
public void CheckForNewUpdate() => _settingsVM.UpdateApp(); public void CheckForNewUpdate() => _settingsVM.UpdateApp();
public void SaveAppAllSettings() public void SaveAppAllSettings()
@ -114,7 +118,7 @@ namespace Flow.Launcher
public void CopyToClipboard(string text) public void CopyToClipboard(string text)
{ {
Clipboard.SetDataObject(text); _mainVM.ResultCopy(text);
} }
public void StartLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Visible; public void StartLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Visible;

View file

@ -9,6 +9,7 @@ using Flow.Launcher.ViewModel;
using ModernWpf; using ModernWpf;
using ModernWpf.Controls; using ModernWpf.Controls;
using System; using System;
using System.ComponentModel;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Data; using System.Windows.Data;
@ -56,12 +57,24 @@ namespace Flow.Launcher
pluginListView = (CollectionView)CollectionViewSource.GetDefaultView(Plugins.ItemsSource); pluginListView = (CollectionView)CollectionViewSource.GetDefaultView(Plugins.ItemsSource);
pluginListView.Filter = PluginListFilter; pluginListView.Filter = PluginListFilter;
pluginStoreView = (CollectionView)CollectionViewSource.GetDefaultView(StoreListBox.ItemsSource); pluginStoreView = (CollectionView)CollectionViewSource.GetDefaultView(StoreListBox.ItemsSource);
pluginStoreView.Filter = PluginStoreFilter; pluginStoreView.Filter = PluginStoreFilter;
viewModel.PropertyChanged += new PropertyChangedEventHandler(SettingsWindowViewModelChanged);
InitializePosition(); InitializePosition();
} }
private void SettingsWindowViewModelChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(viewModel.ExternalPlugins))
{
pluginStoreView = (CollectionView)CollectionViewSource.GetDefaultView(StoreListBox.ItemsSource);
pluginStoreView.Filter = PluginStoreFilter;
pluginStoreView.Refresh();
}
}
private void OnSelectPythonPathClick(object sender, RoutedEventArgs e) private void OnSelectPythonPathClick(object sender, RoutedEventArgs e)
{ {
var selectedFile = viewModel.GetFileFromDialog( var selectedFile = viewModel.GetFileFromDialog(
@ -255,9 +268,9 @@ namespace Flow.Launcher
{ {
var confirmResult = MessageBox.Show( var confirmResult = MessageBox.Show(
InternationalizationManager.Instance.GetTranslation("clearlogfolderMessage"), InternationalizationManager.Instance.GetTranslation("clearlogfolderMessage"),
InternationalizationManager.Instance.GetTranslation("clearlogfolder"), InternationalizationManager.Instance.GetTranslation("clearlogfolder"),
MessageBoxButton.YesNo); MessageBoxButton.YesNo);
if (confirmResult == MessageBoxResult.Yes) if (confirmResult == MessageBoxResult.Yes)
{ {
viewModel.ClearLogFolder(); viewModel.ClearLogFolder();
@ -388,7 +401,7 @@ namespace Flow.Launcher
} }
#endregion #endregion
private CollectionView pluginListView; private CollectionView pluginListView;
private CollectionView pluginStoreView; private CollectionView pluginStoreView;

View file

@ -1104,47 +1104,39 @@ namespace Flow.Launcher.ViewModel
} }
/// <summary> /// <summary>
/// This is the global copy method for an individual result. If no text is passed, /// Copies the specified file or folder path to the clipboard, or the specified text if it is not a valid file or folder path.
/// the method will work out what is to be copied based on the result, so plugin can offer the text /// Shows a message indicating whether the operation was completed successfully.
/// to be copied via the result model. If the text is a directory/file path,
/// then actual file/folder will be copied instead.
/// The result's subtitle text is the default text to be copied
/// </summary> /// </summary>
/// <param name="stringToCopy">The file or folder path, or text to copy to the clipboard.</param>
/// <returns>Nothing.</returns>
public void ResultCopy(string stringToCopy) public void ResultCopy(string stringToCopy)
{ {
if (string.IsNullOrEmpty(stringToCopy)) if (string.IsNullOrEmpty(stringToCopy))
{ {
var result = Results.SelectedItem?.Result;
if (result != null)
{
string copyText = result.CopyText;
var isFile = File.Exists(copyText);
var isFolder = Directory.Exists(copyText);
if (isFile || isFolder)
{
var paths = new StringCollection
{
copyText
};
Clipboard.SetFileDropList(paths);
App.API.ShowMsg(
$"{App.API.GetTranslation("copy")} {(isFile ? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle"))}",
App.API.GetTranslation("completedSuccessfully"));
}
else
{
Clipboard.SetDataObject(copyText);
App.API.ShowMsg(
$"{App.API.GetTranslation("copy")} {App.API.GetTranslation("textTitle")}",
App.API.GetTranslation("completedSuccessfully"));
}
}
return; return;
} }
var isFile = File.Exists(stringToCopy);
var isFolder = Directory.Exists(stringToCopy);
if (isFile || isFolder)
{
var paths = new StringCollection
{
stringToCopy
};
Clipboard.SetDataObject(stringToCopy); Clipboard.SetFileDropList(paths);
App.API.ShowMsg(
$"{App.API.GetTranslation("copy")} {(isFile ? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle"))}",
App.API.GetTranslation("completedSuccessfully"));
}
else
{
Clipboard.SetDataObject(stringToCopy);
App.API.ShowMsg(
$"{App.API.GetTranslation("copy")} {App.API.GetTranslation("textTitle")}",
App.API.GetTranslation("completedSuccessfully"));
}
return;
} }
#endregion #endregion

View file

@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using System.Threading.Tasks;
namespace Flow.Launcher.Plugin.ProcessKiller namespace Flow.Launcher.Plugin.ProcessKiller
{ {
@ -89,7 +88,8 @@ namespace Flow.Launcher.Plugin.ProcessKiller
Action = (c) => Action = (c) =>
{ {
processHelper.TryKill(p); processHelper.TryKill(p);
_ = DelayAndReQueryAsync(query.RawQuery); // Re-query after killing process to refresh process list // Re-query to refresh process list
_context.API.ChangeQuery(query.RawQuery, true);
return true; return true;
} }
}); });
@ -114,7 +114,8 @@ namespace Flow.Launcher.Plugin.ProcessKiller
{ {
processHelper.TryKill(p.Process); processHelper.TryKill(p.Process);
} }
_ = DelayAndReQueryAsync(query.RawQuery); // Re-query after killing process to refresh process list // Re-query to refresh process list
_context.API.ChangeQuery(query.RawQuery, true);
return true; return true;
} }
}); });
@ -122,11 +123,5 @@ namespace Flow.Launcher.Plugin.ProcessKiller
return sortedResults; return sortedResults;
} }
private static async Task DelayAndReQueryAsync(string query)
{
await Task.Delay(500);
_context.API.ChangeQuery(query, true);
}
} }
} }

View file

@ -1,4 +1,4 @@
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -75,6 +75,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
if (!p.HasExited) if (!p.HasExited)
{ {
p.Kill(); p.Kill();
p.WaitForExit(50);
} }
} }
catch (Exception e) catch (Exception e)

View file

@ -88,21 +88,24 @@ namespace Flow.Launcher.Plugin.Program
bool cacheEmpty = !_win32s.Any() && !_uwps.Any(); bool cacheEmpty = !_win32s.Any() && !_uwps.Any();
var a = Task.Run(() => if (cacheEmpty || _settings.LastIndexTime.AddHours(30) < DateTime.Now)
{ {
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Win32Program index cost", IndexWin32Programs); _ = Task.Run(async () =>
}); {
await IndexProgramsAsync().ConfigureAwait(false);
var b = Task.Run(() => WatchProgramUpdate();
});
}
else
{ {
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPPRogram index cost", IndexUwpPrograms); WatchProgramUpdate();
}); }
if (cacheEmpty) static void WatchProgramUpdate()
await Task.WhenAll(a, b); {
Win32.WatchProgramUpdate(_settings);
Win32.WatchProgramUpdate(_settings); _ = UWP.WatchPackageChange();
_ = UWP.WatchPackageChange(); }
} }
public static void IndexWin32Programs() public static void IndexWin32Programs()
@ -110,6 +113,8 @@ namespace Flow.Launcher.Plugin.Program
var win32S = Win32.All(_settings); var win32S = Win32.All(_settings);
_win32s = win32S; _win32s = win32S;
ResetCache(); ResetCache();
_win32Storage.Save(_win32s);
_settings.LastIndexTime = DateTime.Now;
} }
public static void IndexUwpPrograms() public static void IndexUwpPrograms()
@ -117,6 +122,8 @@ namespace Flow.Launcher.Plugin.Program
var applications = UWP.All(_settings); var applications = UWP.All(_settings);
_uwps = applications; _uwps = applications;
ResetCache(); ResetCache();
_uwpStorage.Save(_uwps);
_settings.LastIndexTime = DateTime.Now;
} }
public static async Task IndexProgramsAsync() public static async Task IndexProgramsAsync()
@ -131,7 +138,6 @@ namespace Flow.Launcher.Plugin.Program
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPProgram index cost", IndexUwpPrograms); Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPProgram index cost", IndexUwpPrograms);
}); });
await Task.WhenAll(a, b).ConfigureAwait(false); await Task.WhenAll(a, b).ConfigureAwait(false);
_settings.LastIndexTime = DateTime.Today;
} }
internal static void ResetCache() internal static void ResetCache()
@ -199,7 +205,6 @@ namespace Flow.Launcher.Plugin.Program
_ = Task.Run(() => _ = Task.Run(() =>
{ {
IndexUwpPrograms(); IndexUwpPrograms();
_settings.LastIndexTime = DateTime.Today;
}); });
} }
else if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)) else if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
@ -210,7 +215,6 @@ namespace Flow.Launcher.Plugin.Program
_ = Task.Run(() => _ = Task.Run(() =>
{ {
IndexWin32Programs(); IndexWin32Programs();
_settings.LastIndexTime = DateTime.Today;
}); });
} }
} }

View file

@ -121,13 +121,6 @@ namespace Flow.Launcher.Plugin.Program
public bool EnablePathSource { get; set; } = false; public bool EnablePathSource { get; set; } = false;
public bool EnableUWP { get; set; } = true; public bool EnableUWP { get; set; } = true;
public string CustomizedExplorer { get; set; } = Explorer;
public string CustomizedArgs { get; set; } = ExplorerArgs;
internal const char SuffixSeparator = ';'; internal const char SuffixSeparator = ';';
internal const string Explorer = "explorer";
internal const string ExplorerArgs = "%s";
} }
} }

View file

@ -87,18 +87,6 @@ namespace Flow.Launcher.Plugin.Program.Views
} }
} }
public string CustomizedExplorerPath
{
get => _settings.CustomizedExplorer;
set => _settings.CustomizedExplorer = value;
}
public string CustomizedExplorerArg
{
get => _settings.CustomizedArgs;
set => _settings.CustomizedArgs = value;
}
public bool ShowUWPCheckbox => UWP.SupportUWP(); public bool ShowUWPCheckbox => UWP.SupportUWP();
public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps) public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps)

View file

@ -1,4 +1,5 @@
using System; using System;
using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -200,6 +201,21 @@ namespace Flow.Launcher.Plugin.WindowsSettings.Helper
Process.Start(processStartInfo); Process.Start(processStartInfo);
return true; return true;
} }
catch (Win32Exception)
{
try
{
processStartInfo.UseShellExecute = true;
processStartInfo.Verb = "runas";
Process.Start(processStartInfo);
return true;
}
catch (Exception exception)
{
Log.Exception("can't open settings on elevated permission", exception, typeof(ResultHelper));
return false;
}
}
catch (Exception exception) catch (Exception exception)
{ {
Log.Exception("can't open settings", exception, typeof(ResultHelper)); Log.Exception("can't open settings", exception, typeof(ResultHelper));

View file

@ -222,9 +222,6 @@ And you can download <a href="https://github.com/Flow-Launcher/Flow.Launcher/dis
<a href="https://flowlauncher.com/docs/#/nodejs-develop-plugins"><img src="https://user-images.githubusercontent.com/6903107/147870069-9bde6fe6-d50c-4d85-8fde-fe5ae921ab8c.png" width="64"></a> <a href="https://flowlauncher.com/docs/#/nodejs-develop-plugins"><img src="https://user-images.githubusercontent.com/6903107/147870069-9bde6fe6-d50c-4d85-8fde-fe5ae921ab8c.png" width="64"></a>
</p> </p>
### Everything
<img src="https://user-images.githubusercontent.com/6903107/144533510-6880ecf4-5f93-4b6a-9c1f-4fcdb99110c3.png" width="400">
### SpotifyPremium ### SpotifyPremium
<img src="https://user-images.githubusercontent.com/6903107/144533469-da920295-8c36-46e8-89eb-a9cdd94b74ef.png" width="400"> <img src="https://user-images.githubusercontent.com/6903107/144533469-da920295-8c36-46e8-89eb-a9cdd94b74ef.png" width="400">
@ -341,6 +338,7 @@ And you can download <a href="https://github.com/Flow-Launcher/Flow.Launcher/dis
<a href="https://github.com/andreqramos"><img src="https://avatars.githubusercontent.com/u/49326063?v=4" width="10%" /></a> <a href="https://github.com/andreqramos"><img src="https://avatars.githubusercontent.com/u/49326063?v=4" width="10%" /></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://github.com/patrickdobler"><img src="https://avatars.githubusercontent.com/u/16536946?v=4" width="10%" /></a> <a href="https://github.com/patrickdobler"><img src="https://avatars.githubusercontent.com/u/16536946?v=4" width="10%" /></a>
<a href="https://github.com/benflap"><img src="https://avatars.githubusercontent.com/u/62034481?v=4" width="10%" /></a>
</p> </p>
### Mentions ### Mentions

View file

@ -71,7 +71,6 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
Write-Host "Packing: $spec" Write-Host "Packing: $spec"
Write-Host "Input path: $input" Write-Host "Input path: $input"
New-Alias Nuget $env:USERPROFILE\.nuget\packages\NuGet.CommandLine\6.3.1\tools\NuGet.exe -Force
# dotnet pack is not used because ran into issues, need to test installation and starting up if to use it. # dotnet pack is not used because ran into issues, need to test installation and starting up if to use it.
nuget pack $spec -Version $version -BasePath $input -OutputDirectory $output -Properties Configuration=Release nuget pack $spec -Version $version -BasePath $input -OutputDirectory $output -Properties Configuration=Release

View file

@ -51,7 +51,7 @@ deploy:
- provider: NuGet - provider: NuGet
artifact: Plugin nupkg artifact: Plugin nupkg
api_key: api_key:
secure: EwKxUgjI8VGouFq9fdhI68+uj42amAhwE65JixIbqx8VlqLbyEuW97CLjBBOIL0r secure: Uho7u3gk4RHzyWGgqgXZuOeI55NbqHLQ9tXahL7xmE4av2oiSldrNiyGgy/0AQYw
on: on:
APPVEYOR_REPO_TAG: true APPVEYOR_REPO_TAG: true