From de9894b592e8881357c7fa156db9bfecbb2897b1 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 8 May 2024 16:26:39 -0400 Subject: [PATCH 01/10] Feature: Added support for SeerPro's "Track selected file" setting --- .../PreviewPopupProviders/SeerProProvider.cs | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index e8a9c5248e14..08bab5656f37 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -1,7 +1,7 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Services; +using System.IO; using System.Runtime.InteropServices; using Vanara.PInvoke; @@ -34,6 +34,18 @@ public async Task TogglePreviewPopupAsync(string path) public async Task SwitchPreviewAsync(string path) { + // Close preview window is track selection setting is disabled + if (!isTrackSelectionSettingEnabled) + { + HWND Window = User32.FindWindow("SeerWindowClass", null); + if (User32.IsWindowVisible(Window)) + { + // Hide window if it's already visible + return; + } + } + + // Update the preview window if the path changed if (CurrentPath is not null && path != CurrentPath) await TogglePreviewPopupAsync(path); } @@ -43,5 +55,57 @@ public async Task DetectAvailability() var handle = User32.FindWindow("SeerWindowClass", null).DangerousGetHandle(); return handle != IntPtr.Zero && handle.ToInt64() != -1; } + + private bool? _isTrackSelectionSettingEnabledCache; + private bool isTrackSelectionSettingEnabled + { + get + { + if (_isTrackSelectionSettingEnabledCache is null) + _isTrackSelectionSettingEnabledCache = DetectTrackSelectionSetting().Result; + + return _isTrackSelectionSettingEnabledCache.Value; + } + } + + private Task DetectTrackSelectionSetting() + { + bool trackSelectedFile = true; + + // List of possible paths for the Seer Pro settings file + string[] paths = + { + Environment.ExpandEnvironmentVariables("%USERPROFILE%\\Documents\\Seer\\uwp.ini"), + Environment.ExpandEnvironmentVariables("%USERPROFILE%\\appdata\\Local\\Corey\\Seer\\uwp.ini"), + Environment.ExpandEnvironmentVariables("%USERPROFILE%\\Documents\\Seer\\config.ini") + }; + + // Find the first existing path + foreach (var path in paths) + { + if (File.Exists(path)) + { + // Read the settings file and look for the tracking_file setting + string[] lines = File.ReadAllLines(path); + + foreach (var line in lines) + { + if (line.StartsWith("tracking_file", StringComparison.OrdinalIgnoreCase)) + { + string[] keyValue = line.Split('='); + if (keyValue.Length == 2 && bool.TryParse(keyValue[1].Trim(), out bool isTrackingFile)) + { + trackSelectedFile = isTrackingFile; + break; + } + } + } + + break; + } + } + + return Task.FromResult(trackSelectedFile); + } } } From d0d0761c85b0109bc1faf2f26b63a00891bb5cb6 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 8 May 2024 17:49:56 -0400 Subject: [PATCH 02/10] Update SeerProProvider.cs --- .../Services/PreviewPopupProviders/SeerProProvider.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index 08bab5656f37..6b4897c4200d 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -35,14 +35,10 @@ public async Task TogglePreviewPopupAsync(string path) public async Task SwitchPreviewAsync(string path) { // Close preview window is track selection setting is disabled - if (!isTrackSelectionSettingEnabled) + if (!isTrackSelectionSettingEnabled && !string.IsNullOrEmpty(CurrentPath)) { - HWND Window = User32.FindWindow("SeerWindowClass", null); - if (User32.IsWindowVisible(Window)) - { - // Hide window if it's already visible - return; - } + await TogglePreviewPopupAsync(CurrentPath); + return; } // Update the preview window if the path changed From 30c815a2ab06bdf73333212bd4b5bf401b62324d Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 8 May 2024 18:30:49 -0400 Subject: [PATCH 03/10] Update SeerProProvider.cs --- src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index 6b4897c4200d..b41adb095ba0 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -72,6 +72,7 @@ private Task DetectTrackSelectionSetting() string[] paths = { Environment.ExpandEnvironmentVariables("%USERPROFILE%\\Documents\\Seer\\uwp.ini"), + Environment.ExpandEnvironmentVariables("%USERPROFILE%\\appdata\\Local\\Packages\\CNABA5E861-AC2A-4523-B3C1.Seer-AWindowsQuickLookTo_p7t0z30wh4868\\LocalCache\\Local\\Corey\\Seer\\uwp.ini"), Environment.ExpandEnvironmentVariables("%USERPROFILE%\\appdata\\Local\\Corey\\Seer\\uwp.ini"), Environment.ExpandEnvironmentVariables("%USERPROFILE%\\Documents\\Seer\\config.ini") }; From 9ec9987e070b6b82605da65424b9946d48017ce5 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 9 May 2024 09:51:25 -0700 Subject: [PATCH 04/10] Update src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs Update SeerProProvider.cs Update src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs Co-Authored-By: 0x5bfa <62196528+0x5bfa@users.noreply.github.com> --- .../PreviewPopupProviders/SeerProProvider.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index b41adb095ba0..4132a1359cc1 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -35,7 +35,7 @@ public async Task TogglePreviewPopupAsync(string path) public async Task SwitchPreviewAsync(string path) { // Close preview window is track selection setting is disabled - if (!isTrackSelectionSettingEnabled && !string.IsNullOrEmpty(CurrentPath)) + if (!IsTrackSelectionSettingEnabled && !string.IsNullOrEmpty(CurrentPath)) { await TogglePreviewPopupAsync(CurrentPath); return; @@ -52,15 +52,15 @@ public async Task DetectAvailability() return handle != IntPtr.Zero && handle.ToInt64() != -1; } - private bool? _isTrackSelectionSettingEnabledCache; - private bool isTrackSelectionSettingEnabled + private bool? _IsTrackSelectionSettingEnabledCache; + private bool IsTrackSelectionSettingEnabled { get { - if (_isTrackSelectionSettingEnabledCache is null) - _isTrackSelectionSettingEnabledCache = DetectTrackSelectionSetting().Result; + if (_IsTrackSelectionSettingEnabledCache is null) + _IsTrackSelectionSettingEnabledCache = DetectTrackSelectionSetting().Result; - return _isTrackSelectionSettingEnabledCache.Value; + return _IsTrackSelectionSettingEnabledCache.Value; } } From 28b7b33d8e5dac32ce6b1f1cd6bfb1c2b898ad33 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sat, 11 May 2024 22:52:36 -0400 Subject: [PATCH 05/10] Update SeerProProvider.cs --- .../Services/PreviewPopupProviders/SeerProProvider.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index 4132a1359cc1..9541e7bc63ac 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -1,6 +1,7 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. +using Microsoft.Win32; using System.IO; using System.Runtime.InteropServices; using Vanara.PInvoke; @@ -68,6 +69,12 @@ private Task DetectTrackSelectionSetting() { bool trackSelectedFile = true; + var keyName = @"\\HKEY_CURRENT_USER\\Software\\Corey\\Seer"; + var value = Registry.GetValue(keyName, "General", null); + + if (value is not null) + return Task.FromResult(true); + // List of possible paths for the Seer Pro settings file string[] paths = { From 51f9c6081da3ddf83aa2b1a0d900b870e4102812 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 12 May 2024 10:19:43 -0400 Subject: [PATCH 06/10] Update SeerProProvider.cs --- src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index 9541e7bc63ac..95538d4940a1 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -70,7 +70,7 @@ private Task DetectTrackSelectionSetting() bool trackSelectedFile = true; var keyName = @"\\HKEY_CURRENT_USER\\Software\\Corey\\Seer"; - var value = Registry.GetValue(keyName, "General", null); + var value = Registry.GetValue(keyName, "tracking_file", null); if (value is not null) return Task.FromResult(true); From 3c20e1868238c57af8443d3c0c144882ce9c968b Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 12 May 2024 10:20:13 -0400 Subject: [PATCH 07/10] Update SeerProProvider.cs --- src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index 95538d4940a1..38325602ef96 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -69,7 +69,7 @@ private Task DetectTrackSelectionSetting() { bool trackSelectedFile = true; - var keyName = @"\\HKEY_CURRENT_USER\\Software\\Corey\\Seer"; + var keyName = @"\HKEY_CURRENT_USER\Software\Corey\Seer"; var value = Registry.GetValue(keyName, "tracking_file", null); if (value is not null) From 2c2ee2bcf70db0c0f81d72ca378fbaeb65803908 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 12 May 2024 08:50:11 -0700 Subject: [PATCH 08/10] Update src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> --- src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index 38325602ef96..22c4258ec4e6 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -69,7 +69,7 @@ private Task DetectTrackSelectionSetting() { bool trackSelectedFile = true; - var keyName = @"\HKEY_CURRENT_USER\Software\Corey\Seer"; + var keyName = @"HKEY_CURRENT_USER\Software\Corey\Seer"; var value = Registry.GetValue(keyName, "tracking_file", null); if (value is not null) From 1115988f135b9d28a8b65dcf33dde5841cbc0bb8 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 12 May 2024 12:03:25 -0400 Subject: [PATCH 09/10] Update SeerProProvider.cs --- src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index 22c4258ec4e6..b76de2febe4f 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -72,7 +72,7 @@ private Task DetectTrackSelectionSetting() var keyName = @"HKEY_CURRENT_USER\Software\Corey\Seer"; var value = Registry.GetValue(keyName, "tracking_file", null); - if (value is not null) + if (value?.ToString() == "true") return Task.FromResult(true); // List of possible paths for the Seer Pro settings file From 82c0a573f935606e0dc99f5ffd0ce26e123c338e Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 12 May 2024 13:23:01 -0400 Subject: [PATCH 10/10] Update SeerProProvider.cs --- .../Services/PreviewPopupProviders/SeerProProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs index b76de2febe4f..91b8451d246f 100644 --- a/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs +++ b/src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs @@ -72,8 +72,8 @@ private Task DetectTrackSelectionSetting() var keyName = @"HKEY_CURRENT_USER\Software\Corey\Seer"; var value = Registry.GetValue(keyName, "tracking_file", null); - if (value?.ToString() == "true") - return Task.FromResult(true); + if (value?.ToString() == "false") + return Task.FromResult(false); // List of possible paths for the Seer Pro settings file string[] paths =