mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-31 14:35:18 +00:00
[General]Add setting to disable elevated apps warning (#30628)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <common/notifications/notifications.h>
|
||||
#include <common/notifications/dont_show_again.h>
|
||||
#include <common/utils/resources.h>
|
||||
#include <common/SettingsAPI/settings_helpers.h>
|
||||
|
||||
#include "Generated Files/resource.h"
|
||||
|
||||
@@ -19,8 +20,11 @@ namespace notifications
|
||||
{
|
||||
using namespace NonLocalizable;
|
||||
|
||||
auto settings = PTSettingsHelper::load_general_settings();
|
||||
auto enableWarningsElevatedApps = settings.GetNamedBoolean(L"enable_warnings_elevated_apps", true);
|
||||
|
||||
static bool warning_shown = false;
|
||||
if (!warning_shown && !is_toast_disabled(ElevatedDontShowAgainRegistryPath, ElevatedDisableIntervalInDays))
|
||||
if (enableWarningsElevatedApps && !warning_shown && !is_toast_disabled(ElevatedDontShowAgainRegistryPath, ElevatedDisableIntervalInDays))
|
||||
{
|
||||
std::vector<action_t> actions = {
|
||||
link_button{ button1, RunAsAdminInfoPage },
|
||||
|
@@ -17,6 +17,7 @@ static std::wstring settings_theme = L"system";
|
||||
static bool run_as_elevated = false;
|
||||
static bool download_updates_automatically = true;
|
||||
static bool enable_experimentation = true;
|
||||
static bool enable_warnings_elevated_apps = true;
|
||||
|
||||
json::JsonObject GeneralSettings::to_json()
|
||||
{
|
||||
@@ -40,6 +41,7 @@ json::JsonObject GeneralSettings::to_json()
|
||||
result.SetNamedValue(L"download_updates_automatically", json::value(downloadUpdatesAutomatically));
|
||||
result.SetNamedValue(L"enable_experimentation", json::value(enableExperimentation));
|
||||
result.SetNamedValue(L"is_admin", json::value(isAdmin));
|
||||
result.SetNamedValue(L"enable_warnings_elevated_apps", json::value(enableWarningsElevatedApps));
|
||||
result.SetNamedValue(L"theme", json::value(theme));
|
||||
result.SetNamedValue(L"system_theme", json::value(systemTheme));
|
||||
result.SetNamedValue(L"powertoys_version", json::value(powerToysVersion));
|
||||
@@ -58,6 +60,7 @@ json::JsonObject load_general_settings()
|
||||
run_as_elevated = loaded.GetNamedBoolean(L"run_elevated", false);
|
||||
download_updates_automatically = loaded.GetNamedBoolean(L"download_updates_automatically", true) && check_user_is_admin();
|
||||
enable_experimentation = loaded.GetNamedBoolean(L"enable_experimentation",true);
|
||||
enable_warnings_elevated_apps = loaded.GetNamedBoolean(L"enable_warnings_elevated_apps", true);
|
||||
|
||||
return loaded;
|
||||
}
|
||||
@@ -69,6 +72,7 @@ GeneralSettings get_general_settings()
|
||||
.isElevated = is_process_elevated(),
|
||||
.isRunElevated = run_as_elevated,
|
||||
.isAdmin = is_user_admin,
|
||||
.enableWarningsElevatedApps = enable_warnings_elevated_apps,
|
||||
.downloadUpdatesAutomatically = download_updates_automatically && is_user_admin,
|
||||
.enableExperimentation = enable_experimentation,
|
||||
.theme = settings_theme,
|
||||
@@ -91,6 +95,8 @@ void apply_general_settings(const json::JsonObject& general_configs, bool save)
|
||||
Logger::info(L"apply_general_settings: {}", std::wstring{ general_configs.ToString() });
|
||||
run_as_elevated = general_configs.GetNamedBoolean(L"run_elevated", false);
|
||||
|
||||
enable_warnings_elevated_apps = general_configs.GetNamedBoolean(L"enable_warnings_elevated_apps", true);
|
||||
|
||||
download_updates_automatically = general_configs.GetNamedBoolean(L"download_updates_automatically", true);
|
||||
|
||||
enable_experimentation = general_configs.GetNamedBoolean(L"enable_experimentation", true);
|
||||
|
@@ -10,6 +10,7 @@ struct GeneralSettings
|
||||
bool isElevated;
|
||||
bool isRunElevated;
|
||||
bool isAdmin;
|
||||
bool enableWarningsElevatedApps;
|
||||
bool downloadUpdatesAutomatically;
|
||||
bool enableExperimentation;
|
||||
std::wstring theme;
|
||||
|
@@ -52,6 +52,7 @@ void Trace::SettingsChanged(const GeneralSettings& settings)
|
||||
g_hProvider,
|
||||
"GeneralSettingsChanged",
|
||||
TraceLoggingBoolean(settings.isStartupEnabled, "RunAtStartup"),
|
||||
TraceLoggingBoolean(settings.enableWarningsElevatedApps, "EnableWarningsElevatedApps"),
|
||||
TraceLoggingWideString(settings.startupDisabledReason.c_str(), "StartupDisabledReason"),
|
||||
TraceLoggingWideString(enabledModules.c_str(), "ModulesEnabled"),
|
||||
TraceLoggingBoolean(settings.isRunElevated, "AlwaysRunElevated"),
|
||||
|
@@ -29,6 +29,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
[JsonPropertyName("is_admin")]
|
||||
public bool IsAdmin { get; set; }
|
||||
|
||||
// Gets or sets a value indicating whether is warnings of elevated apps enabled.
|
||||
[JsonPropertyName("enable_warnings_elevated_apps")]
|
||||
public bool EnableWarningsElevatedApps { get; set; }
|
||||
|
||||
// Gets or sets theme Name.
|
||||
[JsonPropertyName("theme")]
|
||||
public string Theme { get; set; }
|
||||
@@ -57,6 +61,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
Startup = false;
|
||||
IsAdmin = false;
|
||||
EnableWarningsElevatedApps = true;
|
||||
IsElevated = false;
|
||||
AutoDownloadUpdates = false;
|
||||
EnableExperimentation = true;
|
||||
|
@@ -209,6 +209,9 @@
|
||||
</controls:SettingsCard>
|
||||
</controls:SettingsExpander.Items>
|
||||
</controls:SettingsExpander>
|
||||
<controls:SettingsCard x:Uid="GeneralPage_WarningsElevatedApps">
|
||||
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{Binding Mode=TwoWay, Path=EnableWarningsElevatedApps}" />
|
||||
</controls:SettingsCard>
|
||||
</custom:SettingsGroup>
|
||||
|
||||
<custom:SettingsGroup x:Uid="Appearance_Behavior" IsEnabled="True">
|
||||
|
@@ -1022,6 +1022,12 @@
|
||||
<data name="GeneralPage_RunAtStartUp.Description" xml:space="preserve">
|
||||
<value>PowerToys will launch automatically</value>
|
||||
</data>
|
||||
<data name="GeneralPage_WarningsElevatedApps.Header" xml:space="preserve">
|
||||
<value>Elevated Apps warnings </value>
|
||||
</data>
|
||||
<data name="GeneralPage_WarningsElevatedApps.Description" xml:space="preserve">
|
||||
<value>Show notifications about PowerToys functionality issues when running alongside elevated applications.</value>
|
||||
</data>
|
||||
<data name="PowerRename.ModuleDescription" xml:space="preserve">
|
||||
<value>A Windows Shell extension for more advanced bulk renaming using search & replace or regular expressions.</value>
|
||||
</data>
|
||||
|
@@ -126,6 +126,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
_isElevated = isElevated;
|
||||
_runElevated = GeneralSettingsConfig.RunElevated;
|
||||
_enableWarningsElevatedApps = GeneralSettingsConfig.EnableWarningsElevatedApps;
|
||||
|
||||
RunningAsUserDefaultText = runAsUserText;
|
||||
RunningAsAdminDefaultText = runAsAdminText;
|
||||
@@ -150,6 +151,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
private bool _isElevated;
|
||||
private bool _runElevated;
|
||||
private bool _isAdmin;
|
||||
private bool _enableWarningsElevatedApps;
|
||||
private int _themeIndex;
|
||||
|
||||
private bool _autoDownloadUpdates;
|
||||
@@ -270,6 +272,24 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableWarningsElevatedApps
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enableWarningsElevatedApps;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_enableWarningsElevatedApps != value)
|
||||
{
|
||||
_enableWarningsElevatedApps = value;
|
||||
GeneralSettingsConfig.EnableWarningsElevatedApps = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Are we running a dev build? (Please note that we verify this in the code that gets the newest version from GitHub too.)
|
||||
public static bool AutoUpdatesDisabledOnDevBuild
|
||||
{
|
||||
|
Reference in New Issue
Block a user