mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
[Keyboard Manager] Confirmation Dialog for orphaned keys and partial remappings. (#2811)
* 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
This commit is contained in:
committed by
GitHub
parent
c39be3dbc9
commit
8c04421387
41
src/modules/keyboardmanager/ui/Dialog.h
Normal file
41
src/modules/keyboardmanager/ui/Dialog.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#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);
|
||||
};
|
||||
Reference in New Issue
Block a user