mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-13 08:08:24 +08:00
8c04421387
* WIP Confirmation dialog for orphaned keys * Confirmation Dialog for orphaned keys * White OK button, Anyways capitalizef * Change Apply to Ok for shortcuts * Validate that mappings can be made before changing keyboardManagerState * Set fixed MinWidth for OK button * Fix typo * Partial remappings confirmation dialog Both for Shortcuts and SingleKey * Remove warning icon callback in OnClickAccept * Add text wrapping for OrphanKeys dialog
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#pragma once
|
|
#include <vector>
|
|
#include <functional>
|
|
#include <keyboardmanager/common/Helpers.h>
|
|
#include <set>
|
|
#include <winrt/Windows.UI.Xaml.h>
|
|
|
|
using namespace winrt::Windows::Foundation;
|
|
|
|
namespace Dialog
|
|
{
|
|
template<typename T>
|
|
KeyboardManagerHelper::ErrorType CheckIfRemappingsAreValid(
|
|
const std::vector<std::vector<T>>& remappings,
|
|
std::function<bool(T)> isValid)
|
|
{
|
|
KeyboardManagerHelper::ErrorType isSuccess = KeyboardManagerHelper::ErrorType::NoError;
|
|
std::set<T> ogKeys;
|
|
for (int i = 0; i < remappings.size(); i++)
|
|
{
|
|
T ogKey = remappings[i][0];
|
|
T newKey = remappings[i][1];
|
|
|
|
if (isValid(ogKey) && isValid(newKey) && ogKeys.find(ogKey) == ogKeys.end())
|
|
{
|
|
ogKeys.insert(ogKey);
|
|
}
|
|
else if (isValid(ogKey) && isValid(newKey) && ogKeys.find(ogKey) != ogKeys.end())
|
|
{
|
|
isSuccess = KeyboardManagerHelper::ErrorType::RemapUnsuccessful;
|
|
}
|
|
else
|
|
{
|
|
isSuccess = KeyboardManagerHelper::ErrorType::RemapUnsuccessful;
|
|
}
|
|
}
|
|
return isSuccess;
|
|
}
|
|
|
|
IAsyncOperation<bool> PartialRemappingConfirmationDialog(winrt::Windows::UI::Xaml::XamlRoot root);
|
|
};
|