mirror of
https://github.com/microsoft/PowerToys
synced 2024-11-21 15:53:19 +00:00
[KBM] Convert RemapBufferRow
to a struct with descriptive field names (#32545)
Use struct for RemapBufferRow Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
This commit is contained in:
parent
67d99a8377
commit
2979dc7d15
@ -29,9 +29,9 @@ namespace BufferValidationHelpers
|
||||
if (selectedKeyCode != -1)
|
||||
{
|
||||
// Check if the value being set is the same as the other column
|
||||
if (remapBuffer[rowIndex].first[std::abs(colIndex - 1)].index() == 0)
|
||||
if (remapBuffer[rowIndex].mapping[std::abs(colIndex - 1)].index() == 0)
|
||||
{
|
||||
DWORD otherColumnKeyCode = std::get<DWORD>(remapBuffer[rowIndex].first[std::abs(colIndex - 1)]);
|
||||
DWORD otherColumnKeyCode = std::get<DWORD>(remapBuffer[rowIndex].mapping[std::abs(colIndex - 1)]);
|
||||
if (otherColumnKeyCode == selectedKeyCode || IsKeyRemappingToItsCombinedKey(selectedKeyCode, otherColumnKeyCode))
|
||||
{
|
||||
errorType = ShortcutErrorType::MapToSameKey;
|
||||
@ -47,9 +47,9 @@ namespace BufferValidationHelpers
|
||||
{
|
||||
if (i != rowIndex)
|
||||
{
|
||||
if (remapBuffer[i].first[colIndex].index() == 0)
|
||||
if (remapBuffer[i].mapping[colIndex].index() == 0)
|
||||
{
|
||||
ShortcutErrorType result = EditorHelpers::DoKeysOverlap(std::get<DWORD>(remapBuffer[i].first[colIndex]), selectedKeyCode);
|
||||
ShortcutErrorType result = EditorHelpers::DoKeysOverlap(std::get<DWORD>(remapBuffer[i].mapping[colIndex]), selectedKeyCode);
|
||||
if (result != ShortcutErrorType::NoError)
|
||||
{
|
||||
errorType = result;
|
||||
@ -65,17 +65,17 @@ namespace BufferValidationHelpers
|
||||
// If there is no error, set the buffer
|
||||
if (errorType == ShortcutErrorType::NoError)
|
||||
{
|
||||
remapBuffer[rowIndex].first[colIndex] = (DWORD)selectedKeyCode;
|
||||
remapBuffer[rowIndex].mapping[colIndex] = (DWORD)selectedKeyCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
remapBuffer[rowIndex].first[colIndex] = (DWORD)0;
|
||||
remapBuffer[rowIndex].mapping[colIndex] = (DWORD)0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset to null if the key is not found
|
||||
remapBuffer[rowIndex].first[colIndex] = (DWORD)0;
|
||||
remapBuffer[rowIndex].mapping[colIndex] = (DWORD)0;
|
||||
}
|
||||
|
||||
return errorType;
|
||||
@ -245,9 +245,9 @@ namespace BufferValidationHelpers
|
||||
if (tempShortcut.index() == 1)
|
||||
{
|
||||
// If shortcut to shortcut
|
||||
if (remapBuffer[rowIndex].first[std::abs(colIndex - 1)].index() == 1)
|
||||
if (remapBuffer[rowIndex].mapping[std::abs(colIndex - 1)].index() == 1)
|
||||
{
|
||||
auto& shortcut = std::get<Shortcut>(remapBuffer[rowIndex].first[std::abs(colIndex - 1)]);
|
||||
auto& shortcut = std::get<Shortcut>(remapBuffer[rowIndex].mapping[std::abs(colIndex - 1)]);
|
||||
if (shortcut == std::get<Shortcut>(tempShortcut) && EditorHelpers::IsValidShortcut(shortcut) && EditorHelpers::IsValidShortcut(std::get<Shortcut>(tempShortcut)))
|
||||
{
|
||||
errorType = ShortcutErrorType::MapToSameShortcut;
|
||||
@ -259,9 +259,9 @@ namespace BufferValidationHelpers
|
||||
else
|
||||
{
|
||||
// If key to key
|
||||
if (remapBuffer[rowIndex].first[std::abs(colIndex - 1)].index() == 0)
|
||||
if (remapBuffer[rowIndex].mapping[std::abs(colIndex - 1)].index() == 0)
|
||||
{
|
||||
DWORD otherColumnKeyCode = std::get<DWORD>(remapBuffer[rowIndex].first[std::abs(colIndex - 1)]);
|
||||
DWORD otherColumnKeyCode = std::get<DWORD>(remapBuffer[rowIndex].mapping[std::abs(colIndex - 1)]);
|
||||
DWORD shortcutKeyCode = std::get<DWORD>(tempShortcut);
|
||||
if ((otherColumnKeyCode == shortcutKeyCode || IsKeyRemappingToItsCombinedKey(otherColumnKeyCode, shortcutKeyCode)) && otherColumnKeyCode != NULL && shortcutKeyCode != NULL)
|
||||
{
|
||||
@ -277,7 +277,7 @@ namespace BufferValidationHelpers
|
||||
// Check if the key is already remapped to something else for the same target app
|
||||
for (int i = 0; i < remapBuffer.size(); i++)
|
||||
{
|
||||
std::wstring currAppName = remapBuffer[i].second;
|
||||
std::wstring currAppName = remapBuffer[i].appName;
|
||||
std::transform(currAppName.begin(), currAppName.end(), currAppName.begin(), towlower);
|
||||
|
||||
if (i != rowIndex && currAppName == appName)
|
||||
@ -285,23 +285,23 @@ namespace BufferValidationHelpers
|
||||
ShortcutErrorType result = ShortcutErrorType::NoError;
|
||||
if (!isHybridControl)
|
||||
{
|
||||
result = EditorHelpers::DoShortcutsOverlap(std::get<Shortcut>(remapBuffer[i].first[colIndex]), std::get<Shortcut>(tempShortcut));
|
||||
result = EditorHelpers::DoShortcutsOverlap(std::get<Shortcut>(remapBuffer[i].mapping[colIndex]), std::get<Shortcut>(tempShortcut));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tempShortcut.index() == 0 && remapBuffer[i].first[colIndex].index() == 0)
|
||||
if (tempShortcut.index() == 0 && remapBuffer[i].mapping[colIndex].index() == 0)
|
||||
{
|
||||
if (std::get<DWORD>(tempShortcut) != NULL && std::get<DWORD>(remapBuffer[i].first[colIndex]) != NULL)
|
||||
if (std::get<DWORD>(tempShortcut) != NULL && std::get<DWORD>(remapBuffer[i].mapping[colIndex]) != NULL)
|
||||
{
|
||||
result = EditorHelpers::DoKeysOverlap(std::get<DWORD>(remapBuffer[i].first[colIndex]), std::get<DWORD>(tempShortcut));
|
||||
result = EditorHelpers::DoKeysOverlap(std::get<DWORD>(remapBuffer[i].mapping[colIndex]), std::get<DWORD>(tempShortcut));
|
||||
}
|
||||
}
|
||||
else if (tempShortcut.index() == 1 && remapBuffer[i].first[colIndex].index() == 1)
|
||||
else if (tempShortcut.index() == 1 && remapBuffer[i].mapping[colIndex].index() == 1)
|
||||
{
|
||||
auto& shortcut = std::get<Shortcut>(remapBuffer[i].first[colIndex]);
|
||||
auto& shortcut = std::get<Shortcut>(remapBuffer[i].mapping[colIndex]);
|
||||
if (EditorHelpers::IsValidShortcut(std::get<Shortcut>(tempShortcut)) && EditorHelpers::IsValidShortcut(shortcut))
|
||||
{
|
||||
result = EditorHelpers::DoShortcutsOverlap(std::get<Shortcut>(remapBuffer[i].first[colIndex]), std::get<Shortcut>(tempShortcut));
|
||||
result = EditorHelpers::DoShortcutsOverlap(std::get<Shortcut>(remapBuffer[i].mapping[colIndex]), std::get<Shortcut>(tempShortcut));
|
||||
}
|
||||
}
|
||||
// Other scenarios not possible since key to shortcut is with key to key, and shortcut to key is with shortcut to shortcut
|
||||
|
@ -348,7 +348,7 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
|
||||
auto indexToDelete = -1;
|
||||
for (int i = 0; i < ShortcutControl::shortcutRemapBuffer.size(); i++)
|
||||
{
|
||||
auto tempShortcut = std::get<Shortcut>(ShortcutControl::shortcutRemapBuffer[i].first[0]);
|
||||
auto tempShortcut = std::get<Shortcut>(ShortcutControl::shortcutRemapBuffer[i].mapping[0]);
|
||||
if (tempShortcut.ToHstringVK() == keysForShortcutToEdit)
|
||||
{
|
||||
indexToDelete = i;
|
||||
|
@ -281,19 +281,19 @@ void KeyDropDownControl::SetSelectionHandler(StackPanel& table, StackPanel row,
|
||||
std::vector<int32_t> selectedKeyCodes = GetSelectedCodesFromStackPanel(parent);
|
||||
if (!isHybridControl)
|
||||
{
|
||||
std::get<Shortcut>(shortcutRemapBuffer[validationResult.second].first[colIndex]).SetKeyCodes(selectedKeyCodes);
|
||||
std::get<Shortcut>(shortcutRemapBuffer[validationResult.second].mapping[colIndex]).SetKeyCodes(selectedKeyCodes);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If exactly one key is selected consider it to be a key remap
|
||||
if (GetNumberOfSelectedKeys(selectedKeyCodes) == 1)
|
||||
{
|
||||
shortcutRemapBuffer[validationResult.second].first[colIndex] = (DWORD)selectedKeyCodes[0];
|
||||
shortcutRemapBuffer[validationResult.second].mapping[colIndex] = (DWORD)selectedKeyCodes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assign instead of setting the value in the buffer since the previous value may not be a Shortcut
|
||||
shortcutRemapBuffer[validationResult.second].first[colIndex] = Shortcut(selectedKeyCodes);
|
||||
shortcutRemapBuffer[validationResult.second].mapping[colIndex] = Shortcut(selectedKeyCodes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,11 +305,11 @@ void KeyDropDownControl::SetSelectionHandler(StackPanel& table, StackPanel row,
|
||||
std::transform(lowercaseDefAppName.begin(), lowercaseDefAppName.end(), lowercaseDefAppName.begin(), towlower);
|
||||
if (newText == lowercaseDefAppName)
|
||||
{
|
||||
shortcutRemapBuffer[validationResult.second].second = L"";
|
||||
shortcutRemapBuffer[validationResult.second].appName = L"";
|
||||
}
|
||||
else
|
||||
{
|
||||
shortcutRemapBuffer[validationResult.second].second = targetApp.Text().c_str();
|
||||
shortcutRemapBuffer[validationResult.second].appName = targetApp.Text().c_str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ namespace LoadingAndSavingRemappingHelper
|
||||
std::map<std::wstring, std::set<KeyShortcutTextUnion>> ogKeys;
|
||||
for (int i = 0; i < remappings.size(); i++)
|
||||
{
|
||||
KeyShortcutTextUnion ogKey = remappings[i].first[0];
|
||||
KeyShortcutTextUnion newKey = remappings[i].first[1];
|
||||
std::wstring appName = remappings[i].second;
|
||||
KeyShortcutTextUnion ogKey = remappings[i].mapping[0];
|
||||
KeyShortcutTextUnion newKey = remappings[i].mapping[1];
|
||||
std::wstring appName = remappings[i].appName;
|
||||
|
||||
const bool ogKeyValidity = (ogKey.index() == 0 && std::get<DWORD>(ogKey) != NULL) || (ogKey.index() == 1 && EditorHelpers::IsValidShortcut(std::get<Shortcut>(ogKey)));
|
||||
const bool newKeyValidity = (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());
|
||||
@ -58,8 +58,8 @@ namespace LoadingAndSavingRemappingHelper
|
||||
|
||||
for (int i = 0; i < remappings.size(); i++)
|
||||
{
|
||||
DWORD ogKey = std::get<DWORD>(remappings[i].first[0]);
|
||||
KeyShortcutTextUnion newKey = remappings[i].first[1];
|
||||
DWORD ogKey = std::get<DWORD>(remappings[i].mapping[0]);
|
||||
KeyShortcutTextUnion newKey = remappings[i].mapping[1];
|
||||
|
||||
const bool hasValidKeyRemapping = newKey.index() == 0 && std::get<DWORD>(newKey) != 0;
|
||||
const bool hasValidShortcutRemapping = newKey.index() == 1 && EditorHelpers::IsValidShortcut(std::get<Shortcut>(newKey));
|
||||
@ -69,7 +69,7 @@ namespace LoadingAndSavingRemappingHelper
|
||||
ogKeys.insert(ogKey);
|
||||
|
||||
// newKey should be added only if the target is a key
|
||||
if (remappings[i].first[1].index() == 0)
|
||||
if (remappings[i].mapping[1].index() == 0)
|
||||
{
|
||||
newKeys.insert(std::get<DWORD>(newKey));
|
||||
}
|
||||
@ -125,8 +125,8 @@ namespace LoadingAndSavingRemappingHelper
|
||||
DWORD successfulKeyToTextRemapCount = 0;
|
||||
for (int i = 0; i < remappings.size(); i++)
|
||||
{
|
||||
const DWORD originalKey = std::get<DWORD>(remappings[i].first[0]);
|
||||
KeyShortcutTextUnion newKey = remappings[i].first[1];
|
||||
const DWORD originalKey = std::get<DWORD>(remappings[i].mapping[0]);
|
||||
KeyShortcutTextUnion newKey = remappings[i].mapping[1];
|
||||
|
||||
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()))
|
||||
{
|
||||
@ -203,12 +203,12 @@ namespace LoadingAndSavingRemappingHelper
|
||||
// Save the shortcuts that are valid and report if any of them were invalid
|
||||
for (int i = 0; i < remappings.size(); i++)
|
||||
{
|
||||
Shortcut originalShortcut = std::get<Shortcut>(remappings[i].first[0]);
|
||||
KeyShortcutTextUnion newShortcut = remappings[i].first[1];
|
||||
Shortcut originalShortcut = std::get<Shortcut>(remappings[i].mapping[0]);
|
||||
KeyShortcutTextUnion newShortcut = remappings[i].mapping[1];
|
||||
|
||||
if (EditorHelpers::IsValidShortcut(originalShortcut) && ((newShortcut.index() == 0 && std::get<DWORD>(newShortcut) != NULL) || (newShortcut.index() == 1 && EditorHelpers::IsValidShortcut(std::get<Shortcut>(newShortcut))) || (newShortcut.index() == 2 && !std::get<std::wstring>(newShortcut).empty())))
|
||||
{
|
||||
if (remappings[i].second == L"")
|
||||
if (remappings[i].appName == L"")
|
||||
{
|
||||
bool result = mappingConfiguration.AddOSLevelShortcut(originalShortcut, newShortcut);
|
||||
if (result)
|
||||
@ -225,7 +225,7 @@ namespace LoadingAndSavingRemappingHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
bool result = mappingConfiguration.AddAppSpecificShortcut(remappings[i].second, originalShortcut, newShortcut);
|
||||
bool result = mappingConfiguration.AddAppSpecificShortcut(remappings[i].appName, originalShortcut, newShortcut);
|
||||
if (result)
|
||||
{
|
||||
if (newShortcut.index() == 0)
|
||||
|
@ -217,7 +217,7 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
|
||||
return;
|
||||
}
|
||||
|
||||
shortcutRemapBuffer[rowIndex].first[1] = text.c_str();
|
||||
shortcutRemapBuffer[rowIndex].mapping[1] = text.c_str();
|
||||
});
|
||||
|
||||
const bool textSelected = newKeys.index() == 2;
|
||||
@ -338,7 +338,7 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
|
||||
KeyDropDownControl::ValidateShortcutFromDropDownList(parent, row, keyboardRemapControlObjects[rowIndex][1]->shortcutDropDownVariableSizedWrapGrid.as<VariableSizedWrapGrid>(), 1, ShortcutControl::shortcutRemapBuffer, keyboardRemapControlObjects[rowIndex][1]->keyDropDownControlObjects, targetAppTextBox, true, false);
|
||||
|
||||
// Reset the buffer based on the selected drop down items
|
||||
std::get<Shortcut>(shortcutRemapBuffer[rowIndex].first[0]).SetKeyCodes(KeyDropDownControl::GetSelectedCodesFromStackPanel(keyboardRemapControlObjects[rowIndex][0]->shortcutDropDownVariableSizedWrapGrid.as<VariableSizedWrapGrid>()));
|
||||
std::get<Shortcut>(shortcutRemapBuffer[rowIndex].mapping[0]).SetKeyCodes(KeyDropDownControl::GetSelectedCodesFromStackPanel(keyboardRemapControlObjects[rowIndex][0]->shortcutDropDownVariableSizedWrapGrid.as<VariableSizedWrapGrid>()));
|
||||
// second column is a hybrid column
|
||||
|
||||
const bool regularShortcut = actionTypeCombo.SelectedIndex() == 0;
|
||||
@ -348,7 +348,7 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
|
||||
|
||||
if (textSelected)
|
||||
{
|
||||
shortcutRemapBuffer[rowIndex].first[1] = unicodeTextKeysInput.Text().c_str();
|
||||
shortcutRemapBuffer[rowIndex].mapping[1] = unicodeTextKeysInput.Text().c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -359,14 +359,14 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
|
||||
// If exactly one key is selected consider it to be a key remap
|
||||
if (selectedKeyCodes.size() == 1)
|
||||
{
|
||||
shortcutRemapBuffer[rowIndex].first[1] = (DWORD)selectedKeyCodes[0];
|
||||
shortcutRemapBuffer[rowIndex].mapping[1] = (DWORD)selectedKeyCodes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
Shortcut tempShortcut;
|
||||
tempShortcut.SetKeyCodes(selectedKeyCodes);
|
||||
// Assign instead of setting the value in the buffer since the previous value may not be a Shortcut
|
||||
shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
}
|
||||
}
|
||||
else if (runProgram)
|
||||
@ -388,7 +388,7 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
|
||||
tempShortcut.alreadyRunningAction = static_cast<Shortcut::ProgramAlreadyRunningAction>(runProgramAlreadyRunningAction.SelectedIndex());
|
||||
|
||||
// Assign instead of setting the value in the buffer since the previous value may not be a Shortcut
|
||||
shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
}
|
||||
else if (openUri)
|
||||
{
|
||||
@ -401,11 +401,11 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
|
||||
std::transform(lowercaseDefAppName.begin(), lowercaseDefAppName.end(), lowercaseDefAppName.begin(), towlower);
|
||||
if (newText == lowercaseDefAppName)
|
||||
{
|
||||
shortcutRemapBuffer[rowIndex].second = L"";
|
||||
shortcutRemapBuffer[rowIndex].appName = L"";
|
||||
}
|
||||
else
|
||||
{
|
||||
shortcutRemapBuffer[rowIndex].second = targetAppTextBox.Text().c_str();
|
||||
shortcutRemapBuffer[rowIndex].appName = targetAppTextBox.Text().c_str();
|
||||
}
|
||||
|
||||
// To set the accessible name of the target app text box when focus is lost
|
||||
@ -517,7 +517,7 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
|
||||
}
|
||||
else if (newKeys.index() == 2)
|
||||
{
|
||||
shortcutRemapBuffer.back().first[1] = std::get<std::wstring>(newKeys);
|
||||
shortcutRemapBuffer.back().mapping[1] = std::get<std::wstring>(newKeys);
|
||||
const auto& remapControl = keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1];
|
||||
actionTypeCombo.SelectedIndex(1);
|
||||
unicodeTextKeysInput.Text(std::get<std::wstring>(newKeys));
|
||||
@ -571,7 +571,7 @@ StackPanel SetupOpenURIControls(StackPanel& parent, StackPanel& row, Shortcut& s
|
||||
Shortcut tempShortcut;
|
||||
tempShortcut.operationType = Shortcut::OperationType::OpenURI;
|
||||
tempShortcut.uriToOpen = ShortcutControl::RemoveExtraQuotes(uriTextBox.Text().c_str());
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
});
|
||||
|
||||
_controlStackPanel.Children().Append(openUriStackPanel);
|
||||
@ -689,7 +689,7 @@ StackPanel SetupRunProgramControls(StackPanel& parent, StackPanel& row, Shortcut
|
||||
}
|
||||
Shortcut tempShortcut;
|
||||
CreateNewTempShortcut(row, tempShortcut, rowIndex);
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
});
|
||||
|
||||
runProgramArgsForProgramInput.TextChanged([parent, row](winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::TextChangedEventArgs const& e) mutable {
|
||||
@ -701,7 +701,7 @@ StackPanel SetupRunProgramControls(StackPanel& parent, StackPanel& row, Shortcut
|
||||
|
||||
Shortcut tempShortcut;
|
||||
CreateNewTempShortcut(row, tempShortcut, rowIndex);
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
});
|
||||
|
||||
runProgramStartInDirInput.TextChanged([parent, row](winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::TextChangedEventArgs const& e) mutable {
|
||||
@ -718,7 +718,7 @@ StackPanel SetupRunProgramControls(StackPanel& parent, StackPanel& row, Shortcut
|
||||
|
||||
Shortcut tempShortcut;
|
||||
CreateNewTempShortcut(row, tempShortcut, rowIndex);
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
});
|
||||
|
||||
runProgramAlreadyRunningAction.SelectionChanged([parent, row](winrt::Windows::Foundation::IInspectable const&, SelectionChangedEventArgs const&) {
|
||||
@ -735,7 +735,7 @@ StackPanel SetupRunProgramControls(StackPanel& parent, StackPanel& row, Shortcut
|
||||
|
||||
Shortcut tempShortcut;
|
||||
CreateNewTempShortcut(static_cast<StackPanel>(row), tempShortcut, rowIndex);
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
});
|
||||
|
||||
runProgramElevationTypeCombo.SelectionChanged([parent, row](winrt::Windows::Foundation::IInspectable const&, SelectionChangedEventArgs const&) {
|
||||
@ -751,7 +751,7 @@ StackPanel SetupRunProgramControls(StackPanel& parent, StackPanel& row, Shortcut
|
||||
}
|
||||
Shortcut tempShortcut;
|
||||
CreateNewTempShortcut(static_cast<StackPanel>(row), tempShortcut, rowIndex);
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
});
|
||||
|
||||
runProgramStartWindow.SelectionChanged([parent, row](winrt::Windows::Foundation::IInspectable const&, SelectionChangedEventArgs const&) {
|
||||
@ -769,7 +769,7 @@ StackPanel SetupRunProgramControls(StackPanel& parent, StackPanel& row, Shortcut
|
||||
Shortcut tempShortcut;
|
||||
CreateNewTempShortcut(static_cast<StackPanel>(row), tempShortcut, rowIndex);
|
||||
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].first[1] = tempShortcut;
|
||||
ShortcutControl::shortcutRemapBuffer[rowIndex].mapping[1] = tempShortcut;
|
||||
});
|
||||
|
||||
pickFileBtn.Click([&, parent, row](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
|
||||
@ -943,17 +943,17 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
|
||||
{
|
||||
if (colIndex == 0)
|
||||
{
|
||||
shortcut = std::get<Shortcut>(shortcutRemapBuffer[rowIndex].first[0]);
|
||||
shortcut = std::get<Shortcut>(shortcutRemapBuffer[rowIndex].mapping[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shortcutRemapBuffer[rowIndex].first[1].index() != 1)
|
||||
if (shortcutRemapBuffer[rowIndex].mapping[1].index() != 1)
|
||||
{
|
||||
// not a shortcut, let's fix that.
|
||||
Shortcut newShortcut;
|
||||
shortcutRemapBuffer[rowIndex].first[1] = newShortcut;
|
||||
shortcutRemapBuffer[rowIndex].mapping[1] = newShortcut;
|
||||
}
|
||||
shortcut = std::get<Shortcut>(shortcutRemapBuffer[rowIndex].first[1]);
|
||||
shortcut = std::get<Shortcut>(shortcutRemapBuffer[rowIndex].mapping[1]);
|
||||
}
|
||||
|
||||
if (!shortcut.IsEmpty() && shortcut.HasChord())
|
||||
@ -964,7 +964,7 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
|
||||
}
|
||||
}
|
||||
|
||||
//remapBuffer[rowIndex].first.
|
||||
//remapBuffer[rowIndex].mapping.
|
||||
|
||||
// ContentDialog for detecting shortcuts. This is the parent UI element.
|
||||
ContentDialog detectShortcutBox;
|
||||
|
@ -72,7 +72,7 @@ SingleKeyRemapControl::SingleKeyRemapControl(StackPanel table, StackPanel row, c
|
||||
return;
|
||||
}
|
||||
|
||||
singleKeyRemapBuffer[rowIndex].first[1] = text.c_str();
|
||||
singleKeyRemapBuffer[rowIndex].mapping[1] = text.c_str();
|
||||
});
|
||||
|
||||
auto typeCombo = ComboBox();
|
||||
|
@ -69,10 +69,10 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is validated and buffer is updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::NoError);
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].first[0]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].first[1]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].first[0]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].first[1]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].mapping[0]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].mapping[1]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateAndUpdateKeyBufferElement method is successful when setting a key to non-null in a new row
|
||||
@ -89,8 +89,8 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is validated and buffer is updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::NoError);
|
||||
Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].first[0]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].first[1]));
|
||||
Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].mapping[0]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateAndUpdateKeyBufferElement method is successful when setting a key to non-null in a valid key to key
|
||||
@ -107,8 +107,8 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is validated and buffer is updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::NoError);
|
||||
Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].first[0]));
|
||||
Assert::AreEqual((DWORD)0x41, std::get<DWORD>(remapBuffer[0].first[1]));
|
||||
Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].mapping[0]));
|
||||
Assert::AreEqual((DWORD)0x41, std::get<DWORD>(remapBuffer[0].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateAndUpdateKeyBufferElement method is successful when setting a key to non-null in a valid key to shortcut
|
||||
@ -125,8 +125,8 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is validated and buffer is updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::NoError);
|
||||
Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].first[0]));
|
||||
Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[0].first[1]));
|
||||
Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].mapping[0]));
|
||||
Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[0].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column to the same value as the right column
|
||||
@ -143,8 +143,8 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is invalid and buffer is not updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::MapToSameKey);
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].first[0]));
|
||||
Assert::AreEqual((DWORD)0x41, std::get<DWORD>(remapBuffer[0].first[1]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].mapping[0]));
|
||||
Assert::AreEqual((DWORD)0x41, std::get<DWORD>(remapBuffer[0].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column of a key to key row to the same value as in another row
|
||||
@ -162,8 +162,8 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is invalid and buffer is not updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::SameKeyPreviouslyMapped);
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].first[0]));
|
||||
Assert::AreEqual((DWORD)0x43, std::get<DWORD>(remapBuffer[1].first[1]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0]));
|
||||
Assert::AreEqual((DWORD)0x43, std::get<DWORD>(remapBuffer[1].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column of a key to shortcut row to the same value as in another row
|
||||
@ -181,8 +181,8 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is invalid and buffer is not updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::SameKeyPreviouslyMapped);
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].first[0]));
|
||||
Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[1].first[1]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0]));
|
||||
Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[1].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column of a key to key row to a conflicting modifier with another row
|
||||
@ -200,8 +200,8 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is invalid and buffer is not updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::ConflictingModifierKey);
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].first[0]));
|
||||
Assert::AreEqual((DWORD)0x43, std::get<DWORD>(remapBuffer[1].first[1]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0]));
|
||||
Assert::AreEqual((DWORD)0x43, std::get<DWORD>(remapBuffer[1].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column of a key to shortcut row to a conflicting modifier with another row
|
||||
@ -219,8 +219,8 @@ namespace RemappingUITests
|
||||
|
||||
// Assert that the element is invalid and buffer is not updated
|
||||
Assert::AreEqual(true, error == ShortcutErrorType::ConflictingModifierKey);
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].first[0]));
|
||||
Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[1].first[1]));
|
||||
Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0]));
|
||||
Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[1].mapping[1]));
|
||||
}
|
||||
|
||||
// Test if the ValidateShortcutBufferElement method is successful and no drop down action is required on setting a column to null in a new or valid row
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
std::wstring runProgramArgs;
|
||||
std::wstring runProgramStartInDir;
|
||||
std::wstring uriToOpen;
|
||||
|
||||
|
||||
ProgramAlreadyRunningAction alreadyRunningAction = ProgramAlreadyRunningAction::ShowWindow;
|
||||
ElevationLevel elevationLevel = ElevationLevel::NonElevated;
|
||||
OperationType operationType = OperationType::RemapShortcut;
|
||||
@ -189,5 +189,11 @@ public:
|
||||
|
||||
using KeyShortcutTextUnion = std::variant<DWORD, Shortcut, std::wstring>;
|
||||
using RemapBufferItem = std::vector<KeyShortcutTextUnion>;
|
||||
using RemapBufferRow = std::pair<RemapBufferItem, std::wstring>;
|
||||
|
||||
struct RemapBufferRow
|
||||
{
|
||||
RemapBufferItem mapping{};
|
||||
std::wstring appName{};
|
||||
};
|
||||
|
||||
using RemapBuffer = std::vector<RemapBufferRow>;
|
||||
|
Loading…
Reference in New Issue
Block a user