runner: simplify powertoy_module interface (#1560)

This commit is contained in:
Andrey Nekrasov
2020-03-13 12:55:15 +03:00
committed by GitHub
parent 4c1dfbaddd
commit 0ac6c01d65
10 changed files with 62 additions and 106 deletions

View File

@@ -37,3 +37,24 @@ json::JsonObject PowertoyModule::json_config() const
module->get_config(result.data(), &size);
return json::JsonObject::Parse(result);
}
PowertoyModule::PowertoyModule(PowertoyModuleIface* module, HMODULE handle) :
handle(handle), module(module)
{
if (!module)
{
throw std::runtime_error("Module not initialized");
}
auto want_signals = module->get_events();
if (want_signals)
{
for (; *want_signals; ++want_signals)
{
powertoys_events().register_receiver(*want_signals, module);
}
}
if (SystemMenuHelperInstace().HasCustomConfig(module))
{
powertoys_events().register_system_menu_action(module);
}
}