mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
- Add 'Free Space in drive'
- when Type "d:\", showing graph with free space.
This commit is contained in:
parent
fabb396dec
commit
4bc3367e3f
4 changed files with 82 additions and 14 deletions
|
|
@ -197,5 +197,7 @@ namespace Flow.Launcher.Plugin
|
||||||
{
|
{
|
||||||
return AsyncAction?.Invoke(context) ?? ValueTask.FromResult(Action?.Invoke(context) ?? false);
|
return AsyncAction?.Invoke(context) ?? ValueTask.FromResult(Action?.Invoke(context) ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int? ProgressBar { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,10 @@
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition x:Name="SubTitleRowDefinition" Height="Auto" />
|
<RowDefinition x:Name="SubTitleRowDefinition" Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
<ProgressBar
|
||||||
|
x:Name="progressbarResult"
|
||||||
|
Style="{DynamicResource ProgressBarResult}"
|
||||||
|
Value="{Binding Result.ProgressBar}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="Title"
|
x:Name="Title"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
|
@ -132,9 +135,7 @@
|
||||||
MinWidth="750"
|
MinWidth="750"
|
||||||
Style="{DynamicResource ItemSubTitleStyle}"
|
Style="{DynamicResource ItemSubTitleStyle}"
|
||||||
Text="{Binding Result.SubTitle}"
|
Text="{Binding Result.SubTitle}"
|
||||||
ToolTip="{Binding ShowSubTitleToolTip}">
|
ToolTip="{Binding ShowSubTitleToolTip}" />
|
||||||
|
|
||||||
</TextBlock>
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,21 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Item Style -->
|
<!-- 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}">
|
<Style x:Key="BaseItemTitleStyle" TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="Foreground" Value="#FFFFF8" />
|
<Setter Property="Foreground" Value="#FFFFF8" />
|
||||||
<Setter Property="FontSize" Value="16" />
|
<Setter Property="FontSize" Value="16" />
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,43 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string toReadableSize(long pDrvSize, int pi)
|
||||||
|
{
|
||||||
|
int mok = 0;
|
||||||
|
double drvSize = pDrvSize;
|
||||||
|
string Space = "Byte";
|
||||||
|
string returnStr = "";
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
if (mok != 0)
|
||||||
|
if (pi == 1)
|
||||||
|
returnStr = string.Format("{0:F1}{1}", drvSize, Space);
|
||||||
|
else if (pi == 2)
|
||||||
|
returnStr = string.Format("{0:F2}{1}", drvSize, Space);
|
||||||
|
else if (pi == 3)
|
||||||
|
returnStr = string.Format("{0:F3}{1}", drvSize, Space);
|
||||||
|
else
|
||||||
|
returnStr = string.Format("{0}{1}", Convert.ToInt32(drvSize), Space);
|
||||||
|
else
|
||||||
|
returnStr = string.Format("{0}{1}", Convert.ToInt32(drvSize), Space);
|
||||||
|
|
||||||
|
return returnStr;
|
||||||
|
}
|
||||||
|
|
||||||
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
|
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
|
||||||
{
|
{
|
||||||
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
|
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
|
||||||
|
|
@ -86,19 +123,32 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
Path.DirectorySeparatorChar
|
Path.DirectorySeparatorChar
|
||||||
}, StringSplitOptions.None).Last();
|
}, StringSplitOptions.None).Last();
|
||||||
|
|
||||||
if (retrievedDirectoryPath.EndsWith(":\\"))
|
|
||||||
{
|
|
||||||
var driveLetter = path.Substring(0, 1).ToUpper();
|
|
||||||
folderName = driveLetter + " drive";
|
|
||||||
}
|
|
||||||
|
|
||||||
var title = "Open current directory";
|
var title = "Open current directory";
|
||||||
|
|
||||||
if (retrievedDirectoryPath != path)
|
if (retrievedDirectoryPath != path)
|
||||||
title = "Open " + folderName;
|
title = "Open " + folderName;
|
||||||
|
|
||||||
|
|
||||||
var subtitleFolderName = folderName;
|
var subtitleFolderName = folderName;
|
||||||
|
var subtitle = $"Use > to search within {subtitleFolderName}, " +
|
||||||
|
$"* to search for file extensions or >* to combine both searches.";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int? progressBar = null;
|
||||||
|
if (retrievedDirectoryPath.EndsWith(":\\"))
|
||||||
|
{
|
||||||
|
title = ""; // hide title when use progress bar,
|
||||||
|
var driveLetter = path.Substring(0, 1).ToUpper();
|
||||||
|
folderName = driveLetter + " drive";
|
||||||
|
var driveName = driveLetter + ":\\";
|
||||||
|
DriveInfo drv = new DriveInfo(driveLetter);
|
||||||
|
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);
|
||||||
|
progressBar = Convert.ToInt32(UsingSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ie. max characters can be displayed without subtitle cutting off: "Program Files (x86)"
|
// ie. max characters can be displayed without subtitle cutting off: "Program Files (x86)"
|
||||||
if (folderName.Length > 19)
|
if (folderName.Length > 19)
|
||||||
|
|
@ -107,11 +157,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
return new Result
|
return new Result
|
||||||
{
|
{
|
||||||
Title = title,
|
Title = title,
|
||||||
SubTitle = $"Use > to search within {subtitleFolderName}, " +
|
SubTitle = subtitle,
|
||||||
$"* to search for file extensions or >* to combine both searches.",
|
|
||||||
AutoCompleteText = GetPathWithActionKeyword(retrievedDirectoryPath, ResultType.Folder),
|
AutoCompleteText = GetPathWithActionKeyword(retrievedDirectoryPath, ResultType.Folder),
|
||||||
IcoPath = retrievedDirectoryPath,
|
IcoPath = retrievedDirectoryPath,
|
||||||
Score = 500,
|
Score = 500,
|
||||||
|
ProgressBar = progressBar,
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
Context.API.OpenDirectory(retrievedDirectoryPath);
|
Context.API.OpenDirectory(retrievedDirectoryPath);
|
||||||
|
|
@ -208,4 +258,4 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
Folder,
|
Folder,
|
||||||
File
|
File
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue