Integrate keyboard manager with settings v2[Part-2] (#2107)

* Added CustomAction Data Models

* Updated data model

* Updated Button command trigger for keyboard manager

* Integerated custom actions in Keyboard manager module backend

* Allow Runner to launch windows on foreground

* Refactor and moved the execution logic to background thread

* Removed non-required unlock calls

* Fixed typo

* Resolve PR comments
This commit is contained in:
udit3333
2020-04-14 09:24:11 -07:00
committed by GitHub
parent 79fcd45d5f
commit a88d66b48b
13 changed files with 292 additions and 40 deletions

View File

@@ -5,7 +5,8 @@
#include <common/settings_objects.h>
#include "trace.h"
#include "resource.h"
#include <keyboardmanager/ui/MainWindow.h>
#include <keyboardmanager/ui/EditKeyboardWindow.h>
#include <keyboardmanager/ui/EditShortcutsWindow.h>
#include <keyboardmanager/common/KeyboardManagerState.h>
#include <keyboardmanager/common/Shortcut.h>
#include <keyboardmanager/common/RemapShortcut.h>
@@ -149,10 +150,22 @@ public:
// Parse the action values, including name.
PowerToysSettings::CustomActionObject action_object =
PowerToysSettings::CustomActionObject::from_json_string(action);
HINSTANCE hInstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
//if (action_object.get_name() == L"custom_action_id") {
// // Execute your custom action
//}
if (action_object.get_name() == L"RemapKeyboard")
{
if (!CheckEditKeyboardWindowActive())
{
std::thread(createEditKeyboardWindow, hInstance, std::ref(keyboardManagerState)).detach();
}
}
else if (action_object.get_name() == L"EditShortcut")
{
if (!CheckEditShortcutsWindowActive())
{
std::thread(createEditShortcutsWindow, hInstance, std::ref(keyboardManagerState)).detach();
}
}
}
catch (std::exception&)
{
@@ -183,8 +196,6 @@ public:
virtual void enable()
{
m_enabled = true;
HINSTANCE hInstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
std::thread(createMainWindow, hInstance, std::ref(keyboardManagerState)).detach();
start_lowlevel_keyboard_hook();
}