diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs
index f3f3d2816..136395467 100644
--- a/Flow.Launcher.Plugin/Result.cs
+++ b/Flow.Launcher.Plugin/Result.cs
@@ -198,6 +198,15 @@ namespace Flow.Launcher.Plugin
return AsyncAction?.Invoke(context) ?? ValueTask.FromResult(Action?.Invoke(context) ?? false);
}
+ ///
+ /// Progress bar display. Providing an int value between 0-100 will trigger the progress bar to be displayed on the result
+ ///
public int? ProgressBar { get; set; }
+
+ ///
+ /// Optionally set the color of the progress bar
+ ///
+ /// #26a0da (blue)
+ public string ProgressBarColor { get; set; } = "#26a0da";
}
}
diff --git a/Flow.Launcher/Converters/ProgressForegroundConverter.cs b/Flow.Launcher/Converters/ProgressForegroundConverter.cs
deleted file mode 100644
index 6190f0399..000000000
--- a/Flow.Launcher/Converters/ProgressForegroundConverter.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-using System.Windows.Media;
-
-namespace Flow.Launcher.Converters
-{
- public class ProgressForegroundConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- double progress = (double)value;
- string foreground = "#26a0da";
-
- if (progress >= 90)
- {
- foreground = "#da2626";
- }
-
- return foreground;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Flow.Launcher/ResultListBox.xaml b/Flow.Launcher/ResultListBox.xaml
index 735742b5e..2c78f9bab 100644
--- a/Flow.Launcher/ResultListBox.xaml
+++ b/Flow.Launcher/ResultListBox.xaml
@@ -46,7 +46,6 @@
-
@@ -114,7 +113,7 @@
= 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";
- string returnStr = "";
while (drvSize > 1024.0)
{
@@ -91,7 +132,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
if (mok == 1)
- Space = "KB";
+ Space = "KB";
else if (mok == 2)
Space = " MB";
else if (mok == 3)
@@ -99,17 +140,25 @@ namespace Flow.Launcher.Plugin.Explorer.Search
else if (mok == 4)
Space = " TB";
+ var returnStr = string.Format("{0}{1}", Convert.ToInt32(drvSize), Space);
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);
+ {
+ 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;
}
@@ -123,28 +172,19 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Path.DirectorySeparatorChar
}, StringSplitOptions.None).Last();
+ if (retrievedDirectoryPath.EndsWith(":\\"))
+ {
+ var driveLetter = path.Substring(0, 1).ToUpper();
+ folderName = driveLetter + " drive";
+ }
+
var title = "Open current directory";
if (retrievedDirectoryPath != path)
title = "Open " + 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)"
if (folderName.Length > 19)
@@ -153,11 +193,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return new Result
{
Title = title,
- SubTitle = subtitle,
+ SubTitle = $"Use > to search within {subtitleFolderName}, " +
+ $"* to search for file extensions or >* to combine both searches.",
AutoCompleteText = GetPathWithActionKeyword(retrievedDirectoryPath, ResultType.Folder),
IcoPath = retrievedDirectoryPath,
Score = 500,
- ProgressBar = progressBar,
Action = c =>
{
Context.API.OpenDirectory(retrievedDirectoryPath);
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
index 2b56cdf6e..4bddbda57 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
@@ -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();