OS Detection and setting the old or new settings UI page accordingly (#2674)

* Added code to detect os build number

* To set the settings.exe according to the powerToys version that is running

* Modified the description of old UI for launcher and keyboard remapper

* Using API contracts instead of registry

* Removing file that was included by mistake
This commit is contained in:
Alekhya 2020-05-05 15:53:30 -07:00 committed by GitHub
parent c2adf56b2f
commit 1a29870958
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 15 deletions

View File

@ -5,7 +5,7 @@
STRINGTABLE
BEGIN
IDS_SETTINGS_DESCRIPTION L"Customize your experience by remapping keys or creating new shortcuts!"
IDS_SETTINGS_DESCRIPTION L"This feature requires Windows 10, May 2019 Update"
IDS_KEYBOARDMANAGER L"Keyboard Manager"
END

View File

@ -1,15 +1,14 @@
#include "resource.h"
#include "../../../common/version.h"
<EFBFBD>
匀吀刀䤀一䜀吀䄀䈀䰀䔀ഀ<EFBFBD>
䈀䔀䜀䤀一ഀ<EFBFBD>
IDS_LAUNCHER_NAME L"Run"
IDS_LAUNCHER_SETTINGS_DESC L"<No description>"
IDS_LAUNCHER_NAME L"Launcher"
IDS_LAUNCHER_SETTINGS_DESC L"This feature requires Windows 10, May 2019 Update"
䔀一䐀ഀ<EFBFBD>
<EFBFBD>
 嘀䔀刀匀䤀伀一䤀一䘀伀ഀ<EFBFBD>
FILEVERSION FILE_VERSION
PRODUCTVERSION PRODUCT_VERSION
FILEVERSION 0,1,0,0
PRODUCTVERSION 0,1,0,0
 䘀䤀䰀䔀䘀䰀䄀䜀匀䴀䄀匀䬀  砀㌀昀䰀ഀ<EFBFBD>
⌀椀昀搀攀昀 开䐀䔀䈀唀䜀ഀ<EFBFBD>
 䘀䤀䰀䔀䘀䰀䄀䜀匀  砀㄀䰀ഀ<EFBFBD>
@ -24,14 +23,14 @@
    䈀䔀䜀䤀一ഀ<EFBFBD>
        䈀䰀伀䌀䬀    㐀戀 ∀ഀ<EFBFBD>
        䈀䔀䜀䤀一ഀ<EFBFBD>
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", "Microsoft.Launcher Module"
VALUE "FileVersion", FILE_VERSION_STRING
VALUE "InternalName", "Microsoft.Launcher"
VALUE "LegalCopyright", COPYRIGHT_NOTE
VALUE "OriginalFilename", "Microsoft.Launcher.dll"
VALUE "ProductName", "Microsoft.Launcher"
VALUE "ProductVersion", PRODUCT_VERSION_STRING
VALUE "CompanyName", "Company Name"
VALUE "FileDescription", "Wox.Launcher Module"
VALUE "FileVersion", "0.1.0.0"
VALUE "InternalName", "Wox.Launcher"
VALUE "LegalCopyright", "Copyright (C) 2019 Company Name"
VALUE "OriginalFilename", "Wox.Launcher.dll"
VALUE "ProductName", "Wox.Launcher"
VALUE "ProductVersion", "0.1.0.0"
        䔀一䐀ഀ<EFBFBD>
    䔀一䐀ഀ<EFBFBD>
    䈀䰀伀䌀䬀 ∀嘀愀爀䘀椀氀攀䤀渀昀漀∀ഀ<EFBFBD>

View File

@ -27,4 +27,5 @@
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.Foundation.Metadata.h>
#include <wil/resource.h>

View File

@ -207,6 +207,41 @@ BOOL run_settings_non_elevated(LPCWSTR executable_path, LPWSTR executable_args,
return process_created;
}
// The following three helper functions determine if the user has a build version higher than or equal to 19h1, as that is a requirement for xaml islands
// Source : Microsoft-ui-xaml github
// Link: https://github.com/microsoft/microsoft-ui-xaml/blob/c045cde57c5c754683d674634a0baccda34d58c4/dev/dll/SharedHelpers.cpp
template<uint16_t APIVersion> bool IsAPIContractVxAvailable()
{
static bool isAPIContractVxAvailableInitialized = false;
static bool isAPIContractVxAvailable = false;
if (!isAPIContractVxAvailableInitialized)
{
isAPIContractVxAvailableInitialized = true;
isAPIContractVxAvailable = winrt::Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent(L"Windows.Foundation.UniversalApiContract", APIVersion);
}
return isAPIContractVxAvailable;
}
bool IsAPIContractV8Available()
{
return IsAPIContractVxAvailable<8>();
}
bool Is19H1OrHigher()
{
return IsAPIContractV8Available();
}
// This function returns true if the build is 19h1 or higher, so that we deploy the new settings.
// It returns false otherwise.
bool use_new_settings()
{
return Is19H1OrHigher();
}
DWORD g_settings_process_id = 0;
void run_settings_window()
@ -223,7 +258,15 @@ void run_settings_window()
// Arg 1: executable path.
std::wstring executable_path = get_module_folderpath();
executable_path.append(L"\\SettingsUIRunner\\Microsoft.PowerToys.Settings.UI.Runner.exe");
if (use_new_settings())
{
executable_path.append(L"\\SettingsUIRunner\\Microsoft.PowerToys.Settings.UI.Runner.exe");
}
else
{
executable_path.append(L"\\PowerToysSettings.exe");
}
// Arg 2: pipe server. Generate unique names for the pipes, if getting a UUID is possible.
std::wstring powertoys_pipe_name(L"\\\\.\\pipe\\powertoys_runner_");