[KBM]Added option for exact match shortcut (#36000)

* Added option for exact match shortcut

* Fix spell-check
This commit is contained in:
Ionuț Manța 2025-01-15 03:31:29 -08:00 коммит произвёл GitHub
Родитель 3a10facb36
Коммит 162096c54c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
9 изменённых файлов: 96 добавлений и 32 удалений

1
.github/actions/spell-check/allow/code.txt поставляемый
Просмотреть файл

@ -97,6 +97,7 @@ EXSEL
HOLDENTER HOLDENTER
HOLDESC HOLDESC
HOLDSPACE HOLDSPACE
HOLDBACKSPACE
KBDLLHOOKSTRUCT KBDLLHOOKSTRUCT
keyevent keyevent
LAlt LAlt

Просмотреть файл

@ -275,6 +275,9 @@
<data name="Type_HoldSpace" xml:space="preserve"> <data name="Type_HoldSpace" xml:space="preserve">
<value>Hold Space to toggle allow chord</value> <value>Hold Space to toggle allow chord</value>
</data> </data>
<data name="Type_HoldBackSpace" xml:space="preserve">
<value>Hold BackSpace to toggle exact match</value>
</data>
<data name="Type_HoldEnter" xml:space="preserve"> <data name="Type_HoldEnter" xml:space="preserve">
<value>Hold Enter to continue</value> <value>Hold Enter to continue</value>
</data> </data>
@ -287,6 +290,9 @@
<data name="EditShortcuts_Allow_Chords" xml:space="preserve"> <data name="EditShortcuts_Allow_Chords" xml:space="preserve">
<value>Allow chords</value> <value>Allow chords</value>
</data> </data>
<data name="EditShortcuts_Exact_Match" xml:space="preserve">
<value>Exact Match</value>
</data>
<data name="EditShortcuts_Path_To_Program" xml:space="preserve"> <data name="EditShortcuts_Path_To_Program" xml:space="preserve">
<value>Path to program</value> <value>Path to program</value>
</data> </data>

Просмотреть файл

@ -115,4 +115,6 @@ public:
// Get number of selected keys. Do not count -1 and 0 values as they stand for Not selected and None // Get number of selected keys. Do not count -1 and 0 values as they stand for Not selected and None
static int GetNumberOfSelectedKeys(std::vector<int32_t> keys); static int GetNumberOfSelectedKeys(std::vector<int32_t> keys);
bool exactMatch = false;
}; };

Просмотреть файл

@ -90,6 +90,8 @@ namespace KBMEditor
// flag to set if we want to allow building a chord // flag to set if we want to allow building a chord
bool AllowChord = false; bool AllowChord = false;
bool exactMatch = false;
// Stores the keyboard layout // Stores the keyboard layout
LayoutMap keyboardMap; LayoutMap keyboardMap;

Просмотреть файл

@ -496,11 +496,11 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
{ {
// not sure why by we need to add the current item in here, so we have it even if does not change. // not sure why by we need to add the current item in here, so we have it even if does not change.
auto newShortcut = std::get<Shortcut>(newKeys); auto newShortcut = std::get<Shortcut>(newKeys);
shortcutRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ Shortcut(), newShortcut }, std::wstring(targetAppName) }); shortcutRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ originalKeys, newShortcut }, std::wstring(targetAppName) });
} }
else else
{ {
shortcutRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring(targetAppName) }); shortcutRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ originalKeys, newKeys }, std::wstring(targetAppName) });
} }
KeyDropDownControl::AddShortcutToControl(originalKeys, parent, keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->shortcutDropDownVariableSizedWrapGrid.as<VariableSizedWrapGrid>(), *keyboardManagerState, 0, keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->keyDropDownControlObjects, shortcutRemapBuffer, row, targetAppTextBox, false, false); KeyDropDownControl::AddShortcutToControl(originalKeys, parent, keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->shortcutDropDownVariableSizedWrapGrid.as<VariableSizedWrapGrid>(), *keyboardManagerState, 0, keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->keyDropDownControlObjects, shortcutRemapBuffer, row, targetAppTextBox, false, false);
@ -956,11 +956,12 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
shortcut = std::get<Shortcut>(shortcutRemapBuffer[rowIndex].mapping[1]); shortcut = std::get<Shortcut>(shortcutRemapBuffer[rowIndex].mapping[1]);
} }
if (!shortcut.IsEmpty() && shortcut.HasChord()) keyboardManagerState.AllowChord = false;
keyboardManagerState.exactMatch = false;
if (!shortcut.IsEmpty())
{ {
keyboardManagerState.AllowChord = true; keyboardManagerState.AllowChord = shortcut.HasChord();
} else { keyboardManagerState.exactMatch = shortcut.exactMatch;
keyboardManagerState.AllowChord = false;
} }
} }
@ -969,6 +970,7 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
// ContentDialog for detecting shortcuts. This is the parent UI element. // ContentDialog for detecting shortcuts. This is the parent UI element.
ContentDialog detectShortcutBox; ContentDialog detectShortcutBox;
ToggleSwitch allowChordSwitch; ToggleSwitch allowChordSwitch;
ToggleSwitch exactMatchSwitch;
// ContentDialog requires manually setting the XamlRoot (https://learn.microsoft.com/uwp/api/windows.ui.xaml.controls.contentdialog#contentdialog-in-appwindow-or-xaml-islands) // ContentDialog requires manually setting the XamlRoot (https://learn.microsoft.com/uwp/api/windows.ui.xaml.controls.contentdialog#contentdialog-in-appwindow-or-xaml-islands)
detectShortcutBox.XamlRoot(xamlRoot); detectShortcutBox.XamlRoot(xamlRoot);
@ -1038,6 +1040,11 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
allowChordSwitch.IsOn(keyboardManagerState.AllowChord); allowChordSwitch.IsOn(keyboardManagerState.AllowChord);
}; };
auto onReleaseBack = [&keyboardManagerState,
exactMatchSwitch] {
keyboardManagerState.exactMatch = !keyboardManagerState.exactMatch;
exactMatchSwitch.IsOn(keyboardManagerState.exactMatch);
};
auto onAccept = [onPressEnter, auto onAccept = [onPressEnter,
onReleaseEnter] { onReleaseEnter] {
onPressEnter(); onPressEnter();
@ -1109,6 +1116,17 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
}); });
}, },
nullptr); nullptr);
keyboardManagerState.RegisterKeyDelay(
VK_BACK,
selectDetectedShortcutAndResetKeys,
[onReleaseBack, detectShortcutBox](DWORD) {
detectShortcutBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
[onReleaseBack] {
onReleaseBack();
});
},
nullptr);
} }
// Cancel button // Cancel button
@ -1157,6 +1175,7 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
// Detect Chord // Detect Chord
Windows::UI::Xaml::Controls::StackPanel chordStackPanel; Windows::UI::Xaml::Controls::StackPanel chordStackPanel;
Windows::UI::Xaml::Controls::StackPanel exactMatchStackPanel;
if (isOrigShortcut) if (isOrigShortcut)
{ {
@ -1189,6 +1208,32 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
}; };
allowChordSwitch.Toggled(toggleHandler); allowChordSwitch.Toggled(toggleHandler);
TextBlock exactMatchText;
exactMatchText.Text(GET_RESOURCE_STRING(IDS_EDITSHORTCUTS_EXACT_MATCH));
exactMatchText.FontSize(12);
exactMatchText.Margin({ 0, 12 + verticalMargin, 0, 0 });
exactMatchText.TextAlignment(TextAlignment::Center);
exactMatchStackPanel.VerticalAlignment(VerticalAlignment::Center);
exactMatchStackPanel.Orientation(Orientation::Horizontal);
exactMatchSwitch.OnContent(nullptr);
exactMatchSwitch.OffContent(nullptr);
exactMatchSwitch.Margin({ 12, verticalMargin, 0, 0 });
exactMatchSwitch.IsOn(keyboardManagerState.exactMatch);
exactMatchStackPanel.Children().Append(exactMatchText);
exactMatchStackPanel.Children().Append(exactMatchSwitch);
stackPanel.Children().Append(exactMatchStackPanel);
exactMatchSwitch.IsOn(keyboardManagerState.exactMatch);
auto toggleHandlerExactMatch = [exactMatchSwitch, &keyboardManagerState, rowIndex, &remapBuffer](auto const& sender, auto const& e) {
Shortcut& shortcut = std::get<Shortcut>(remapBuffer[rowIndex].mapping[0]);
shortcut.exactMatch = exactMatchSwitch.IsOn();
};
exactMatchSwitch.Toggled(toggleHandlerExactMatch);
} }
TextBlock holdEscInfo; TextBlock holdEscInfo;
@ -1211,6 +1256,12 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
holdSpaceInfo.FontSize(12); holdSpaceInfo.FontSize(12);
holdSpaceInfo.Margin({ 0, 0, 0, 0 }); holdSpaceInfo.Margin({ 0, 0, 0, 0 });
stackPanel.Children().Append(holdSpaceInfo); stackPanel.Children().Append(holdSpaceInfo);
TextBlock holdCtrInfo;
holdCtrInfo.Text(GET_RESOURCE_STRING(IDS_TYPE_HOLDBACKSPACE));
holdCtrInfo.FontSize(12);
holdCtrInfo.Margin({ 0, 0, 0, 0 });
stackPanel.Children().Append(holdCtrInfo);
} }
try try

Просмотреть файл

@ -314,6 +314,11 @@ namespace KeyboardEventHandlers
// if not a mod key, check for chord stuff // if not a mod key, check for chord stuff
if (!resetChordsResults.CurrentKeyIsModifierKey && (data->wParam == WM_KEYDOWN || data->wParam == WM_SYSKEYDOWN)) if (!resetChordsResults.CurrentKeyIsModifierKey && (data->wParam == WM_KEYDOWN || data->wParam == WM_SYSKEYDOWN))
{ {
if (it->first.exactMatch == true && !it->first.IsKeyboardStateClearExceptShortcut(ii))
{
continue;
}
if (itShortcut.HasChord()) if (itShortcut.HasChord())
{ {
if (!resetChordsResults.AnyChordStarted && data->lParam->vkCode == itShortcut.GetActionKey() && !itShortcut.IsChordStarted() && itShortcut.HasChord()) if (!resetChordsResults.AnyChordStarted && data->lParam->vkCode == itShortcut.GetActionKey() && !itShortcut.IsChordStarted() && itShortcut.HasChord())

Просмотреть файл

@ -64,15 +64,15 @@ namespace KeyboardManagerConstants
// Name of the property use to store runProgramFilePath. // Name of the property use to store runProgramFilePath.
inline const std::wstring RunProgramFilePathSettingName = L"runProgramFilePath"; inline const std::wstring RunProgramFilePathSettingName = L"runProgramFilePath";
// Name of the property use to store secondKeyOfChord.
inline const std::wstring ShortcutSecondKeyOfChordSettingName = L"secondKeyOfChord";
// Name of the property use to store openUri. // Name of the property use to store openUri.
inline const std::wstring ShortcutOpenURI = L"openUri"; inline const std::wstring ShortcutOpenURI = L"openUri";
// Name of the property use to store shortcutOperationType. // Name of the property use to store shortcutOperationType.
inline const std::wstring ShortcutOperationType = L"operationType"; inline const std::wstring ShortcutOperationType = L"operationType";
// Name of the property use to store exactMatch.
inline const std::wstring ShortcutExactMatch = L"exactMatch";
// Name of the property use to store the target application. // Name of the property use to store the target application.
inline const std::wstring TargetAppSettingName = L"targetApp"; inline const std::wstring TargetAppSettingName = L"targetApp";

Просмотреть файл

@ -230,7 +230,9 @@ bool MappingConfiguration::LoadAppSpecificShortcutRemaps(const json::JsonObject&
auto newRemapText = it.GetObjectW().GetNamedString(KeyboardManagerConstants::NewTextSettingName, {}); auto newRemapText = it.GetObjectW().GetNamedString(KeyboardManagerConstants::NewTextSettingName, {});
auto targetApp = it.GetObjectW().GetNamedString(KeyboardManagerConstants::TargetAppSettingName); auto targetApp = it.GetObjectW().GetNamedString(KeyboardManagerConstants::TargetAppSettingName);
auto operationType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutOperationType, 0); auto operationType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutOperationType, 0);
auto exactMatch = it.GetObjectW().GetNamedBoolean(KeyboardManagerConstants::ShortcutExactMatch, false);
auto originalShortcut = Shortcut(originalKeys.c_str());
originalShortcut.exactMatch = exactMatch;
// undo dummy data for backwards compatibility // undo dummy data for backwards compatibility
if (newRemapText == L"*Unsupported*") if (newRemapText == L"*Unsupported*")
{ {
@ -246,7 +248,6 @@ bool MappingConfiguration::LoadAppSpecificShortcutRemaps(const json::JsonObject&
auto runProgramElevationLevel = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramElevationLevelSettingName, 0); auto runProgramElevationLevel = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramElevationLevelSettingName, 0);
auto runProgramAlreadyRunningAction = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramAlreadyRunningAction, 0); auto runProgramAlreadyRunningAction = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramAlreadyRunningAction, 0);
auto runProgramStartWindowType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramStartWindowType, 0); auto runProgramStartWindowType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramStartWindowType, 0);
auto secondKeyOfChord = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, 0);
auto tempShortcut = Shortcut(newRemapKeys.c_str()); auto tempShortcut = Shortcut(newRemapKeys.c_str());
tempShortcut.operationType = Shortcut::OperationType::RunProgram; tempShortcut.operationType = Shortcut::OperationType::RunProgram;
@ -257,16 +258,15 @@ bool MappingConfiguration::LoadAppSpecificShortcutRemaps(const json::JsonObject&
tempShortcut.alreadyRunningAction = static_cast<Shortcut::ProgramAlreadyRunningAction>(runProgramAlreadyRunningAction); tempShortcut.alreadyRunningAction = static_cast<Shortcut::ProgramAlreadyRunningAction>(runProgramAlreadyRunningAction);
tempShortcut.startWindowType = static_cast<Shortcut::StartWindowType>(runProgramStartWindowType); tempShortcut.startWindowType = static_cast<Shortcut::StartWindowType>(runProgramStartWindowType);
AddAppSpecificShortcut(targetApp.c_str(), Shortcut(originalKeys.c_str(), static_cast<DWORD>(secondKeyOfChord)), tempShortcut); AddAppSpecificShortcut(targetApp.c_str(), originalShortcut, tempShortcut);
} }
else if (operationType == 2) else if (operationType == 2)
{ {
auto secondKeyOfChord = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, 0);
auto tempShortcut = Shortcut(newRemapKeys.c_str()); auto tempShortcut = Shortcut(newRemapKeys.c_str());
tempShortcut.operationType = Shortcut::OperationType::OpenURI; tempShortcut.operationType = Shortcut::OperationType::OpenURI;
tempShortcut.uriToOpen = it.GetObjectW().GetNamedString(KeyboardManagerConstants::ShortcutOpenURI, L""); tempShortcut.uriToOpen = it.GetObjectW().GetNamedString(KeyboardManagerConstants::ShortcutOpenURI, L"");
AddAppSpecificShortcut(targetApp.c_str(), Shortcut(originalKeys.c_str(), static_cast<DWORD>(secondKeyOfChord)), tempShortcut); AddAppSpecificShortcut(targetApp.c_str(), originalShortcut, tempShortcut);
} }
if (!newRemapKeys.empty()) if (!newRemapKeys.empty())
@ -274,18 +274,18 @@ bool MappingConfiguration::LoadAppSpecificShortcutRemaps(const json::JsonObject&
// If remapped to a shortcut // If remapped to a shortcut
if (std::wstring(newRemapKeys).find(L";") != std::string::npos) if (std::wstring(newRemapKeys).find(L";") != std::string::npos)
{ {
AddAppSpecificShortcut(targetApp.c_str(), Shortcut(originalKeys.c_str()), Shortcut(newRemapKeys.c_str())); AddAppSpecificShortcut(targetApp.c_str(), originalShortcut, Shortcut(newRemapKeys.c_str()));
} }
// If remapped to a key // If remapped to a key
else else
{ {
AddAppSpecificShortcut(targetApp.c_str(), Shortcut(originalKeys.c_str()), std::stoul(newRemapKeys.c_str())); AddAppSpecificShortcut(targetApp.c_str(), originalShortcut, std::stoul(newRemapKeys.c_str()));
} }
} }
else else
{ {
AddAppSpecificShortcut(targetApp.c_str(), Shortcut(originalKeys.c_str()), newRemapText.c_str()); AddAppSpecificShortcut(targetApp.c_str(), originalShortcut, newRemapText.c_str());
} }
} }
catch (...) catch (...)
@ -326,6 +326,8 @@ bool MappingConfiguration::LoadShortcutRemaps(const json::JsonObject& jsonData,
auto newRemapText = it.GetObjectW().GetNamedString(KeyboardManagerConstants::NewTextSettingName, {}); auto newRemapText = it.GetObjectW().GetNamedString(KeyboardManagerConstants::NewTextSettingName, {});
auto operationType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutOperationType, 0); auto operationType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutOperationType, 0);
auto originalShortcut = Shortcut(originalKeys.c_str());
originalShortcut.exactMatch = it.GetObjectW().GetNamedBoolean(KeyboardManagerConstants::ShortcutExactMatch, false);
// undo dummy data for backwards compatibility // undo dummy data for backwards compatibility
if (newRemapText == L"*Unsupported*") if (newRemapText == L"*Unsupported*")
{ {
@ -340,8 +342,6 @@ bool MappingConfiguration::LoadShortcutRemaps(const json::JsonObject& jsonData,
auto runProgramStartInDir = it.GetObjectW().GetNamedString(KeyboardManagerConstants::RunProgramStartInDirSettingName, L""); auto runProgramStartInDir = it.GetObjectW().GetNamedString(KeyboardManagerConstants::RunProgramStartInDirSettingName, L"");
auto runProgramElevationLevel = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramElevationLevelSettingName, 0); auto runProgramElevationLevel = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramElevationLevelSettingName, 0);
auto runProgramStartWindowType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramStartWindowType, 0); auto runProgramStartWindowType = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramStartWindowType, 0);
auto secondKeyOfChord = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, 0);
auto runProgramAlreadyRunningAction = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramAlreadyRunningAction, 0); auto runProgramAlreadyRunningAction = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::RunProgramAlreadyRunningAction, 0);
auto tempShortcut = Shortcut(newRemapKeys.c_str()); auto tempShortcut = Shortcut(newRemapKeys.c_str());
@ -353,33 +353,32 @@ bool MappingConfiguration::LoadShortcutRemaps(const json::JsonObject& jsonData,
tempShortcut.alreadyRunningAction = static_cast<Shortcut::ProgramAlreadyRunningAction>(runProgramAlreadyRunningAction); tempShortcut.alreadyRunningAction = static_cast<Shortcut::ProgramAlreadyRunningAction>(runProgramAlreadyRunningAction);
tempShortcut.startWindowType = static_cast<Shortcut::StartWindowType>(runProgramStartWindowType); tempShortcut.startWindowType = static_cast<Shortcut::StartWindowType>(runProgramStartWindowType);
AddOSLevelShortcut(Shortcut(originalKeys.c_str(), static_cast<DWORD>(secondKeyOfChord)), tempShortcut); AddOSLevelShortcut(originalShortcut, tempShortcut);
} }
else if (operationType == 2) else if (operationType == 2)
{ {
auto secondKeyOfChord = it.GetObjectW().GetNamedNumber(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, 0);
auto tempShortcut = Shortcut(newRemapKeys.c_str()); auto tempShortcut = Shortcut(newRemapKeys.c_str());
tempShortcut.operationType = Shortcut::OperationType::OpenURI; tempShortcut.operationType = Shortcut::OperationType::OpenURI;
tempShortcut.uriToOpen = it.GetObjectW().GetNamedString(KeyboardManagerConstants::ShortcutOpenURI, L""); tempShortcut.uriToOpen = it.GetObjectW().GetNamedString(KeyboardManagerConstants::ShortcutOpenURI, L"");
AddOSLevelShortcut(Shortcut(originalKeys.c_str(), static_cast<DWORD>(secondKeyOfChord)), tempShortcut); AddOSLevelShortcut(originalShortcut, tempShortcut);
} }
else if (!newRemapKeys.empty()) else if (!newRemapKeys.empty())
{ {
// If remapped to a shortcut // If remapped to a shortcut
if (std::wstring(newRemapKeys).find(L";") != std::string::npos) if (std::wstring(newRemapKeys).find(L";") != std::string::npos)
{ {
AddOSLevelShortcut(Shortcut(originalKeys.c_str()), Shortcut(newRemapKeys.c_str())); AddOSLevelShortcut(originalShortcut, Shortcut(newRemapKeys.c_str()));
} }
// If remapped to a key // If remapped to a key
else else
{ {
AddOSLevelShortcut(Shortcut(originalKeys.c_str()), std::stoul(newRemapKeys.c_str())); AddOSLevelShortcut(originalShortcut, std::stoul(newRemapKeys.c_str()));
} }
} }
else else
{ {
AddOSLevelShortcut(Shortcut(originalKeys.c_str()), newRemapText.c_str()); AddOSLevelShortcut(originalShortcut, newRemapText.c_str());
} }
} }
catch (...) catch (...)
@ -501,6 +500,7 @@ bool MappingConfiguration::SaveSettingsToFile()
keys.SetNamedValue(KeyboardManagerConstants::OriginalKeysSettingName, json::value(it.first.ToHstringVK())); keys.SetNamedValue(KeyboardManagerConstants::OriginalKeysSettingName, json::value(it.first.ToHstringVK()));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutExactMatch, json::JsonValue::CreateBooleanValue(it.first.exactMatch));
bool remapToText = false; bool remapToText = false;
// For shortcut to key remapping // For shortcut to key remapping
@ -516,7 +516,6 @@ bool MappingConfiguration::SaveSettingsToFile()
if (targetShortcut.operationType == Shortcut::OperationType::RunProgram) if (targetShortcut.operationType == Shortcut::OperationType::RunProgram)
{ {
keys.SetNamedValue(KeyboardManagerConstants::RunProgramElevationLevelSettingName, json::value(static_cast<unsigned int>(targetShortcut.elevationLevel))); keys.SetNamedValue(KeyboardManagerConstants::RunProgramElevationLevelSettingName, json::value(static_cast<unsigned int>(targetShortcut.elevationLevel)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, json::value(static_cast<unsigned int>(it.first.secondKey)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType))); keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType)));
keys.SetNamedValue(KeyboardManagerConstants::RunProgramAlreadyRunningAction, json::value(static_cast<unsigned int>(targetShortcut.alreadyRunningAction))); keys.SetNamedValue(KeyboardManagerConstants::RunProgramAlreadyRunningAction, json::value(static_cast<unsigned int>(targetShortcut.alreadyRunningAction)));
@ -532,7 +531,6 @@ bool MappingConfiguration::SaveSettingsToFile()
else if (targetShortcut.operationType == Shortcut::OperationType::OpenURI) else if (targetShortcut.operationType == Shortcut::OperationType::OpenURI)
{ {
keys.SetNamedValue(KeyboardManagerConstants::RunProgramElevationLevelSettingName, json::value(static_cast<unsigned int>(targetShortcut.elevationLevel))); keys.SetNamedValue(KeyboardManagerConstants::RunProgramElevationLevelSettingName, json::value(static_cast<unsigned int>(targetShortcut.elevationLevel)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, json::value(static_cast<unsigned int>(it.first.secondKey)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType))); keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOpenURI, json::value(targetShortcut.uriToOpen)); keys.SetNamedValue(KeyboardManagerConstants::ShortcutOpenURI, json::value(targetShortcut.uriToOpen));
@ -543,7 +541,6 @@ bool MappingConfiguration::SaveSettingsToFile()
else else
{ {
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType))); keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, json::value(static_cast<unsigned int>(it.first.secondKey)));
keys.SetNamedValue(KeyboardManagerConstants::NewRemapKeysSettingName, json::value(targetShortcut.ToHstringVK())); keys.SetNamedValue(KeyboardManagerConstants::NewRemapKeysSettingName, json::value(targetShortcut.ToHstringVK()));
} }
} }
@ -552,7 +549,6 @@ bool MappingConfiguration::SaveSettingsToFile()
{ {
remapToText = true; remapToText = true;
keys.SetNamedValue(KeyboardManagerConstants::NewTextSettingName, json::value(std::get<std::wstring>(it.second.targetShortcut))); keys.SetNamedValue(KeyboardManagerConstants::NewTextSettingName, json::value(std::get<std::wstring>(it.second.targetShortcut)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, json::value(static_cast<unsigned int>(it.first.secondKey)));
} }
if (!remapToText) if (!remapToText)
@ -568,7 +564,7 @@ bool MappingConfiguration::SaveSettingsToFile()
{ {
json::JsonObject keys; json::JsonObject keys;
keys.SetNamedValue(KeyboardManagerConstants::OriginalKeysSettingName, json::value(itKeys.first.ToHstringVK())); keys.SetNamedValue(KeyboardManagerConstants::OriginalKeysSettingName, json::value(itKeys.first.ToHstringVK()));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutExactMatch, json::JsonValue::CreateBooleanValue(itKeys.first.exactMatch));
bool remapToText = false; bool remapToText = false;
// For shortcut to key remapping // For shortcut to key remapping
@ -585,7 +581,6 @@ bool MappingConfiguration::SaveSettingsToFile()
if (targetShortcut.operationType == Shortcut::OperationType::RunProgram) if (targetShortcut.operationType == Shortcut::OperationType::RunProgram)
{ {
keys.SetNamedValue(KeyboardManagerConstants::RunProgramElevationLevelSettingName, json::value(static_cast<unsigned int>(targetShortcut.elevationLevel))); keys.SetNamedValue(KeyboardManagerConstants::RunProgramElevationLevelSettingName, json::value(static_cast<unsigned int>(targetShortcut.elevationLevel)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, json::value(static_cast<unsigned int>(itKeys.first.secondKey)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType))); keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType)));
keys.SetNamedValue(KeyboardManagerConstants::RunProgramAlreadyRunningAction, json::value(static_cast<unsigned int>(targetShortcut.alreadyRunningAction))); keys.SetNamedValue(KeyboardManagerConstants::RunProgramAlreadyRunningAction, json::value(static_cast<unsigned int>(targetShortcut.alreadyRunningAction)));
@ -601,7 +596,6 @@ bool MappingConfiguration::SaveSettingsToFile()
else if (targetShortcut.operationType == Shortcut::OperationType::OpenURI) else if (targetShortcut.operationType == Shortcut::OperationType::OpenURI)
{ {
keys.SetNamedValue(KeyboardManagerConstants::RunProgramElevationLevelSettingName, json::value(static_cast<unsigned int>(targetShortcut.elevationLevel))); keys.SetNamedValue(KeyboardManagerConstants::RunProgramElevationLevelSettingName, json::value(static_cast<unsigned int>(targetShortcut.elevationLevel)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutSecondKeyOfChordSettingName, json::value(static_cast<unsigned int>(itKeys.first.secondKey)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType))); keys.SetNamedValue(KeyboardManagerConstants::ShortcutOperationType, json::value(static_cast<unsigned int>(targetShortcut.operationType)));
keys.SetNamedValue(KeyboardManagerConstants::ShortcutOpenURI, json::value(targetShortcut.uriToOpen)); keys.SetNamedValue(KeyboardManagerConstants::ShortcutOpenURI, json::value(targetShortcut.uriToOpen));

Просмотреть файл

@ -26,6 +26,9 @@ private:
std::vector<int32_t> Shortcut::ConvertToNumbers(std::vector<std::wstring>& keys); std::vector<int32_t> Shortcut::ConvertToNumbers(std::vector<std::wstring>& keys);
public: public:
bool exactMatch = false;
enum ElevationLevel enum ElevationLevel
{ {
NonElevated = 0, NonElevated = 0,