[Kbm] Save the remaps to file[part-1] (#2184)

* Added Inital FileWatcher Implementation

* Added logic to read remap from file

* Added remap logic save to file

* Refactor code

* Moved the strings to constant file

* Added logic to handle Win key

* Updated filewatcher logic to avoid duplicate events

* Added comments

* Fix spacing

* Fix spacing

* Update logic to accomodate upstream merge

* Added global property name for os level shortcuts

* Added subkey for inprocess keys

* Remove non required file

* Added Changes required after merge

* Fix spacing in Helper.cpp
This commit is contained in:
udit3333
2020-04-20 08:22:36 -07:00
committed by GitHub
parent cae77ae291
commit 325db535c0
29 changed files with 647 additions and 152 deletions

View File

@@ -94,7 +94,7 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
// Cancel button
Button cancelButton;
cancelButton.Content(winrt::box_value(winrt::to_hstring("Cancel")));
cancelButton.Click([&](IInspectable const& sender, RoutedEventArgs const&) {
cancelButton.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
// Close the window since settings do not need to be saved
PostMessage(_hWndEditShortcutsWindow, WM_CLOSE, 0, 0);
});
@@ -151,7 +151,7 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
// Apply button
Button applyButton;
applyButton.Content(winrt::box_value(winrt::to_hstring("Apply")));
applyButton.Click([&](IInspectable const& sender, RoutedEventArgs const&) {
applyButton.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
bool isSuccess = true;
// Clear existing shortcuts
keyboardManagerState.ClearOSLevelShortcuts();
@@ -176,16 +176,24 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
}
}
if (isSuccess)
// Save the updated key remaps to file.
auto saveResult = keyboardManagerState.SaveConfigToFile();
if (isSuccess && saveResult)
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Green() });
settingsMessage.Text(winrt::to_hstring("Remapping successful!"));
}
else
else if (!isSuccess && saveResult)
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Red() });
settingsMessage.Text(winrt::to_hstring("All remappings were not successfully applied."));
}
else
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Red() });
settingsMessage.Text(winrt::to_hstring("Failed to save the remappings."));
}
});
header.Children().Append(headerText);
@@ -200,7 +208,7 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
plusSymbol.Glyph(L"\xE109");
addShortcut.Content(plusSymbol);
addShortcut.Margin({ 10 });
addShortcut.Click([&](IInspectable const& sender, RoutedEventArgs const&) {
addShortcut.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
ShortcutControl::AddNewShortcutControlRow(shortcutTable, keyboardRemapControlObjects);
});