mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into QuickSizeAdjust & Work around dotnet/wpf#6792
This commit is contained in:
parent
01c9be37bf
commit
0baf04eb74
9 changed files with 141 additions and 9 deletions
|
|
@ -197,5 +197,16 @@ namespace Flow.Launcher.Plugin
|
|||
{
|
||||
return AsyncAction?.Invoke(context) ?? ValueTask.FromResult(Action?.Invoke(context) ?? false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Progress bar display. Providing an int value between 0-100 will trigger the progress bar to be displayed on the result
|
||||
/// </summary>
|
||||
public int? ProgressBar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optionally set the color of the progress bar
|
||||
/// </summary>
|
||||
/// <default>#26a0da (blue)</default>
|
||||
public string ProgressBarColor { get; set; } = "#26a0da";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,4 +115,14 @@
|
|||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="taskkill /f /fi "IMAGENAME eq Flow.Launcher.exe"" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RemoveDuplicateAnalyzers" BeforeTargets="CoreCompile">
|
||||
<!-- Work around https://github.com/dotnet/wpf/issues/6792 -->
|
||||
|
||||
<ItemGroup>
|
||||
<FilteredAnalyzer Include="@(Analyzer->Distinct())" />
|
||||
<Analyzer Remove="@(Analyzer)" />
|
||||
<Analyzer Include="@(FilteredAnalyzer)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
@ -77,7 +77,6 @@ namespace Flow.Launcher
|
|||
};
|
||||
link.Inlines.Add(url);
|
||||
link.NavigateUri = new Uri(url);
|
||||
link.RequestNavigate += (s, e) => SearchWeb.OpenInBrowserTab(e.Uri.ToString());
|
||||
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url);
|
||||
|
||||
paragraph.Inlines.Add(textBeforeUrl);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,11 @@
|
|||
<RowDefinition />
|
||||
<RowDefinition x:Name="SubTitleRowDefinition" Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ProgressBar
|
||||
x:Name="progressbarResult"
|
||||
Foreground="{Binding Result.ProgressBarColor}"
|
||||
Style="{DynamicResource ProgressBarResult}"
|
||||
Value="{Binding Result.ProgressBar}" />
|
||||
<TextBlock
|
||||
x:Name="Title"
|
||||
VerticalAlignment="Center"
|
||||
|
|
|
|||
|
|
@ -81,6 +81,21 @@
|
|||
|
||||
|
||||
<!-- Item Style -->
|
||||
<Style x:Key="ProgressBarResult" TargetType="{x:Type ProgressBar}">
|
||||
<Setter Property="Height" Value="18" />
|
||||
<Setter Property="Margin" Value="0,0,0,4" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Maximum" Value="100" />
|
||||
<Setter Property="Minimum" Value="0" />
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
<Setter Property="Foreground" Value="#26a0da " />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Result.ProgressBar}" Value="{x:Null}">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="BaseItemTitleStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="#FFFFF8" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
|
|
|
|||
|
|
@ -77,6 +77,92 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
};
|
||||
}
|
||||
|
||||
internal static Result CreateDriveSpaceDisplayResult(string path, bool windowsIndexed = false)
|
||||
{
|
||||
var progressBarColor = "#26a0da";
|
||||
int? progressValue = null;
|
||||
var title = string.Empty; // hide title when use progress bar,
|
||||
var driveLetter = path.Substring(0, 1).ToUpper();
|
||||
var driveName = driveLetter + ":\\";
|
||||
DriveInfo drv = new DriveInfo(driveLetter);
|
||||
var subtitle = toReadableSize(drv.AvailableFreeSpace, 2) + " free of " + toReadableSize(drv.TotalSize, 2);
|
||||
double UsingSize = (Convert.ToDouble(drv.TotalSize) - Convert.ToDouble(drv.AvailableFreeSpace)) / Convert.ToDouble(drv.TotalSize) * 100;
|
||||
|
||||
progressValue = Convert.ToInt32(UsingSize);
|
||||
|
||||
if (progressValue >= 90)
|
||||
progressBarColor = "#da2626";
|
||||
|
||||
return new Result
|
||||
{
|
||||
Title = title,
|
||||
SubTitle = subtitle,
|
||||
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
|
||||
IcoPath = path,
|
||||
Score = 500,
|
||||
ProgressBar = progressValue,
|
||||
ProgressBarColor = progressBarColor,
|
||||
Action = c =>
|
||||
{
|
||||
Context.API.OpenDirectory(path);
|
||||
return true;
|
||||
},
|
||||
TitleToolTip = path,
|
||||
SubTitleToolTip = path,
|
||||
ContextData = new SearchResult
|
||||
{
|
||||
Type = ResultType.Folder,
|
||||
FullPath = path,
|
||||
ShowIndexState = true,
|
||||
WindowsIndexed = windowsIndexed
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static string toReadableSize(long pDrvSize, int pi)
|
||||
{
|
||||
int mok = 0;
|
||||
double drvSize = pDrvSize;
|
||||
string Space = "Byte";
|
||||
|
||||
while (drvSize > 1024.0)
|
||||
{
|
||||
drvSize /= 1024.0;
|
||||
mok++;
|
||||
}
|
||||
|
||||
if (mok == 1)
|
||||
Space = "KB";
|
||||
else if (mok == 2)
|
||||
Space = " MB";
|
||||
else if (mok == 3)
|
||||
Space = " GB";
|
||||
else if (mok == 4)
|
||||
Space = " TB";
|
||||
|
||||
var returnStr = string.Format("{0}{1}", Convert.ToInt32(drvSize), Space);
|
||||
if (mok != 0)
|
||||
{
|
||||
switch (pi)
|
||||
{
|
||||
case 1:
|
||||
returnStr = string.Format("{0:F1}{1}", drvSize, Space);
|
||||
break;
|
||||
case 2:
|
||||
returnStr = string.Format("{0:F2}{1}", drvSize, Space);
|
||||
break;
|
||||
case 3:
|
||||
returnStr = string.Format("{0:F3}{1}", drvSize, Space);
|
||||
break;
|
||||
default:
|
||||
returnStr = string.Format("{0}{1}", Convert.ToInt32(drvSize), Space);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
|
||||
{
|
||||
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
|
||||
|
|
@ -208,4 +294,4 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
Folder,
|
||||
File
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
var useIndexSearch = UseWindowsIndexForDirectorySearch(locationPath);
|
||||
|
||||
results.Add(ResultManager.CreateOpenCurrentFolderResult(locationPath, useIndexSearch));
|
||||
if (locationPath.EndsWith(":\\"))
|
||||
{
|
||||
results.Add(ResultManager.CreateDriveSpaceDisplayResult(locationPath, useIndexSearch));
|
||||
}
|
||||
else
|
||||
{
|
||||
results.Add(ResultManager.CreateOpenCurrentFolderResult(locationPath, useIndexSearch));
|
||||
}
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
||||
using Microsoft.Search.Interop;
|
||||
using System;
|
||||
|
|
@ -17,7 +17,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
{
|
||||
|
||||
// Reserved keywords in oleDB
|
||||
private const string reservedStringPattern = @"^[`\@\#\^,\&\/\\\$\%_;\[\]]+$";
|
||||
private const string reservedStringPattern = @"^[`\@\@\#\#\*\^,\&\&\/\\\$\%_;\[\]]+$";
|
||||
|
||||
internal static async Task<List<Result>> ExecuteWindowsIndexSearchAsync(string indexQueryString, string connectionString, Query query, CancellationToken token)
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
await using var conn = new OleDbConnection(connectionString);
|
||||
await conn.OpenAsync(token);
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
|
||||
await using var command = new OleDbCommand(indexQueryString, conn);
|
||||
// Results return as an OleDbDataReader.
|
||||
await using var dataReaderResults = await command.ExecuteReaderAsync(token) as OleDbDataReader;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "6.0.100",
|
||||
"rollForward": "latestFeature"
|
||||
"version": "6.0.*",
|
||||
"rollForward": "latestPatch"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue