[KBM][CQ]Replace make_pair with RemapBufferRow (#32003)

This commit is contained in:
Masaru Iritani
2024-04-17 21:45:58 +09:00
committed by GitHub
parent 21aaf9c071
commit fba5f6f002
4 changed files with 317 additions and 317 deletions

View File

@@ -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.
auto newShortcut = std::get<Shortcut>(newKeys);
shortcutRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ Shortcut(), newShortcut }, std::wstring(targetAppName)));
shortcutRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ Shortcut(), newShortcut }, std::wstring(targetAppName) });
}
else
{
shortcutRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring(targetAppName)));
shortcutRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, 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);
@@ -526,7 +526,7 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
else
{
// Initialize both shortcuts as empty shortcuts
shortcutRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring(targetAppName)));
shortcutRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, 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);
@@ -666,7 +666,7 @@ StackPanel SetupRunProgramControls(StackPanel& parent, StackPanel& row, Shortcut
runProgramAlreadyRunningAction.Items().Append(winrt::box_value(GET_RESOURCE_STRING(IDS_ALREADY_RUNNING_DO_NOTHING)));
runProgramAlreadyRunningAction.Items().Append(winrt::box_value(GET_RESOURCE_STRING(IDS_ALREADY_RUNNING_CLOSE)));
runProgramAlreadyRunningAction.Items().Append(winrt::box_value(GET_RESOURCE_STRING(IDS_ALREADY_RUNNING_TERMINATE)));
runProgramAlreadyRunningAction.SelectedIndex(0);
controlStackPanel.Children().Append(UIHelpers::GetLabelWrapped(runProgramElevationTypeCombo, GET_RESOURCE_STRING(IDS_EDITSHORTCUTS_LABEL_ELEVATION), runProgramLabelWidth).as<StackPanel>());
@@ -1033,7 +1033,7 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
auto onReleaseSpace = [&keyboardManagerState,
allowChordSwitch] {
keyboardManagerState.AllowChord = !keyboardManagerState.AllowChord;
allowChordSwitch.IsOn(keyboardManagerState.AllowChord);
};

View File

@@ -177,7 +177,7 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
// Set the key text if the two keys are not null (i.e. default args)
if (originalKey != NULL && !(newKey.index() == 0 && std::get<DWORD>(newKey) == NULL) && !(newKey.index() == 1 && !EditorHelpers::IsValidShortcut(std::get<Shortcut>(newKey))) && !(newKey.index() == 2 && std::get<std::wstring>(newKey).empty()))
{
singleKeyRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ originalKey, newKey }, L""));
singleKeyRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ originalKey, newKey }, L"" });
keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->keyDropDownControlObjects[0]->SetSelectedValue(std::to_wstring(originalKey));
if (newKey.index() == 0)
{
@@ -201,7 +201,7 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
else
{
// Initialize both keys to NULL
singleKeyRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ (DWORD)0, (DWORD)0 }, L""));
singleKeyRemapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, (DWORD)0 }, L"" });
}
// Delete row button

View File

@@ -42,8 +42,8 @@ namespace RemappingUITests
RemapBuffer remapBuffer;
// Remap A to B and B to C
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x42, (DWORD)0x43 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x42, (DWORD)0x43 }), std::wstring() });
// Assert that remapping set is valid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::NoError);
@@ -62,8 +62,8 @@ namespace RemappingUITests
Shortcut s2;
s2.SetKey(VK_MENU);
s2.SetKey(VK_TAB);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, s1 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x42, s2 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, s1 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x42, s2 }), std::wstring() });
// Assert that remapping set is valid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::NoError);
@@ -82,8 +82,8 @@ namespace RemappingUITests
Shortcut s2;
s2.SetKey(VK_MENU);
s2.SetKey(VK_TAB);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ s1, (DWORD)0x41 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ s2, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ s1, (DWORD)0x41 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ s2, (DWORD)0x42 }), std::wstring() });
// Assert that remapping set is valid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::NoError);
@@ -108,8 +108,8 @@ namespace RemappingUITests
Shortcut dest2;
dest2.SetKey(CommonSharedConstants::VK_WIN_BOTH);
dest2.SetKey(0x41);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, dest1 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src2, dest2 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, dest1 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src2, dest2 }), std::wstring() });
// Assert that remapping set is valid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::NoError);
@@ -134,10 +134,10 @@ namespace RemappingUITests
Shortcut dest2;
dest2.SetKey(CommonSharedConstants::VK_WIN_BOTH);
dest2.SetKey(0x41);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, dest1 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src2, (DWORD)0x41 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x42, dest2 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, dest1 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src2, (DWORD)0x41 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x42, dest2 }), std::wstring() });
// Assert that remapping set is valid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::NoError);
@@ -150,7 +150,7 @@ namespace RemappingUITests
RemapBuffer remapBuffer;
// Remap A to NULL
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, (DWORD)0 }), std::wstring() });
// Assert that remapping set is invalid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::RemapUnsuccessful);
@@ -165,7 +165,7 @@ namespace RemappingUITests
// Remap A to incomplete shortcut (Ctrl)
Shortcut src1;
src1.SetKey(VK_CONTROL);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, src1 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, src1 }), std::wstring() });
// Assert that remapping set is invalid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::RemapUnsuccessful);
@@ -181,8 +181,8 @@ namespace RemappingUITests
Shortcut src1;
src1.SetKey(VK_CONTROL);
src1.SetKey(0x43);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, src1 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, src1 }), std::wstring() });
// Assert that remapping set is invalid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::RemapUnsuccessful);
@@ -201,8 +201,8 @@ namespace RemappingUITests
Shortcut dest1;
dest1.SetKey(VK_CONTROL);
dest1.SetKey(0x56);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, dest1 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, (DWORD)0x42 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, dest1 }), std::wstring() });
// Assert that remapping set is invalid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::RemapUnsuccessful);
@@ -221,8 +221,8 @@ namespace RemappingUITests
Shortcut dest1;
dest1.SetKey(VK_CONTROL);
dest1.SetKey(0x56);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, (DWORD)0x42 }), testApp1));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, dest1 }), testApp1));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, (DWORD)0x42 }), testApp1 });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, dest1 }), testApp1 });
// Assert that remapping set is invalid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::RemapUnsuccessful);
@@ -241,8 +241,8 @@ namespace RemappingUITests
Shortcut dest1;
dest1.SetKey(VK_CONTROL);
dest1.SetKey(0x56);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, (DWORD)0x42 }), testApp1));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, dest1 }), testApp2));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, (DWORD)0x42 }), testApp1 });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, dest1 }), testApp2 });
// Assert that remapping set is valid
bool isSuccess = (LoadingAndSavingRemappingHelper::CheckIfRemappingsAreValid(remapBuffer) == ShortcutErrorType::NoError);
@@ -264,7 +264,7 @@ namespace RemappingUITests
RemapBuffer remapBuffer;
// Remap A to B
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring() });
// Assert that only A is orphaned
Assert::AreEqual((size_t)1, LoadingAndSavingRemappingHelper::GetOrphanedKeys(remapBuffer).size());
@@ -277,8 +277,8 @@ namespace RemappingUITests
RemapBuffer remapBuffer;
// Remap A to B and B to A
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x42, (DWORD)0x41 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x42, (DWORD)0x41 }), std::wstring() });
// Assert that there are no orphaned keys
Assert::AreEqual(true, LoadingAndSavingRemappingHelper::GetOrphanedKeys(remapBuffer).empty());
@@ -293,8 +293,8 @@ namespace RemappingUITests
Shortcut dest1;
dest1.SetKey(VK_CONTROL);
dest1.SetKey(0x42);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, dest1 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x43, (DWORD)0x41 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, dest1 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x43, (DWORD)0x41 }), std::wstring() });
// Assert that only C is orphaned
Assert::AreEqual((size_t)1, LoadingAndSavingRemappingHelper::GetOrphanedKeys(remapBuffer).size());
@@ -391,10 +391,10 @@ namespace RemappingUITests
s1.SetKey(0x56);
Shortcut s2;
s2.SetKey(VK_LMENU);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x42, s1 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x43, (DWORD)0 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x44, s2 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x42, s1 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x43, (DWORD)0 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)0x44, s2 }), std::wstring() });
// Apply the single key remaps from the buffer to the keyboard manager state variable
LoadingAndSavingRemappingHelper::ApplySingleKeyRemappings(testShortcuts, remapBuffer, false);
@@ -415,10 +415,10 @@ namespace RemappingUITests
RemapBuffer remapBuffer;
// Add Ctrl->A, Alt->B, Shift->C and Win->D remappings to the buffer
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)VK_CONTROL, (DWORD)0x41 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)VK_MENU, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)VK_SHIFT, (DWORD)0x43 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)CommonSharedConstants::VK_WIN_BOTH, (DWORD)0x44 }), std::wstring()));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)VK_CONTROL, (DWORD)0x41 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)VK_MENU, (DWORD)0x42 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)VK_SHIFT, (DWORD)0x43 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ (DWORD)CommonSharedConstants::VK_WIN_BOTH, (DWORD)0x44 }), std::wstring() });
// Apply the single key remaps from the buffer to the keyboard manager state variable
LoadingAndSavingRemappingHelper::ApplySingleKeyRemappings(testShortcuts, remapBuffer, false);
@@ -496,14 +496,14 @@ namespace RemappingUITests
src4.SetKey(0x47);
Shortcut dest4;
dest4.SetKey(VK_CONTROL);
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, dest1 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src2, dest2 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src3, (DWORD)0 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src4, dest4 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src3, dest2 }), testApp1));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src4, dest1 }), testApp1));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src1, (DWORD)0 }), testApp1));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ src2, dest4 }), testApp1));
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, dest1 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src2, dest2 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src3, (DWORD)0 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src4, dest4 }), std::wstring() });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src3, dest2 }), testApp1 });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src4, dest1 }), testApp1 });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src1, (DWORD)0 }), testApp1 });
remapBuffer.push_back(RemapBufferRow{ RemapBufferItem({ src2, dest4 }), testApp1 });
// Apply the shortcut remaps from the buffer to the keyboard manager state variable
LoadingAndSavingRemappingHelper::ApplyShortcutRemappings(testShortcuts, remapBuffer, false);