[Settings] 'Check for updates' button behavior changed (#4385)

This commit is contained in:
Seraphima Zykova
2020-06-23 15:53:02 +03:00
committed by GitHub
parent 87f0fcfd52
commit 5c1999b3d0
18 changed files with 460 additions and 87 deletions

View File

@@ -11,6 +11,7 @@
#include "common/windows_colors.h"
#include "common/common.h"
#include "restart_elevated.h"
#include "update_utils.h"
#include <common/json.h>
#include <common\settings_helpers.cpp>
@@ -56,15 +57,32 @@ void dispatch_json_action_to_module(const json::JsonObject& powertoys_configs)
// so it has to be the "restart as (non-)elevated" button.
if (name == L"general")
{
if (is_process_elevated())
try
{
schedule_restart_as_non_elevated();
PostQuitMessage(0);
const auto value = powertoy_element.Value().GetObjectW();
const auto action = value.GetNamedString(L"action_name");
if (action == L"restart_elevation")
{
if (is_process_elevated())
{
schedule_restart_as_non_elevated();
PostQuitMessage(0);
}
else
{
schedule_restart_as_elevated();
PostQuitMessage(0);
}
}
else if (action == L"check_for_updates")
{
std::thread{ [] {
check_for_updates();
} }.detach();
}
}
else
catch (...)
{
schedule_restart_as_elevated();
PostQuitMessage(0);
}
}
else if (modules().find(name) != modules().end())