Improve warnings for KBM (dev/build-features) (#2386)

* Handled invalid input for single key remaps

* Added some functions

* Added better error message functions and finished warnings for edit keyboard

* Updated dropdown order of keys

* Added new warning template for shortcuts

* Added show warning on Apply code

* Removed old flyout code

* Fixed issue where tooltips were replaced on Apply

* Simplified == operator
This commit is contained in:
Arjun Balgovind
2020-04-26 15:09:40 -07:00
committed by GitHub
parent 7ec8d02c1f
commit 38ecc82e97
15 changed files with 439 additions and 125 deletions

View File

@@ -29,16 +29,16 @@ public:
// Vector to store dynamically allocated KeyDropDownControl objects to avoid early destruction
std::vector<std::unique_ptr<KeyDropDownControl>> keyDropDownControlObjects;
ShortcutControl(Grid table, const size_t colIndex)
ShortcutControl(Grid table, const int colIndex, FontIcon warning, ToolTip toolTip)
{
shortcutDropDownStackPanel.Spacing(10);
shortcutDropDownStackPanel.Orientation(Windows::UI::Xaml::Controls::Orientation::Horizontal);
typeShortcut.Content(winrt::box_value(L"Type Shortcut"));
typeShortcut.Click([&, table, colIndex](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
typeShortcut.Click([&, table, colIndex, warning, toolTip](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
keyboardManagerState->SetUIState(KeyboardManagerUIState::DetectShortcutWindowActivated, EditShortcutsWindowHandle);
// Using the XamlRoot of the typeShortcut to get the root of the XAML host
createDetectShortcutWindow(sender, sender.as<Button>().XamlRoot(), shortcutRemapBuffer, *keyboardManagerState, colIndex, table);
createDetectShortcutWindow(sender, sender.as<Button>().XamlRoot(), shortcutRemapBuffer, *keyboardManagerState, colIndex, table, warning, toolTip);
});
shortcutControlLayout.Margin({ 0, 0, 0, 10 });
@@ -46,7 +46,7 @@ public:
shortcutControlLayout.Children().Append(typeShortcut);
shortcutControlLayout.Children().Append(shortcutDropDownStackPanel);
KeyDropDownControl::AddDropDown(table, shortcutControlLayout, shortcutDropDownStackPanel, colIndex, shortcutRemapBuffer, keyDropDownControlObjects);
KeyDropDownControl::AddDropDown(table, shortcutControlLayout, shortcutDropDownStackPanel, colIndex, shortcutRemapBuffer, keyDropDownControlObjects, warning, toolTip);
shortcutControlLayout.UpdateLayout();
}
@@ -54,11 +54,11 @@ public:
static void AddNewShortcutControlRow(Grid& parent, std::vector<std::vector<std::unique_ptr<ShortcutControl>>>& keyboardRemapControlObjects, Shortcut originalKeys = Shortcut(), Shortcut newKeys = Shortcut());
// Function to add a shortcut to the shortcut control as combo boxes
void AddShortcutToControl(Shortcut& shortcut, Grid table, StackPanel parent, KeyboardManagerState& keyboardManagerState, const size_t colIndex);
void AddShortcutToControl(Shortcut& shortcut, Grid table, StackPanel parent, KeyboardManagerState& keyboardManagerState, const int colIndex, FontIcon warning, ToolTip toolTip);
// Function to return the stack panel element of the ShortcutControl. This is the externally visible UI element which can be used to add it to other layouts
StackPanel getShortcutControl();
// Function to create the detect shortcut UI window
void createDetectShortcutWindow(winrt::Windows::Foundation::IInspectable const& sender, XamlRoot xamlRoot, std::vector<std::vector<Shortcut>>& shortcutRemapBuffer, KeyboardManagerState& keyboardManagerState, const size_t colIndex, Grid table);
void createDetectShortcutWindow(winrt::Windows::Foundation::IInspectable const& sender, XamlRoot xamlRoot, std::vector<std::vector<Shortcut>>& shortcutRemapBuffer, KeyboardManagerState& keyboardManagerState, const int colIndex, Grid table, FontIcon warning, ToolTip toolTip);
};