Skip to content

Commit f37d4c4

Browse files
authored
Release 2.0.2 | Plugin 5.1.0 (#4046)
1 parent a05e099 commit f37d4c4

File tree

167 files changed

+1483
-869
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1483
-869
lines changed

Flow.Launcher.Infrastructure/NativeMethods.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,10 @@ QueryFullProcessImageName
8585
EVENT_OBJECT_HIDE
8686
EVENT_SYSTEM_DIALOGEND
8787

88+
DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS
8889
WM_POWERBROADCAST
89-
PBT_APMRESUMEAUTOMATIC
90+
PBT_APMRESUMEAUTOMATIC
91+
PBT_APMRESUMESUSPEND
92+
PowerRegisterSuspendResumeNotification
93+
PowerUnregisterSuspendResumeNotification
94+
DeviceNotifyCallbackRoutine

Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public static class DataLocation
77
{
88
public const string PortableFolderName = "UserData";
99
public const string DeletionIndicatorFile = ".dead";
10-
public static string PortableDataPath = Path.Combine(Constant.ProgramDirectory, PortableFolderName);
11-
public static string RoamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlowLauncher");
10+
public static readonly string PortableDataPath = Path.Combine(Constant.ProgramDirectory, PortableFolderName);
11+
public static readonly string RoamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlowLauncher");
1212
public static string DataDirectory()
1313
{
1414
if (PortableDataLocationInUse())
@@ -19,7 +19,8 @@ public static string DataDirectory()
1919

2020
public static bool PortableDataLocationInUse()
2121
{
22-
if (Directory.Exists(PortableDataPath) && !File.Exists(DeletionIndicatorFile))
22+
if (Directory.Exists(PortableDataPath) &&
23+
!File.Exists(Path.Combine(PortableDataPath, DeletionIndicatorFile)))
2324
return true;
2425

2526
return false;

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Windows.Win32;
2020
using Windows.Win32.Foundation;
2121
using Windows.Win32.Graphics.Dwm;
22+
using Windows.Win32.System.Power;
2223
using Windows.Win32.System.Threading;
2324
using Windows.Win32.UI.Input.KeyboardAndMouse;
2425
using Windows.Win32.UI.Shell.Common;
@@ -338,9 +339,6 @@ public static Point TransformPixelsToDIP(Visual visual, double unitX, double uni
338339
public const int SC_MAXIMIZE = (int)PInvoke.SC_MAXIMIZE;
339340
public const int SC_MINIMIZE = (int)PInvoke.SC_MINIMIZE;
340341

341-
public const int WM_POWERBROADCAST = (int)PInvoke.WM_POWERBROADCAST;
342-
public const int PBT_APMRESUMEAUTOMATIC = (int)PInvoke.PBT_APMRESUMEAUTOMATIC;
343-
344342
#endregion
345343

346344
#region Window Handle
@@ -918,5 +916,105 @@ public static string SelectFile()
918916
}
919917

920918
#endregion
919+
920+
#region Sleep Mode Listener
921+
922+
private static Action _func;
923+
private static PDEVICE_NOTIFY_CALLBACK_ROUTINE _callback = null;
924+
private static DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS _recipient;
925+
private static SafeHandle _recipientHandle;
926+
private static HPOWERNOTIFY _handle = HPOWERNOTIFY.Null;
927+
928+
/// <summary>
929+
/// Registers a listener for sleep mode events.
930+
/// Inspired from: https://github.com/XKaguya/LenovoLegionToolkit
931+
/// https://blog.csdn.net/mochounv/article/details/114668594
932+
/// </summary>
933+
/// <param name="func"></param>
934+
/// <exception cref="Win32Exception"></exception>
935+
public static unsafe void RegisterSleepModeListener(Action func)
936+
{
937+
if (_callback != null)
938+
{
939+
// Only register if not already registered
940+
return;
941+
}
942+
943+
_func = func;
944+
_callback = new PDEVICE_NOTIFY_CALLBACK_ROUTINE(DeviceNotifyCallback);
945+
_recipient = new DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS()
946+
{
947+
Callback = _callback,
948+
Context = null
949+
};
950+
951+
_recipientHandle = new StructSafeHandle<DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS>(_recipient);
952+
_handle = PInvoke.PowerRegisterSuspendResumeNotification(
953+
REGISTER_NOTIFICATION_FLAGS.DEVICE_NOTIFY_CALLBACK,
954+
_recipientHandle,
955+
out var handle) == WIN32_ERROR.ERROR_SUCCESS ?
956+
new HPOWERNOTIFY(new IntPtr(handle)) :
957+
HPOWERNOTIFY.Null;
958+
if (_handle.IsNull)
959+
{
960+
throw new Win32Exception("Error registering for power notifications: " + Marshal.GetLastWin32Error());
961+
}
962+
}
963+
964+
/// <summary>
965+
/// Unregisters the sleep mode listener.
966+
/// </summary>
967+
public static void UnregisterSleepModeListener()
968+
{
969+
if (!_handle.IsNull)
970+
{
971+
PInvoke.PowerUnregisterSuspendResumeNotification(_handle);
972+
_handle = HPOWERNOTIFY.Null;
973+
_func = null;
974+
_callback = null;
975+
_recipientHandle = null;
976+
}
977+
}
978+
979+
private static unsafe uint DeviceNotifyCallback(void* context, uint type, void* setting)
980+
{
981+
switch (type)
982+
{
983+
case PInvoke.PBT_APMRESUMEAUTOMATIC:
984+
// Operation is resuming automatically from a low-power state.This message is sent every time the system resumes
985+
_func?.Invoke();
986+
break;
987+
988+
case PInvoke.PBT_APMRESUMESUSPEND:
989+
// Operation is resuming from a low-power state.This message is sent after PBT_APMRESUMEAUTOMATIC if the resume is triggered by user input, such as pressing a key
990+
_func?.Invoke();
991+
break;
992+
}
993+
994+
return 0;
995+
}
996+
997+
private sealed class StructSafeHandle<T> : SafeHandle where T : struct
998+
{
999+
private readonly nint _ptr = nint.Zero;
1000+
1001+
public StructSafeHandle(T recipient) : base(nint.Zero, true)
1002+
{
1003+
var pRecipient = Marshal.AllocHGlobal(Marshal.SizeOf<T>());
1004+
Marshal.StructureToPtr(recipient, pRecipient, false);
1005+
SetHandle(pRecipient);
1006+
_ptr = pRecipient;
1007+
}
1008+
1009+
public override bool IsInvalid => handle == nint.Zero;
1010+
1011+
protected override bool ReleaseHandle()
1012+
{
1013+
Marshal.FreeHGlobal(_ptr);
1014+
return true;
1015+
}
1016+
}
1017+
1018+
#endregion
9211019
}
9221020
}

Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
</PropertyGroup>
1616

1717
<PropertyGroup>
18-
<Version>5.0.0</Version>
19-
<PackageVersion>5.0.0</PackageVersion>
20-
<AssemblyVersion>5.0.0</AssemblyVersion>
21-
<FileVersion>5.0.0</FileVersion>
18+
<Version>5.1.0</Version>
19+
<PackageVersion>5.1.0</PackageVersion>
20+
<AssemblyVersion>5.1.0</AssemblyVersion>
21+
<FileVersion>5.1.0</FileVersion>
2222
<PackageId>Flow.Launcher.Plugin</PackageId>
2323
<Authors>Flow-Launcher</Authors>
2424
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ public static bool FileExists(this string filePath)
150150
return File.Exists(filePath);
151151
}
152152

153+
/// <summary>
154+
/// Checks if a file or directory exists
155+
/// </summary>
156+
/// <param name="path"></param>
157+
/// <returns></returns>
158+
public static bool FileOrLocationExists(this string path)
159+
{
160+
return LocationExists(path) || FileExists(path);
161+
}
162+
153163
/// <summary>
154164
/// Open a directory window (using the OS's default handler, usually explorer)
155165
/// </summary>

Flow.Launcher/Languages/ar.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@
214214
<system:String x:Key="plugin_query_version">الإصدار</system:String>
215215
<system:String x:Key="plugin_query_web">الموقع الإلكتروني</system:String>
216216
<system:String x:Key="plugin_uninstall">إلغاء التثبيت</system:String>
217+
<system:String x:Key="plugin_default_search_delay_time">Search delay time: default</system:String>
218+
<system:String x:Key="plugin_search_delay_time">Search delay time: {0}ms</system:String>
217219
<system:String x:Key="failedToRemovePluginSettingsTitle">Fail to remove plugin settings</system:String>
218220
<system:String x:Key="failedToRemovePluginSettingsMessage">Plugins: {0} - Fail to remove plugin settings files, please remove them manually</system:String>
219221
<system:String x:Key="failedToRemovePluginCacheTitle">Fail to remove plugin cache</system:String>
@@ -595,8 +597,9 @@
595597
The specified file manager could not be found. Please check the Custom File Manager setting under Settings &gt; General.
596598
</system:String>
597599
<system:String x:Key="errorTitle">خطأ</system:String>
598-
<system:String x:Key="folderOpenError">An error occurred while opening the folder. {0}</system:String>
600+
<system:String x:Key="folderOpenError">An error occurred while opening the folder.</system:String>
599601
<system:String x:Key="browserOpenError">An error occurred while opening the URL in the browser. Please check your Default Web Browser configuration in the General section of the settings window</system:String>
602+
<system:String x:Key="fileNotFoundError">File or directory not found: {0}</system:String>
600603

601604
<!-- General Notice -->
602605
<system:String x:Key="pleaseWait">يرجى الانتظار...</system:String>

Flow.Launcher/Languages/cs.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@
214214
<system:String x:Key="plugin_query_version">Verze</system:String>
215215
<system:String x:Key="plugin_query_web">Webová stránka</system:String>
216216
<system:String x:Key="plugin_uninstall">Odinstalovat</system:String>
217+
<system:String x:Key="plugin_default_search_delay_time">Search delay time: default</system:String>
218+
<system:String x:Key="plugin_search_delay_time">Search delay time: {0}ms</system:String>
217219
<system:String x:Key="failedToRemovePluginSettingsTitle">Fail to remove plugin settings</system:String>
218220
<system:String x:Key="failedToRemovePluginSettingsMessage">Plugins: {0} - Fail to remove plugin settings files, please remove them manually</system:String>
219221
<system:String x:Key="failedToRemovePluginCacheTitle">Fail to remove plugin cache</system:String>
@@ -595,8 +597,9 @@ Pokud před zkratku při zadávání přidáte znak &quot;@&quot;, bude odpovíd
595597
The specified file manager could not be found. Please check the Custom File Manager setting under Settings &gt; General.
596598
</system:String>
597599
<system:String x:Key="errorTitle">Chyba</system:String>
598-
<system:String x:Key="folderOpenError">An error occurred while opening the folder. {0}</system:String>
600+
<system:String x:Key="folderOpenError">An error occurred while opening the folder.</system:String>
599601
<system:String x:Key="browserOpenError">An error occurred while opening the URL in the browser. Please check your Default Web Browser configuration in the General section of the settings window</system:String>
602+
<system:String x:Key="fileNotFoundError">File or directory not found: {0}</system:String>
600603

601604
<!-- General Notice -->
602605
<system:String x:Key="pleaseWait">Počkejte prosím...</system:String>

Flow.Launcher/Languages/da.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@
214214
<system:String x:Key="plugin_query_version">Version</system:String>
215215
<system:String x:Key="plugin_query_web">Hjemmeside</system:String>
216216
<system:String x:Key="plugin_uninstall">Uninstall</system:String>
217+
<system:String x:Key="plugin_default_search_delay_time">Search delay time: default</system:String>
218+
<system:String x:Key="plugin_search_delay_time">Search delay time: {0}ms</system:String>
217219
<system:String x:Key="failedToRemovePluginSettingsTitle">Fail to remove plugin settings</system:String>
218220
<system:String x:Key="failedToRemovePluginSettingsMessage">Plugins: {0} - Fail to remove plugin settings files, please remove them manually</system:String>
219221
<system:String x:Key="failedToRemovePluginCacheTitle">Fail to remove plugin cache</system:String>
@@ -595,8 +597,9 @@ If you add an '@' prefix while inputting a shortcut, it matches any position in
595597
The specified file manager could not be found. Please check the Custom File Manager setting under Settings &gt; General.
596598
</system:String>
597599
<system:String x:Key="errorTitle">Error</system:String>
598-
<system:String x:Key="folderOpenError">An error occurred while opening the folder. {0}</system:String>
600+
<system:String x:Key="folderOpenError">An error occurred while opening the folder.</system:String>
599601
<system:String x:Key="browserOpenError">An error occurred while opening the URL in the browser. Please check your Default Web Browser configuration in the General section of the settings window</system:String>
602+
<system:String x:Key="fileNotFoundError">File or directory not found: {0}</system:String>
600603

601604
<!-- General Notice -->
602605
<system:String x:Key="pleaseWait">Please wait...</system:String>

Flow.Launcher/Languages/de.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@
214214
<system:String x:Key="plugin_query_version">Version</system:String>
215215
<system:String x:Key="plugin_query_web">Website</system:String>
216216
<system:String x:Key="plugin_uninstall">Deinstallieren</system:String>
217+
<system:String x:Key="plugin_default_search_delay_time">Search delay time: default</system:String>
218+
<system:String x:Key="plugin_search_delay_time">Search delay time: {0}ms</system:String>
217219
<system:String x:Key="failedToRemovePluginSettingsTitle">Plug-in-Einstellungen können nicht entfernt werden</system:String>
218220
<system:String x:Key="failedToRemovePluginSettingsMessage">Plug-ins: {0} - Plug-in-Einstellungsdateien können nicht entfernt werden, bitte entfernen Sie diese manuell</system:String>
219221
<system:String x:Key="failedToRemovePluginCacheTitle">Plug-in-Cache kann nicht entfernt werden</system:String>
@@ -595,8 +597,9 @@ Wenn Sie bei der Eingabe eines Shortcuts ein '@'-Präfix hinzufügen, stimmt die
595597
Der spezifizierte Dateimanager konnte nicht gefunden werden. Bitte überprüfen Sie die Einstellung des benutzerdefinierten Dateimanagers unter Einstellungen &gt; Allgemein.
596598
</system:String>
597599
<system:String x:Key="errorTitle">Fehler</system:String>
598-
<system:String x:Key="folderOpenError">Beim Öffnen des Ordners ist ein Fehler aufgetreten. {0}</system:String>
600+
<system:String x:Key="folderOpenError">An error occurred while opening the folder.</system:String>
599601
<system:String x:Key="browserOpenError">Beim Öffnen der URL im Browser ist ein Fehler aufgetreten. Bitte überprüfen Sie die Konfiguration Ihres Default-Webbrowsers im Abschnitt „Allgemein“ des Einstellungsfensters</system:String>
602+
<system:String x:Key="fileNotFoundError">File or directory not found: {0}</system:String>
600603

601604
<!-- General Notice -->
602605
<system:String x:Key="pleaseWait">Bitte warten Sie ...</system:String>

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@
587587
<system:String x:Key="errorTitle">Error</system:String>
588588
<system:String x:Key="folderOpenError">An error occurred while opening the folder. {0}</system:String>
589589
<system:String x:Key="browserOpenError">An error occurred while opening the URL in the browser. Please check your Default Web Browser configuration in the General section of the settings window</system:String>
590+
<system:String x:Key="fileNotFoundError">File or directory not found: {0}</system:String>
590591

591592
<!-- General Notice -->
592593
<system:String x:Key="pleaseWait">Please wait...</system:String>

0 commit comments

Comments
 (0)