Skip to content

Commit 68f2af6

Browse files
Merge branch 'PrimaryMonitor' of https://github.com/onesounds/Flow.Launcher into pr/1978
2 parents 78a74b9 + 4f0ea01 commit 68f2af6

File tree

13 files changed

+161
-118
lines changed

13 files changed

+161
-118
lines changed

.github/ISSUE_TEMPLATE/bug-report.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ body:
1010

1111
- type: checkboxes
1212
attributes:
13-
label: Checks
13+
label: Check New Issue
1414
options:
1515
- label: >
1616
I have checked that this issue has not already been reported.
1717
18+
- type: checkboxes
19+
attributes:
20+
label: Check Latest Version
21+
options:
22+
- label: >
23+
I am using the latest version of Flow Launcher.
24+
1825
- type: textarea
1926
attributes:
2027
label: Problem Description
@@ -54,7 +61,6 @@ body:
5461
validations:
5562
required: true
5663

57-
5864
- type: textarea
5965
id: logs
6066
attributes:

.github/actions/spelling/allow.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ github
22
https
33
ssh
44
ubuntu
5+
runcount

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ public interface IPublicAPI
233233
/// Open directory in an explorer configured by user via Flow's Settings. The default is Windows Explorer
234234
/// </summary>
235235
/// <param name="DirectoryPath">Directory Path to open</param>
236-
/// <param name="FileName">Extra FileName Info</param>
237-
public void OpenDirectory(string DirectoryPath, string FileName = null);
236+
/// <param name="FileNameOrFilePath">Extra FileName Info</param>
237+
public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null);
238238

239239
/// <summary>
240240
/// Opens the URL with the given Uri object.

Flow.Launcher.Plugin/Result.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public override int GetHashCode()
178178
/// <inheritdoc />
179179
public override string ToString()
180180
{
181-
return Title + SubTitle;
181+
return Title + SubTitle + Score;
182182
}
183183

184184
/// <summary>

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ public static class FilesFolders
1414
{
1515
private const string FileExplorerProgramName = "explorer";
1616

17-
private const string FileExplorerProgramEXE = "explorer.exe";
18-
1917
/// <summary>
2018
/// Copies the folder and all of its files and folders
2119
/// including subfolders to the target location
@@ -151,7 +149,12 @@ public static bool FileExists(this string filePath)
151149
/// <param name="fileOrFolderPath"></param>
152150
public static void OpenPath(string fileOrFolderPath)
153151
{
154-
var psi = new ProcessStartInfo { FileName = FileExplorerProgramName, UseShellExecute = true, Arguments = '"' + fileOrFolderPath + '"' };
152+
var psi = new ProcessStartInfo
153+
{
154+
FileName = FileExplorerProgramName,
155+
UseShellExecute = true,
156+
Arguments = '"' + fileOrFolderPath + '"'
157+
};
155158
try
156159
{
157160
if (LocationExists(fileOrFolderPath) || FileExists(fileOrFolderPath))
@@ -167,15 +170,6 @@ public static void OpenPath(string fileOrFolderPath)
167170
}
168171
}
169172

170-
/// <summary>
171-
/// Open the folder that contains <paramref name="path"/>
172-
/// </summary>
173-
/// <param name="path"></param>
174-
public static void OpenContainingFolder(string path)
175-
{
176-
Process.Start(FileExplorerProgramEXE, $" /select,\"{path}\"");
177-
}
178-
179173
///<summary>
180174
/// This checks whether a given string is a directory path or network location string.
181175
/// It does not check if location actually exists.

Flow.Launcher/MainWindow.xaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,9 @@
335335
</Grid>
336336
<Grid>
337337
<Grid.ColumnDefinitions>
338-
<ColumnDefinition Width="*" />
339-
<ColumnDefinition
340-
Width="0.85*"
341-
MinWidth="244"
342-
MaxWidth="340" />
338+
<ColumnDefinition Width="*" MinWidth="100" />
339+
<ColumnDefinition Width="Auto" />
340+
<ColumnDefinition Width="0.85*" MinWidth="244" />
343341
</Grid.ColumnDefinitions>
344342
<StackPanel
345343
x:Name="ResultArea"
@@ -394,9 +392,16 @@
394392
</ContentControl>
395393
</Border>
396394
</StackPanel>
395+
<GridSplitter
396+
Grid.Column="1"
397+
Width="5"
398+
HorizontalAlignment="Center"
399+
VerticalAlignment="Stretch"
400+
Background="Transparent"
401+
ShowsPreview="True" />
397402
<Grid
398403
x:Name="Preview"
399-
Grid.Column="1"
404+
Grid.Column="2"
400405
VerticalAlignment="Stretch"
401406
Style="{DynamicResource PreviewArea}"
402407
Visibility="{Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}">

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
 using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Net;
@@ -195,17 +195,20 @@ public void SavePluginSettings()
195195
((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save();
196196
}
197197

198-
public void OpenDirectory(string DirectoryPath, string FileName = null)
198+
public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null)
199199
{
200200
using var explorer = new Process();
201201
var explorerInfo = _settingsVM.Settings.CustomExplorer;
202202
explorer.StartInfo = new ProcessStartInfo
203203
{
204204
FileName = explorerInfo.Path,
205-
Arguments = FileName is null ?
206-
explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) :
207-
explorerInfo.FileArgument.Replace("%d", DirectoryPath).Replace("%f",
208-
Path.IsPathRooted(FileName) ? FileName : Path.Combine(DirectoryPath, FileName))
205+
Arguments = FileNameOrFilePath is null
206+
? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath)
207+
: explorerInfo.FileArgument
208+
.Replace("%d", DirectoryPath)
209+
.Replace("%f",
210+
Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath)
211+
)
209212
};
210213
explorer.Start();
211214
}

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ private void ShowPreview()
469469

470470
private void HidePreview()
471471
{
472-
ResultAreaColumn = 2;
472+
ResultAreaColumn = 3;
473473
PreviewVisible = false;
474474
}
475475

Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ public PluginStoreItemViewModel(UserPlugin plugin)
2626
public string IcoPath => _plugin.IcoPath;
2727

2828
public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null;
29-
public bool LabelUpdate => LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version;
29+
public bool LabelUpdate => LabelInstalled && VersionConvertor(_plugin.Version) > VersionConvertor(PluginManager.GetPluginForId(_plugin.ID).Metadata.Version);
3030

3131
internal const string None = "None";
3232
internal const string RecentlyUpdated = "RecentlyUpdated";
3333
internal const string NewRelease = "NewRelease";
3434
internal const string Installed = "Installed";
3535

36+
public Version VersionConvertor(string version)
37+
{
38+
Version ResultVersion = new Version(version);
39+
return ResultVersion;
40+
}
41+
3642
public string Category
3743
{
3844
get

Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class EverythingApi
1717
{
1818
private const int BufferSize = 4096;
1919

20-
private static SemaphoreSlim _semaphore = new(1, 1);
20+
private static readonly SemaphoreSlim _semaphore = new(1, 1);
2121

2222
// cached buffer to remove redundant allocations.
2323
private static readonly StringBuilder buffer = new(BufferSize);
@@ -34,6 +34,9 @@ public enum StateCode
3434
InvalidCallError
3535
}
3636

37+
const uint EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME = 0x00000004u;
38+
const uint EVERYTHING_REQUEST_RUN_COUNT = 0x00000400u;
39+
3740
/// <summary>
3841
/// Checks whether the sort option is Fast Sort.
3942
/// </summary>
@@ -78,7 +81,7 @@ public static async IAsyncEnumerable<SearchResult> SearchAsync(EverythingSearchO
7881

7982
if (option.MaxCount < 0)
8083
throw new ArgumentOutOfRangeException(nameof(option.MaxCount), option.MaxCount, "MaxCount must be greater than or equal to 0");
81-
84+
8285
await _semaphore.WaitAsync(token);
8386

8487

@@ -112,6 +115,17 @@ public static async IAsyncEnumerable<SearchResult> SearchAsync(EverythingSearchO
112115

113116
EverythingApiDllImport.Everything_SetSort(option.SortOption);
114117
EverythingApiDllImport.Everything_SetMatchPath(option.IsFullPathSearch);
118+
119+
if (option.SortOption == SortOption.RUN_COUNT_DESCENDING)
120+
{
121+
EverythingApiDllImport.Everything_SetRequestFlags(EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME | EVERYTHING_REQUEST_RUN_COUNT);
122+
}
123+
else
124+
{
125+
EverythingApiDllImport.Everything_SetRequestFlags(EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME);
126+
}
127+
128+
115129

116130
if (token.IsCancellationRequested) yield break;
117131

@@ -132,10 +146,12 @@ public static async IAsyncEnumerable<SearchResult> SearchAsync(EverythingSearchO
132146

133147
var result = new SearchResult
134148
{
149+
// todo the types are wrong. Everything expects uint everywhere, but we send int just above/below. how to fix? Is EverythingApiDllImport autogenerated or handmade?
135150
FullPath = buffer.ToString(),
136151
Type = EverythingApiDllImport.Everything_IsFolderResult(idx) ? ResultType.Folder :
137152
EverythingApiDllImport.Everything_IsFileResult(idx) ? ResultType.File :
138-
ResultType.Volume
153+
ResultType.Volume,
154+
Score = (int)EverythingApiDllImport.Everything_GetResultRunCount( (uint)idx)
139155
};
140156

141157
yield return result;
@@ -172,5 +188,19 @@ private static void CheckAndThrowExceptionOnError()
172188
throw new ArgumentOutOfRangeException();
173189
}
174190
}
191+
192+
public static async Task IncrementRunCounterAsync(string fileOrFolder)
193+
{
194+
await _semaphore.WaitAsync(TimeSpan.FromSeconds(1));
195+
try
196+
{
197+
_ = EverythingApiDllImport.Everything_IncRunCountFromFileName(fileOrFolder);
198+
}
199+
catch (Exception)
200+
{
201+
/*ignored*/
202+
}
203+
finally { _semaphore.Release(); }
204+
}
175205
}
176206
}

0 commit comments

Comments
 (0)