mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-19 18:11:39 -05:00
The actions page now has a list of all the commands (default, user, fragments etc) and clicking a command from that page brings you to an "Edit action" page where you can fully view and edit both the action type and any additional arguments. ## Detailed Description of the Pull Request / Additional comments Actions View Model * Added several new view models * `CommandViewModel` (view model for a `Command`), a list of these is created and managed by `ActionsViewModel` * `ActionArgsViewModel` (view model for an `ActionArgs`), created and managed by `CommandViewModel` * `ArgWrapper` (view model for each individual argument inside an `ActionArgs`), created and managed by `ActionArgsViewModel` Actions page * No longer a list of only keybindings, instead it is a list of every command Terminal knows about EditAction page * New page that you get to by clicking a command from the Actions page * Bound to a `CommandViewModel` * Allows editing the type of shortcut action and the command name * Depending on the shortcut action, displays a list of additional arguments allowed for the command with the appropriate templating (bool arguments are switches, flags are checkboxes etc) Closes #19019
54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include "pch.h"
|
|
#include "EditAction.h"
|
|
#include "EditAction.g.cpp"
|
|
#include "LibraryResources.h"
|
|
#include "../TerminalSettingsModel/AllShortcutActions.h"
|
|
|
|
using namespace winrt::Windows::UI::Xaml;
|
|
using namespace winrt::Windows::UI::Xaml::Navigation;
|
|
|
|
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
{
|
|
EditAction::EditAction()
|
|
{
|
|
}
|
|
|
|
void EditAction::OnNavigatedTo(const NavigationEventArgs& e)
|
|
{
|
|
const auto args = e.Parameter().as<Editor::NavigateToCommandArgs>();
|
|
_ViewModel = args.Command();
|
|
_propagateWindowRootRevoker = _ViewModel.PropagateWindowRootRequested(
|
|
winrt::auto_revoke,
|
|
[windowRoot = args.WindowRoot()](const IInspectable&, const Editor::ArgWrapper& wrapper) {
|
|
if (wrapper)
|
|
{
|
|
wrapper.WindowRoot(windowRoot);
|
|
}
|
|
});
|
|
auto weakThis = get_weak();
|
|
_focusContainerRevoker = _ViewModel.FocusContainer(
|
|
winrt::auto_revoke,
|
|
[weakThis](const auto&, const auto& args) {
|
|
if (auto page{ weakThis.get() })
|
|
{
|
|
if (auto kcVM{ args.try_as<KeyChordViewModel>() })
|
|
{
|
|
if (const auto& container = page->KeyChordListView().ContainerFromItem(*kcVM))
|
|
{
|
|
container.as<Controls::ListViewItem>().Focus(FocusState::Programmatic);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
_layoutUpdatedRevoker = LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) {
|
|
// Only let this succeed once.
|
|
_layoutUpdatedRevoker.revoke();
|
|
|
|
CommandNameTextBox().Focus(FocusState::Programmatic);
|
|
});
|
|
}
|
|
}
|