terminal/src/cascadia/TerminalSettingsEditor/AddProfile.cpp
PankajBhojwani b53bd672d7
Create a new page for "Add new profile" in the SUI (#9352)
- Whenever we add a new profile setting from now on we have to update
  `Profile::CopySettings` _and_ `CascadiaSettings::DuplicateProfile` 👎 

Notes from bug bash (checked bugs have been resolved):

- [ ] The duplicate list can be very long if you have profiles
- [x] DH: "Create new" seems too vague. "New empty profile" or something
  seems a little clearer to me.
- [x] There is no deduplication counter for name
- [x] Crash when your settings file is corrupt and we had to fall back
  to the defaults and you duplicate a profile
- [x] Crash due to #10003

## PR Checklist
* [x] Closes #9121
2021-05-05 04:15:25 +00:00

43 lines
1.3 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "pch.h"
#include "AddProfile.h"
#include "AddProfile.g.cpp"
#include "AddProfilePageNavigationState.g.cpp"
#include "EnumEntry.h"
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::System;
using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::UI::Xaml::Navigation;
using namespace winrt::Microsoft::Terminal::Settings::Model;
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
AddProfile::AddProfile()
{
InitializeComponent();
}
void AddProfile::OnNavigatedTo(const NavigationEventArgs& e)
{
_State = e.Parameter().as<Editor::AddProfilePageNavigationState>();
}
void AddProfile::AddNewClick(const IInspectable& /*sender*/,
const Windows::UI::Xaml::RoutedEventArgs& /*eventArgs*/)
{
_State.RequestAddNew();
}
void AddProfile::DuplicateClick(const IInspectable& /*sender*/,
const Windows::UI::Xaml::RoutedEventArgs& /*eventArgs*/)
{
if (const auto selected = Profiles().SelectedItem())
{
_State.RequestDuplicate(selected.try_as<Model::Profile>().Guid());
}
}
}