2019-09-05 00:26:26 +08:00
|
|
|
#pragma once
|
|
|
|
#include <interface/powertoy_module_interface.h>
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <vector>
|
|
|
|
#include <functional>
|
|
|
|
|
2020-12-15 20:16:09 +08:00
|
|
|
#include <common/utils/json.h>
|
2019-09-05 00:26:26 +08:00
|
|
|
|
2019-12-27 00:26:11 +08:00
|
|
|
struct PowertoyModuleDeleter
|
|
|
|
{
|
2021-01-09 02:26:38 +08:00
|
|
|
void operator()(PowertoyModuleIface* pt_module) const
|
2019-12-27 00:26:11 +08:00
|
|
|
{
|
2021-01-09 02:26:38 +08:00
|
|
|
if (pt_module)
|
2019-12-27 00:26:11 +08:00
|
|
|
{
|
2021-01-09 02:26:38 +08:00
|
|
|
pt_module->destroy();
|
2019-12-27 00:26:11 +08:00
|
|
|
}
|
2019-09-05 00:26:26 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-27 00:26:11 +08:00
|
|
|
struct PowertoyModuleDLLDeleter
|
|
|
|
{
|
|
|
|
using pointer = HMODULE;
|
|
|
|
void operator()(HMODULE handle) const
|
|
|
|
{
|
|
|
|
FreeLibrary(handle);
|
|
|
|
}
|
2019-09-05 00:26:26 +08:00
|
|
|
};
|
|
|
|
|
2019-12-27 00:26:11 +08:00
|
|
|
class PowertoyModule
|
|
|
|
{
|
2019-09-05 00:26:26 +08:00
|
|
|
public:
|
2021-01-09 02:26:38 +08:00
|
|
|
PowertoyModule(PowertoyModuleIface* pt_module, HMODULE handle);
|
2019-12-27 00:26:11 +08:00
|
|
|
|
2020-03-13 17:55:15 +08:00
|
|
|
inline PowertoyModuleIface* operator->()
|
2019-12-27 00:26:11 +08:00
|
|
|
{
|
2021-01-09 02:26:38 +08:00
|
|
|
return pt_module.get();
|
2019-09-05 00:26:26 +08:00
|
|
|
}
|
2019-12-27 00:26:11 +08:00
|
|
|
|
|
|
|
json::JsonObject json_config() const;
|
|
|
|
|
2020-09-21 18:44:16 +08:00
|
|
|
void update_hotkeys();
|
|
|
|
|
2021-05-20 20:07:34 +08:00
|
|
|
void UpdateHotkeyEx();
|
|
|
|
|
2019-09-05 00:26:26 +08:00
|
|
|
private:
|
2019-12-27 00:26:11 +08:00
|
|
|
std::unique_ptr<HMODULE, PowertoyModuleDLLDeleter> handle;
|
2021-01-09 02:26:38 +08:00
|
|
|
std::unique_ptr<PowertoyModuleIface, PowertoyModuleDeleter> pt_module;
|
2019-09-05 00:26:26 +08:00
|
|
|
};
|
|
|
|
|
2020-06-22 18:01:33 +08:00
|
|
|
PowertoyModule load_powertoy(const std::wstring_view filename);
|
2020-03-26 18:51:05 +08:00
|
|
|
std::map<std::wstring, PowertoyModule>& modules();
|