Skip to content

Commit

Permalink
polish moving entries to folders
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Nov 21, 2024
1 parent 06ef29c commit b1f695f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/cascadia/TerminalSettingsEditor/NewTabMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void NewTabMenu::FolderPickerDialog_Opened(const IInspectable& /*sender*/, const Controls::ContentDialogOpenedEventArgs& /*e*/)
{
_ViewModel.CurrentFolderTreeViewSelectedItem(nullptr);
// Ideally, we'd bind IsPrimaryButtonEnabled to something like mtu:Converters.isEmpty(FolderTree.SelectedItems.Size) in the XAML.
// Similar to above, the XAML compiler can't find FolderTree when we try that.
// To make matters worse, SelectionChanged doesn't exist for WinUI 2's TreeView.
// Let's just select the first item and call it a day.
_ViewModel.GenerateFolderTree();
_ViewModel.CurrentFolderTreeViewSelectedItem(_ViewModel.FolderTree().First().Current());
}

void NewTabMenu::FolderPickerDialog_PrimaryButtonClick(const IInspectable& /*sender*/, const Controls::ContentDialogButtonClickEventArgs& /*e*/)
Expand Down
9 changes: 8 additions & 1 deletion src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,19 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void NewTabMenuViewModel::RequestMoveEntriesToFolder(const Windows::Foundation::Collections::IVector<Editor::NewTabMenuEntryViewModel>& entries, const Editor::FolderEntryViewModel& destinationFolder)
{
auto destination{ destinationFolder == nullptr ? _rootEntries : destinationFolder.Entries() };
for (auto&& e : entries)
{
// Don't move the folder into itself (just skip over it)
if (e == destinationFolder)
{
continue;
}

// Remove entry from the current layer,
// and add it to the destination folder
RequestDeleteEntry(e);
destinationFolder.Entries().Append(e);
destination.Append(e);
}
}

Expand Down

0 comments on commit b1f695f

Please sign in to comment.