-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Actions page editable #9949
Conversation
This comment has been minimized.
This comment has been minimized.
9001102
to
4ccebc7
Compare
This comment has been minimized.
This comment has been minimized.
4ccebc7
to
6460195
Compare
This comment has been minimized.
This comment has been minimized.
6460195
to
643b787
Compare
Misspellings found, please review:
To accept these changes, run the following commands from this repository on this branch
✏️ Contributor please read thisBy default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
See the 🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉 🗜️ If you see a bunch of garbage and it relates to a binary-ish string, please add a file path to the File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
|
643b787
to
ed9ec6d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea okay, I'm fine with like 99% of it, I just have a couple questions, and I think it needs more comments
|
||
Button acceptBTN{}; | ||
acceptBTN.Content(box_value(RS_(L"Actions_RenameConflictConfirmationAcceptButton"))); | ||
acceptBTN.Click([=](auto&, auto&) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capturing everything by value here seems sus, but it's probably fine? The only things getting captured are already members of the SUI, and it's not like this will ever get triggered after the SUI is destroyed, so yea this is probably fine
for (uint32_t i = 0; i < _KeyBindingList.Size(); ++i) | ||
{ | ||
const auto& kbdVM{ _KeyBindingList.GetAt(i) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (uint32_t i = 0; i < _KeyBindingList.Size(); ++i) | |
{ | |
const auto& kbdVM{ _KeyBindingList.GetAt(i) }; | |
for (const auto& kbdVM : _KeyBindingList) | |
{ |
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh never mind, we do need the index below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. We could use ContainerFromItem
, but I figured ContainerFromIndex
would be faster here since we're already iterating over all of the key binding view models anyways.
Bug Bash Notes (5/12)
|
Still need to come back to work on that performance issue. It seems doable, but I'll need a bit more help so I'll leave that for Monday. Added a nice background to the list view item when it's in edit mode. An annoying problem is that it'll only appear if you're using the Windows OS theme. But that's due to #9716. |
flyoutStack.Children().Append(confirmationQuestionTB); | ||
flyoutStack.Children().Append(acceptBTN); | ||
|
||
Flyout acceptChangesFlyout{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does a new flyout get created every time there's a conflicting command? Could there be a way to reuse it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish! As mentioned in the comments below:
- The data template prevents us from getting a control by name. So we have no way of targeting the button and attaching a pre-saved flyout.
- The flyout needs to appear sometimes. So we can't just build it in XAML, because then we don't have control over when it appears or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, dang that's pretty annoying 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if this will work, but you might be able to give the button a flyout without having it automagically open the flyout on every button press by putting the flyout in FlyoutBase.AttachedFlyout
. It's an attached property so this particular property can be set on just about any FrameworkElement
, but IIRC it doesn't behave the same as if you set the Flyout
property on Button.
https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.primitives.flyoutbase?view=winrt-19041#xaml-attached-properties - should tell you more about how to use this particular attached property
This is more an experimental idea though, not something I'd block over 😄
e.g.
<Button>
<FlyoutBase.AttachedFlyout>
<Flyout>
</Flyout>
</FlyoutBase.AttachedFlyout>
</Button>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea okay you touched everything I was worried about.
Hello @carlos-zamora! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questions mostly around function rather than form. Form looks excellent, and I like how it feels.
}; | ||
|
||
[default_interface] runtimeclass ActionMap : IActionMapView | ||
{ | ||
Boolean RebindKeys(Microsoft.Terminal.Control.KeyChord oldKeys, Microsoft.Terminal.Control.KeyChord newKeys); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm surprised that this takes the oldkeys and not the action -- shouldn't we enforce that the caller is providing an action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, oldKeys
can be used as a primary key the way it's written now.
If we wanted to switch over to using ActionAndArgs
, we could make the API look more like this:
void RegisterKeyBinding(ActionAndArgs, KeyChord);
void EraseKeyBinding(ActionAndArgs, KeyChord);
// For later...
void SetActionForKeyBinding(KeyChord, ActionAndArgs);
void SetName(ActionAndArgs, String);
I'm intentionally trying to make it so that we don't work with Command
outside of ActionMap
.
🎉 Handy links: |
Applies feedback from #9949 (review) Highlights include: - bugfix: make all edit buttons stay visible if the user is using assistive technology - rename a few functions and resources to match the correct naming scheme - update the localized text for a conflicting key chord being assigned - provide better comments throughout the actions page code ## References #9949 - Original PR Closes #10168
This introduces the ability to set the action for a key binding. A combo box is used to let the user select a new action. ## References #6900 - Actions page Epic #9427 - Actions page design doc #9949 - Actions page PR ## Detailed Description of the Pull Request / Additional comments ### Settings Model Changes - `ActionAndArgs` - new ctor that just takes a `ShortcutAction` - `ActionMap` - `AvailableActions` provides a map of all the "acceptable" actions to choose from. This is a merged list of (1) all `{ "command": X }` style actions and (2) any actions with args that are already defined in the ActionMap (or any parents). - `RegisterKeyBinding` introduces a new unnamed key binding to the action map. ### Editor Changes - XAML - Pretty straightforward, when in edit mode, we replace the text block with a combo box. This combo box just presents the actions you can choose from. - `RebindKeysEventArgs` --> `ModifyKeyBindingEventArgs` - `AvailableActionAndArgs` - stores the list of actions to choose from in the combo box - _Unfortunately_, `KeyBindingViewModel` needs this so that we can populate the combo box - `Actions` stores and maintains this though. We populate this from the settings model on navigation. - `ProposedAction` vs `CurrentAction` - similar to `ProposedKeys` and `Keys`, we need a way to distinguish the value from the settings model and the value of the control (i.e. combo box). - `CurrentAction` --> settings model - `ProposedAction` --> combo box selected item ## Validation Steps Performed - Cancel: - ✔️ change action --> cancel button --> begin editing action again --> original action is selected - Accept: - ✔️ don't change anything - ✔️ change action --> OK! --> Save! - NOTE: The original action is still left as a stub `{ "command": "closePane" }`. This is intentional because we want to prevent all modifications to the command palette. - ✔️ change action & change key chord --> OK! --> Save! - ✔️ change action & change key chord (conflicting key chord) --> OK! --> click ok on flyout --> Save! - NOTE: original action is left as a stub; original key chord explicitly unbound; new command/keys combo added.
Summary of the Pull Request
This PR lays the foundation for a new Actions page in the Settings UI as designed in #6900. The Actions page now leverages the
ActionMap
to display all of the key bindings and allow the user to modify the associated key chord or delete the key binding entirely.References
#9621 - ActionMap
#9926 - ActionMap serialization
#9428 - ActionMap Spec
#6900 - Actions page
#9427 - Actions page design doc
Detailed Description of the Pull Request / Additional comments
Settings Model Changes
Command::Copy()
now copies theActionAndArgs
ActionMap::RebindKeys()
handles changing the key chord of a key binding. If a conflict occurs, the conflicting key chord is overwritten.ActionMap::DeleteKeyBinding()
"deletes" a key binding by binding "unbound" to the given key chord.ActionMap::KeyBindings()
presents another view (similar toNameMap
) of theActionMap
. It specifically presents a map of key chords to commands. It is generated similar to howNameMap
is generated.Editor Changes
Actions.xaml
is mainly split into two parts:ListView
(as before) holds the list of key bindings. We could explore the idea of an items repeater, but theListView
seems to provide some niceties with regards to navigating the list via the key board (though none are selectable).DataTemplate
is used to represent each key binding inside theListView
. This is tricky because it is bound to aKeyBindingViewModel
which must provide all context necessary to modify the UI and the settings model. We cannot use names to target UI elements inside this template, so we must make the view model smart and force updates to the UI via changes in the view model.KeyBindingViewModel
is a view model object that controls the UI and the settings model.There are a number of TODOs in Actions.cpp will be long-term follow-ups and would be nice to have. This includes...
Actions::KeyBindingList
Demo