Move KBM warnings at Apply to Flyouts (#2237)

* Moved warning to Flyout

* Fixed formatting
This commit is contained in:
Arjun Balgovind 2020-04-20 08:59:35 -07:00 committed by GitHub
parent 325db535c0
commit ddf800de10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View File

@ -137,7 +137,9 @@ void createEditKeyboardWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMan
keyRemapTable.Children().Append(tableHeaderRow);
// Message to display success/failure of saving settings.
Flyout applyFlyout;
TextBlock settingsMessage;
applyFlyout.Content(settingsMessage);
// Store handle of edit keyboard window
SingleKeyRemapControl::EditKeyboardWindowHandle = _hWndEditKeyboardWindow;
@ -162,6 +164,7 @@ void createEditKeyboardWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMan
applyButton.Background(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::LightGray() });
applyButton.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Black() });
applyButton.Content(winrt::box_value(winrt::to_hstring("Apply")));
applyButton.Flyout(applyFlyout);
applyButton.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
bool isSuccess = true;
// Clear existing Key Remaps
@ -191,25 +194,21 @@ void createEditKeyboardWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMan
if (isSuccess && saveResult)
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Green() });
settingsMessage.Text(winrt::to_hstring("Remapping successful!"));
settingsMessage.Text(winrt::to_hstring("Remapping successful"));
}
else if (!isSuccess && saveResult)
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Red() });
settingsMessage.Text(winrt::to_hstring("All remappings were not successfully applied."));
settingsMessage.Text(winrt::to_hstring("All remappings were not successfully applied"));
}
else
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Red() });
settingsMessage.Text(winrt::to_hstring("Failed to save the remappings."));
settingsMessage.Text(L"Failed to save the remappings.");
}
});
header.Children().Append(headerText);
header.Children().Append(cancelButton);
header.Children().Append(applyButton);
header.Children().Append(settingsMessage);
// Add remap key button
Windows::UI::Xaml::Controls::Button addRemapKey;

View File

@ -128,7 +128,9 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
shortcutTable.Children().Append(tableHeaderRow);
// Message to display success/failure of saving settings.
Flyout applyFlyout;
TextBlock settingsMessage;
applyFlyout.Content(settingsMessage);
// Store handle of edit shortcuts window
ShortcutControl::EditShortcutsWindowHandle = _hWndEditShortcutsWindow;
@ -151,6 +153,7 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
// Apply button
Button applyButton;
applyButton.Content(winrt::box_value(winrt::to_hstring("Apply")));
applyButton.Flyout(applyFlyout);
applyButton.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
bool isSuccess = true;
// Clear existing shortcuts
@ -181,18 +184,15 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
if (isSuccess && saveResult)
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Green() });
settingsMessage.Text(winrt::to_hstring("Remapping successful!"));
}
else if (!isSuccess && saveResult)
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Red() });
settingsMessage.Text(winrt::to_hstring("All remappings were not successfully applied."));
}
else
{
settingsMessage.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Red() });
settingsMessage.Text(winrt::to_hstring("Failed to save the remappings."));
settingsMessage.Text(L"Failed to save the remappings.");
}
});
@ -259,7 +259,7 @@ LRESULT CALLBACK EditShortcutsWindowProc(HWND hWnd, UINT messageCode, WPARAM wPa
return 0;
}
bool CheckEditShortcutsWindowActive()
bool CheckEditShortcutsWindowActive()
{
bool result = false;
std::unique_lock<std::mutex> hwndLock(editShortcutsWindowMutex);