Skip to content

Commit

Permalink
Disabling powertoy only if it's explicitly off (#1888)
Browse files Browse the repository at this point in the history
* Disabling powertoy only if it's explicitly off
  • Loading branch information
yevhenii44-zz committed Apr 2, 2020
1 parent 5c01e0e commit cea5668
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/runner/general_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ void apply_general_settings(const json::JsonObject& general_configs)

void start_initial_powertoys()
{
bool only_enable_some_powertoys = false;

std::unordered_set<std::wstring> powertoys_to_enable;
std::unordered_set<std::wstring> powertoys_to_disable;

json::JsonObject general_settings;
try
Expand All @@ -210,34 +208,32 @@ void start_initial_powertoys()
if (general_settings.HasKey(L"enabled"))
{
json::JsonObject enabled = general_settings.GetNamedObject(L"enabled");
for (const auto& enabled_element : enabled)
for (const auto& disabled_element : enabled)
{
if (enabled_element.Value().GetBoolean())
if (!disabled_element.Value().GetBoolean())
{
// Enable this powertoy.
powertoys_to_enable.emplace(enabled_element.Key());
powertoys_to_disable.emplace(disabled_element.Key());
}
}
only_enable_some_powertoys = true;
}
}
catch (...)
catch (...) { }

if (powertoys_to_disable.empty())
{
only_enable_some_powertoys = false;
for (auto& [name, powertoy] : modules())
{
powertoy->enable();
}
}

for (auto& [name, powertoy] : modules())
else
{
if (only_enable_some_powertoys)
for (auto& [name, powertoy] : modules())
{
if (powertoys_to_enable.find(name) != powertoys_to_enable.end())
if (powertoys_to_disable.find(name) == powertoys_to_disable.end())
{
powertoy->enable();
}
}
else
{
powertoy->enable();
}
}
}

0 comments on commit cea5668

Please sign in to comment.