Repository: microsoft/PowerToys
File: src/runner/general_settings.cpp (C++)

Code before:
            }
            if (target_enabled)
            {
                Logger::info(L"apply_general_settings: Enabling powertoy {}", name);
                powertoy->enable();
            }
            else
            {
                Logger::info(L"apply_general_settings: Disabling powertoy {}", name);
                powertoy->disable();
            }
            // Sync the hotkey state with the module state, so it can be removed for disabled modules.
            powertoy.UpdateHotkeyEx();
        }
    }

    if (json::has(general_configs, L"theme", json::JsonValueType::String))
    {
        settings_theme = general_configs.GetNamedString(L"theme");
    }

    if (json::has(general_configs, L"show_tray_icon", json::JsonValueType::Boolean))
    {
        show_tray_icon = general_configs.GetNamedBoolean(L"show_tray_icon");
        // Update tray icon visibility when setting is toggled
        set_tray_icon_visible(!show_tray_icon);
    }

    if (save)
    {
        GeneralSettings save_settings = get_general_settings();
        PTSettingsHelper::save_general_settings(save_settings.to_json());
        Trace::SettingsChanged(save_settings);
    }
}

void start_enabled_powertoys()
{
    std::unordered_set<std::wstring> powertoys_to_disable;
    std::unordered_map<std::wstring, powertoys_gpo::gpo_rule_configured_t> powertoys_gpo_configuration;
    // Take into account default values supplied by modules themselves and gpo configurations
    for (auto& [name, powertoy] : modules())
    {
        auto gpo_rule = powertoy->gpo_policy_enabled_configuration();
        powertoys_gpo_configuration[name] = gpo_rule;
        if (gpo_rule == powertoys_gpo::gpo_rule_configured_unavailable)
        {
            Logger::warn(L"start_enabled_powertoys: couldn't read the gpo rule for Powertoy {}", name);
        }
        if (gpo_rule == powertoys_gpo::gpo_rule_configured_wrong_value)
        {

Review comment (suggestion):
```cpp
        // Update tray icon visibility when setting is toggled
        set_tray_icon_visible(show_tray_icon);
```

No longer needs to be inverted with the correction of the state change in `tray_icon.cpp`

Code after:
            }
            if (target_enabled)
            {
                Logger::info(L"apply_general_settings: Enabling powertoy {}", name);
                powertoy->enable();
            }
            else
            {
                Logger::info(L"apply_general_settings: Disabling powertoy {}", name);
                powertoy->disable();
            }
            // Sync the hotkey state with the module state, so it can be removed for disabled modules.
            powertoy.UpdateHotkeyEx();
        }
    }

    if (json::has(general_configs, L"theme", json::JsonValueType::String))
    {
        settings_theme = general_configs.GetNamedString(L"theme");
    }

    if (json::has(general_configs, L"show_tray_icon", json::JsonValueType::Boolean))
    {
        show_tray_icon = general_configs.GetNamedBoolean(L"show_tray_icon");
        // Update tray icon visibility when setting is toggled
        set_tray_icon_visible(show_tray_icon);
    }

    if (save)
    {
        GeneralSettings save_settings = get_general_settings();
        PTSettingsHelper::save_general_settings(save_settings.to_json());
        Trace::SettingsChanged(save_settings);
    }
}

void start_enabled_powertoys()
{
    std::unordered_set<std::wstring> powertoys_to_disable;
    std::unordered_map<std::wstring, powertoys_gpo::gpo_rule_configured_t> powertoys_gpo_configuration;
    // Take into account default values supplied by modules themselves and gpo configurations
    for (auto& [name, powertoy] : modules())
    {
        auto gpo_rule = powertoy->gpo_policy_enabled_configuration();
        powertoys_gpo_configuration[name] = gpo_rule;
        if (gpo_rule == powertoys_gpo::gpo_rule_configured_unavailable)
        {
            Logger::warn(L"start_enabled_powertoys: couldn't read the gpo rule for Powertoy {}", name);
        }
        if (gpo_rule == powertoys_gpo::gpo_rule_configured_wrong_value)
        {