[TextExtractor]Disable by default and warning to use Snipping Tool on Win11 (#29839)

* [TextExtractor] default enabled until Win10 + infobar in Settings page

* Fixing severity

* Fixing warning text

* Use the Windows 11 detection from Common.UI
This commit is contained in:
Laszlo Nemeth
2023-11-20 16:49:24 +01:00
committed by GitHub
parent d7f0d0e5c1
commit 5e666556f4
4 changed files with 23 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
#include <common/interop/shared_constants.h> #include <common/interop/shared_constants.h>
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
#include <common/utils/winapi_error.h> #include <common/utils/winapi_error.h>
#include <common/utils/package.h>
BOOL APIENTRY DllMain(HMODULE /*hModule*/, BOOL APIENTRY DllMain(HMODULE /*hModule*/,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
@@ -293,6 +294,13 @@ public:
{ {
return m_enabled; return m_enabled;
} }
// Returns whether the PowerToys should be enabled by default
virtual bool is_enabled_by_default() const override
{
// disabled by default for Windows 11 and enabled by default on Windows 10
return !package::IsWin11OrGreater();
}
}; };
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()

View File

@@ -22,6 +22,12 @@
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabledGpoConfigured, Converter={StaticResource BoolNegationConverter}}"> IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabledGpoConfigured, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.IsEnabled, Mode=TwoWay}" /> <ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.IsEnabled, Mode=TwoWay}" />
</controls:SettingsCard> </controls:SettingsCard>
<InfoBar
x:Uid="TextExtractor_UseSnippingToolWarning"
IsClosable="False"
IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.IsWin11OrGreater}"
IsTabStop="{x:Bind Mode=OneWay, Path=ViewModel.IsWin11OrGreater}"
Severity="Informational" />
<InfoBar <InfoBar
x:Uid="GPO_IsSettingForced" x:Uid="GPO_IsSettingForced"
IsClosable="False" IsClosable="False"

View File

@@ -3249,6 +3249,9 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="TextExtractor_SupportedLanguages.Title" xml:space="preserve"> <data name="TextExtractor_SupportedLanguages.Title" xml:space="preserve">
<value>Text Extractor can only recognize languages that have the OCR pack installed.</value> <value>Text Extractor can only recognize languages that have the OCR pack installed.</value>
</data> </data>
<data name="TextExtractor_UseSnippingToolWarning.Title" xml:space="preserve">
<value>It is recommended to use the Snipping Tool instead of the TextExtractor module.</value>
</data>
<data name="TextExtractor_SupportedLanguages_Link.Content" xml:space="preserve"> <data name="TextExtractor_SupportedLanguages_Link.Content" xml:space="preserve">
<value>Learn more about supported languages</value> <value>Learn more about supported languages</value>
</data> </data>

View File

@@ -9,6 +9,7 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Timers; using System.Timers;
using Common.UI;
using global::PowerToys.GPOWrapper; using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
@@ -146,6 +147,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
} }
} }
public bool IsWin11OrGreater
{
get => OSVersionHelper.IsWindows11();
}
public bool IsEnabledGpoConfigured public bool IsEnabledGpoConfigured
{ {
get => _enabledStateIsGPOConfigured; get => _enabledStateIsGPOConfigured;