2023-12-28 13:33:04 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <common/notifications/notifications.h>
|
|
|
|
|
#include <common/notifications/dont_show_again.h>
|
|
|
|
|
#include <common/utils/resources.h>
|
2024-01-03 20:22:54 +03:00
|
|
|
#include <common/SettingsAPI/settings_helpers.h>
|
2023-12-28 13:33:04 +03:00
|
|
|
|
|
|
|
|
#include "Generated Files/resource.h"
|
|
|
|
|
|
|
|
|
|
namespace notifications
|
|
|
|
|
{
|
|
|
|
|
// Non-Localizable strings
|
|
|
|
|
namespace NonLocalizable
|
|
|
|
|
{
|
|
|
|
|
const wchar_t RunAsAdminInfoPage[] = L"https://aka.ms/powertoysDetectedElevatedHelp";
|
|
|
|
|
const wchar_t ToastNotificationButtonUrl[] = L"powertoys://cant_drag_elevated_disable/";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void WarnIfElevationIsRequired(std::wstring title, std::wstring message, std::wstring button1, std::wstring button2)
|
|
|
|
|
{
|
|
|
|
|
using namespace NonLocalizable;
|
|
|
|
|
|
2024-01-03 20:22:54 +03:00
|
|
|
auto settings = PTSettingsHelper::load_general_settings();
|
|
|
|
|
auto enableWarningsElevatedApps = settings.GetNamedBoolean(L"enable_warnings_elevated_apps", true);
|
|
|
|
|
|
2023-12-28 13:33:04 +03:00
|
|
|
static bool warning_shown = false;
|
2024-01-03 20:22:54 +03:00
|
|
|
if (enableWarningsElevatedApps && !warning_shown && !is_toast_disabled(ElevatedDontShowAgainRegistryPath, ElevatedDisableIntervalInDays))
|
2023-12-28 13:33:04 +03:00
|
|
|
{
|
|
|
|
|
std::vector<action_t> actions = {
|
|
|
|
|
link_button{ button1, RunAsAdminInfoPage },
|
|
|
|
|
link_button{ button2, ToastNotificationButtonUrl }
|
|
|
|
|
};
|
|
|
|
|
show_toast_with_activations(message,
|
|
|
|
|
title,
|
|
|
|
|
{},
|
|
|
|
|
std::move(actions));
|
|
|
|
|
warning_shown = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|